blob: 22aea7b089c67e84adbe585fa3ebed32b82d2cda [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 Iwai66946352010-03-29 17:21:45 +02004987/* fill adc_nids (and capsrc_nids) containing all active input pins */
4988static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
4989 int num_nids)
4990{
4991 struct alc_spec *spec = codec->spec;
4992 int n;
4993 hda_nid_t fallback_adc = 0, fallback_cap = 0;
4994
4995 for (n = 0; n < num_nids; n++) {
4996 hda_nid_t adc, cap;
4997 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
4998 int nconns, i, j;
4999
5000 adc = nids[n];
5001 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5002 continue;
5003 cap = adc;
5004 nconns = snd_hda_get_connections(codec, cap, conn,
5005 ARRAY_SIZE(conn));
5006 if (nconns == 1) {
5007 cap = conn[0];
5008 nconns = snd_hda_get_connections(codec, cap, conn,
5009 ARRAY_SIZE(conn));
5010 }
5011 if (nconns <= 0)
5012 continue;
5013 if (!fallback_adc) {
5014 fallback_adc = adc;
5015 fallback_cap = cap;
5016 }
5017 for (i = 0; i < AUTO_PIN_LAST; i++) {
5018 hda_nid_t nid = spec->autocfg.input_pins[i];
5019 if (!nid)
5020 continue;
5021 for (j = 0; j < nconns; j++) {
5022 if (conn[j] == nid)
5023 break;
5024 }
5025 if (j >= nconns)
5026 break;
5027 }
5028 if (i >= AUTO_PIN_LAST) {
5029 int num_adcs = spec->num_adc_nids;
5030 spec->private_adc_nids[num_adcs] = adc;
5031 spec->private_capsrc_nids[num_adcs] = cap;
5032 spec->num_adc_nids++;
5033 spec->adc_nids = spec->private_adc_nids;
5034 if (adc != cap)
5035 spec->capsrc_nids = spec->private_capsrc_nids;
5036 }
5037 }
5038 if (!spec->num_adc_nids) {
5039 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
5040 " using fallback 0x%x\n", fallback_adc);
5041 spec->private_adc_nids[0] = fallback_adc;
5042 spec->adc_nids = spec->private_adc_nids;
5043 if (fallback_adc != fallback_cap) {
5044 spec->private_capsrc_nids[0] = fallback_cap;
5045 spec->capsrc_nids = spec->private_adc_nids;
5046 }
5047 }
5048}
5049
Takashi Iwai67d634c2009-11-16 15:35:59 +01005050#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005051#define set_beep_amp(spec, nid, idx, dir) \
5052 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01005053#else
5054#define set_beep_amp(spec, nid, idx, dir) /* NOP */
5055#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005056
5057/*
5058 * OK, here we have finally the patch for ALC880
5059 */
5060
Linus Torvalds1da177e2005-04-16 15:20:36 -07005061static int patch_alc880(struct hda_codec *codec)
5062{
5063 struct alc_spec *spec;
5064 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005065 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005066
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005067 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005068 if (spec == NULL)
5069 return -ENOMEM;
5070
5071 codec->spec = spec;
5072
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005073 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5074 alc880_models,
5075 alc880_cfg_tbl);
5076 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005077 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5078 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005079 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005080 }
5081
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005082 if (board_config == ALC880_AUTO) {
5083 /* automatic parse from the BIOS config */
5084 err = alc880_parse_auto_config(codec);
5085 if (err < 0) {
5086 alc_free(codec);
5087 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005088 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005089 printk(KERN_INFO
5090 "hda_codec: Cannot set up configuration "
5091 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005092 board_config = ALC880_3ST;
5093 }
5094 }
5095
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005096 err = snd_hda_attach_beep_device(codec, 0x1);
5097 if (err < 0) {
5098 alc_free(codec);
5099 return err;
5100 }
5101
Kailang Yangdf694da2005-12-05 19:42:22 +01005102 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005103 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005104
Linus Torvalds1da177e2005-04-16 15:20:36 -07005105 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5106 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005107 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005108
Linus Torvalds1da177e2005-04-16 15:20:36 -07005109 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5110 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5111
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005112 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005113 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005114 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005115 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005116 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005117 if (wcap != AC_WID_AUD_IN) {
5118 spec->adc_nids = alc880_adc_nids_alt;
5119 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005120 } else {
5121 spec->adc_nids = alc880_adc_nids;
5122 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005123 }
5124 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005125 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005126 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005127
Takashi Iwai2134ea42008-01-10 16:53:55 +01005128 spec->vmaster_nid = 0x0c;
5129
Linus Torvalds1da177e2005-04-16 15:20:36 -07005130 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005131 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005132 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005133#ifdef CONFIG_SND_HDA_POWER_SAVE
5134 if (!spec->loopback.amplist)
5135 spec->loopback.amplist = alc880_loopbacks;
5136#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005137
5138 return 0;
5139}
5140
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005141
Linus Torvalds1da177e2005-04-16 15:20:36 -07005142/*
5143 * ALC260 support
5144 */
5145
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005146static hda_nid_t alc260_dac_nids[1] = {
5147 /* front */
5148 0x02,
5149};
5150
5151static hda_nid_t alc260_adc_nids[1] = {
5152 /* ADC0 */
5153 0x04,
5154};
5155
Kailang Yangdf694da2005-12-05 19:42:22 +01005156static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005157 /* ADC1 */
5158 0x05,
5159};
5160
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005161/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5162 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5163 */
5164static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005165 /* ADC0, ADC1 */
5166 0x04, 0x05
5167};
5168
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005169#define ALC260_DIGOUT_NID 0x03
5170#define ALC260_DIGIN_NID 0x06
5171
5172static struct hda_input_mux alc260_capture_source = {
5173 .num_items = 4,
5174 .items = {
5175 { "Mic", 0x0 },
5176 { "Front Mic", 0x1 },
5177 { "Line", 0x2 },
5178 { "CD", 0x4 },
5179 },
5180};
5181
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005182/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005183 * headphone jack and the internal CD lines since these are the only pins at
5184 * which audio can appear. For flexibility, also allow the option of
5185 * recording the mixer output on the second ADC (ADC0 doesn't have a
5186 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005187 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005188static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5189 {
5190 .num_items = 3,
5191 .items = {
5192 { "Mic/Line", 0x0 },
5193 { "CD", 0x4 },
5194 { "Headphone", 0x2 },
5195 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005196 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005197 {
5198 .num_items = 4,
5199 .items = {
5200 { "Mic/Line", 0x0 },
5201 { "CD", 0x4 },
5202 { "Headphone", 0x2 },
5203 { "Mixer", 0x5 },
5204 },
5205 },
5206
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005207};
5208
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005209/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5210 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005211 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005212static struct hda_input_mux alc260_acer_capture_sources[2] = {
5213 {
5214 .num_items = 4,
5215 .items = {
5216 { "Mic", 0x0 },
5217 { "Line", 0x2 },
5218 { "CD", 0x4 },
5219 { "Headphone", 0x5 },
5220 },
5221 },
5222 {
5223 .num_items = 5,
5224 .items = {
5225 { "Mic", 0x0 },
5226 { "Line", 0x2 },
5227 { "CD", 0x4 },
5228 { "Headphone", 0x6 },
5229 { "Mixer", 0x5 },
5230 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005231 },
5232};
Michael Schwingencc959482009-02-22 18:58:45 +01005233
5234/* Maxdata Favorit 100XS */
5235static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5236 {
5237 .num_items = 2,
5238 .items = {
5239 { "Line/Mic", 0x0 },
5240 { "CD", 0x4 },
5241 },
5242 },
5243 {
5244 .num_items = 3,
5245 .items = {
5246 { "Line/Mic", 0x0 },
5247 { "CD", 0x4 },
5248 { "Mixer", 0x5 },
5249 },
5250 },
5251};
5252
Linus Torvalds1da177e2005-04-16 15:20:36 -07005253/*
5254 * This is just place-holder, so there's something for alc_build_pcms to look
5255 * at when it calculates the maximum number of channels. ALC260 has no mixer
5256 * element which allows changing the channel mode, so the verb list is
5257 * never used.
5258 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005259static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005260 { 2, NULL },
5261};
5262
Kailang Yangdf694da2005-12-05 19:42:22 +01005263
5264/* Mixer combinations
5265 *
5266 * basic: base_output + input + pc_beep + capture
5267 * HP: base_output + input + capture_alt
5268 * HP_3013: hp_3013 + input + capture
5269 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005270 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005271 */
5272
5273static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005274 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005275 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005276 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5277 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5278 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5279 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5280 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005281};
Kailang Yangdf694da2005-12-05 19:42:22 +01005282
5283static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005284 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5285 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5286 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5287 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5288 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5289 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5290 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5291 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005292 { } /* end */
5293};
5294
Takashi Iwaibec15c32008-01-28 18:16:30 +01005295/* update HP, line and mono out pins according to the master switch */
5296static void alc260_hp_master_update(struct hda_codec *codec,
5297 hda_nid_t hp, hda_nid_t line,
5298 hda_nid_t mono)
5299{
5300 struct alc_spec *spec = codec->spec;
5301 unsigned int val = spec->master_sw ? PIN_HP : 0;
5302 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005303 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005304 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005305 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005306 val);
5307 /* mono (speaker) depending on the HP jack sense */
5308 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005309 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005310 val);
5311}
5312
5313static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5314 struct snd_ctl_elem_value *ucontrol)
5315{
5316 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5317 struct alc_spec *spec = codec->spec;
5318 *ucontrol->value.integer.value = spec->master_sw;
5319 return 0;
5320}
5321
5322static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5323 struct snd_ctl_elem_value *ucontrol)
5324{
5325 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5326 struct alc_spec *spec = codec->spec;
5327 int val = !!*ucontrol->value.integer.value;
5328 hda_nid_t hp, line, mono;
5329
5330 if (val == spec->master_sw)
5331 return 0;
5332 spec->master_sw = val;
5333 hp = (kcontrol->private_value >> 16) & 0xff;
5334 line = (kcontrol->private_value >> 8) & 0xff;
5335 mono = kcontrol->private_value & 0xff;
5336 alc260_hp_master_update(codec, hp, line, mono);
5337 return 1;
5338}
5339
5340static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5341 {
5342 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5343 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005344 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005345 .info = snd_ctl_boolean_mono_info,
5346 .get = alc260_hp_master_sw_get,
5347 .put = alc260_hp_master_sw_put,
5348 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5349 },
5350 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5351 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5352 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5353 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5354 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5355 HDA_OUTPUT),
5356 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5357 { } /* end */
5358};
5359
5360static struct hda_verb alc260_hp_unsol_verbs[] = {
5361 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5362 {},
5363};
5364
5365static void alc260_hp_automute(struct hda_codec *codec)
5366{
5367 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005368
Wu Fengguang864f92b2009-11-18 12:38:02 +08005369 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005370 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5371}
5372
5373static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5374{
5375 if ((res >> 26) == ALC880_HP_EVENT)
5376 alc260_hp_automute(codec);
5377}
5378
Kailang Yangdf694da2005-12-05 19:42:22 +01005379static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005380 {
5381 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5382 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005383 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005384 .info = snd_ctl_boolean_mono_info,
5385 .get = alc260_hp_master_sw_get,
5386 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005387 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005388 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005389 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5390 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5391 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5392 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5393 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5394 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005395 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5396 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005397 { } /* end */
5398};
5399
Kailang Yang3f878302008-08-26 13:02:23 +02005400static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5401 .ops = &snd_hda_bind_vol,
5402 .values = {
5403 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5404 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5405 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5406 0
5407 },
5408};
5409
5410static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5411 .ops = &snd_hda_bind_sw,
5412 .values = {
5413 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5414 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5415 0
5416 },
5417};
5418
5419static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5420 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5421 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5422 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5423 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5424 { } /* end */
5425};
5426
Takashi Iwaibec15c32008-01-28 18:16:30 +01005427static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5428 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5429 {},
5430};
5431
5432static void alc260_hp_3013_automute(struct hda_codec *codec)
5433{
5434 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005435
Wu Fengguang864f92b2009-11-18 12:38:02 +08005436 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005437 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005438}
5439
5440static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5441 unsigned int res)
5442{
5443 if ((res >> 26) == ALC880_HP_EVENT)
5444 alc260_hp_3013_automute(codec);
5445}
5446
Kailang Yang3f878302008-08-26 13:02:23 +02005447static void alc260_hp_3012_automute(struct hda_codec *codec)
5448{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005449 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005450
Kailang Yang3f878302008-08-26 13:02:23 +02005451 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5452 bits);
5453 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5454 bits);
5455 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5456 bits);
5457}
5458
5459static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5460 unsigned int res)
5461{
5462 if ((res >> 26) == ALC880_HP_EVENT)
5463 alc260_hp_3012_automute(codec);
5464}
5465
5466/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005467 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5468 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005469static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005470 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005471 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005472 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005473 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5474 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5475 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5476 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005477 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005478 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5479 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005480 { } /* end */
5481};
5482
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005483/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5484 * versions of the ALC260 don't act on requests to enable mic bias from NID
5485 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5486 * datasheet doesn't mention this restriction. At this stage it's not clear
5487 * whether this behaviour is intentional or is a hardware bug in chip
5488 * revisions available in early 2006. Therefore for now allow the
5489 * "Headphone Jack Mode" control to span all choices, but if it turns out
5490 * that the lack of mic bias for this NID is intentional we could change the
5491 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5492 *
5493 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5494 * don't appear to make the mic bias available from the "line" jack, even
5495 * though the NID used for this jack (0x14) can supply it. The theory is
5496 * that perhaps Acer have included blocking capacitors between the ALC260
5497 * and the output jack. If this turns out to be the case for all such
5498 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5499 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005500 *
5501 * The C20x Tablet series have a mono internal speaker which is controlled
5502 * via the chip's Mono sum widget and pin complex, so include the necessary
5503 * controls for such models. On models without a "mono speaker" the control
5504 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005505 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005506static struct snd_kcontrol_new alc260_acer_mixer[] = {
5507 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5508 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005509 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005510 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005511 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005512 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005513 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005514 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5515 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5516 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5517 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5518 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5519 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5520 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5521 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005522 { } /* end */
5523};
5524
Michael Schwingencc959482009-02-22 18:58:45 +01005525/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5526 */
5527static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5528 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5529 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5530 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5531 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5532 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5533 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5534 { } /* end */
5535};
5536
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005537/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5538 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5539 */
5540static struct snd_kcontrol_new alc260_will_mixer[] = {
5541 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5542 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5543 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5544 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5545 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5546 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5547 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5548 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5549 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5550 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005551 { } /* end */
5552};
5553
5554/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5555 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5556 */
5557static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5558 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5559 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5560 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5561 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5562 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5563 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5564 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5565 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5566 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5567 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5568 { } /* end */
5569};
5570
Kailang Yangdf694da2005-12-05 19:42:22 +01005571/*
5572 * initialization verbs
5573 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005574static struct hda_verb alc260_init_verbs[] = {
5575 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005576 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005577 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005578 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005579 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005580 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005581 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005582 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005583 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005584 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005585 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005586 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005587 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005588 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005589 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005590 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005591 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005592 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5593 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005594 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005595 /* set connection select to line in (default select for this ADC) */
5596 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005597 /* mute capture amp left and right */
5598 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5599 /* set connection select to line in (default select for this ADC) */
5600 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005601 /* set vol=0 Line-Out mixer amp left and right */
5602 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5603 /* unmute pin widget amp left and right (no gain on this amp) */
5604 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5605 /* set vol=0 HP mixer amp left and right */
5606 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5607 /* unmute pin widget amp left and right (no gain on this amp) */
5608 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5609 /* set vol=0 Mono mixer amp left and right */
5610 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5611 /* unmute pin widget amp left and right (no gain on this amp) */
5612 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5613 /* unmute LINE-2 out pin */
5614 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005615 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5616 * Line In 2 = 0x03
5617 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005618 /* mute analog inputs */
5619 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5620 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5621 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5622 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5623 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005624 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005625 /* mute Front out path */
5626 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5627 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5628 /* mute Headphone out path */
5629 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5630 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5631 /* mute Mono out path */
5632 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5633 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005634 { }
5635};
5636
Takashi Iwai474167d2006-05-17 17:17:43 +02005637#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005638static struct hda_verb alc260_hp_init_verbs[] = {
5639 /* Headphone and output */
5640 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5641 /* mono output */
5642 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5643 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5644 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5645 /* Mic2 (front panel) pin widget for input and vref at 80% */
5646 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5647 /* Line In pin widget for input */
5648 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5649 /* Line-2 pin widget for output */
5650 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5651 /* CD pin widget for input */
5652 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5653 /* unmute amp left and right */
5654 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5655 /* set connection select to line in (default select for this ADC) */
5656 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5657 /* unmute Line-Out mixer amp left and right (volume = 0) */
5658 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5659 /* mute pin widget amp left and right (no gain on this amp) */
5660 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5661 /* unmute HP mixer amp left and right (volume = 0) */
5662 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5663 /* mute pin widget amp left and right (no gain on this amp) */
5664 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005665 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5666 * Line In 2 = 0x03
5667 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005668 /* mute analog inputs */
5669 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5671 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5673 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005674 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5675 /* Unmute Front out path */
5676 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5677 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5678 /* Unmute Headphone out path */
5679 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5680 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5681 /* Unmute Mono out path */
5682 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5683 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5684 { }
5685};
Takashi Iwai474167d2006-05-17 17:17:43 +02005686#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005687
5688static struct hda_verb alc260_hp_3013_init_verbs[] = {
5689 /* Line out and output */
5690 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5691 /* mono output */
5692 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5693 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5694 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5695 /* Mic2 (front panel) pin widget for input and vref at 80% */
5696 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5697 /* Line In pin widget for input */
5698 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5699 /* Headphone pin widget for output */
5700 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5701 /* CD pin widget for input */
5702 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5703 /* unmute amp left and right */
5704 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5705 /* set connection select to line in (default select for this ADC) */
5706 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5707 /* unmute Line-Out mixer amp left and right (volume = 0) */
5708 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5709 /* mute pin widget amp left and right (no gain on this amp) */
5710 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5711 /* unmute HP mixer amp left and right (volume = 0) */
5712 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5713 /* mute pin widget amp left and right (no gain on this amp) */
5714 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005715 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5716 * Line In 2 = 0x03
5717 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005718 /* mute analog inputs */
5719 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5720 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5721 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5722 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5723 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005724 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5725 /* Unmute Front out path */
5726 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5727 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5728 /* Unmute Headphone out path */
5729 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5730 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5731 /* Unmute Mono out path */
5732 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5733 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5734 { }
5735};
5736
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005737/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005738 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5739 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005740 */
5741static struct hda_verb alc260_fujitsu_init_verbs[] = {
5742 /* Disable all GPIOs */
5743 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5744 /* Internal speaker is connected to headphone pin */
5745 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5746 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5747 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005748 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5749 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5750 /* Ensure all other unused pins are disabled and muted. */
5751 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5752 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005753 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005754 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005755 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005756 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5757 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5758 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005759
Jonathan Woithef7ace402006-02-28 11:46:14 +01005760 /* Disable digital (SPDIF) pins */
5761 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5762 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005763
Kailang Yangea1fb292008-08-26 12:58:38 +02005764 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005765 * when acting as an output.
5766 */
5767 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5768
5769 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005770 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5771 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5772 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5773 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5774 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5775 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5776 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5777 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5778 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005779
Jonathan Woithef7ace402006-02-28 11:46:14 +01005780 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5781 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5782 /* Unmute Line1 pin widget output buffer since it starts as an output.
5783 * If the pin mode is changed by the user the pin mode control will
5784 * take care of enabling the pin's input/output buffers as needed.
5785 * Therefore there's no need to enable the input buffer at this
5786 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005787 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005788 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005789 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005790 * mixer ctrl)
5791 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005792 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005793
Jonathan Woithef7ace402006-02-28 11:46:14 +01005794 /* Mute capture amp left and right */
5795 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005796 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005797 * in (on mic1 pin)
5798 */
5799 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005800
Jonathan Woithef7ace402006-02-28 11:46:14 +01005801 /* Do the same for the second ADC: mute capture input amp and
5802 * set ADC connection to line in (on mic1 pin)
5803 */
5804 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5805 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005806
Jonathan Woithef7ace402006-02-28 11:46:14 +01005807 /* Mute all inputs to mixer widget (even unconnected ones) */
5808 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5809 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5810 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5811 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5812 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5813 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5814 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5815 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005816
5817 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005818};
5819
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005820/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5821 * similar laptops (adapted from Fujitsu init verbs).
5822 */
5823static struct hda_verb alc260_acer_init_verbs[] = {
5824 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5825 * the headphone jack. Turn this on and rely on the standard mute
5826 * methods whenever the user wants to turn these outputs off.
5827 */
5828 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5829 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5830 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5831 /* Internal speaker/Headphone jack is connected to Line-out pin */
5832 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5833 /* Internal microphone/Mic jack is connected to Mic1 pin */
5834 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5835 /* Line In jack is connected to Line1 pin */
5836 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005837 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5838 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005839 /* Ensure all other unused pins are disabled and muted. */
5840 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5841 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005842 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5843 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5844 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5845 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5846 /* Disable digital (SPDIF) pins */
5847 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5848 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5849
Kailang Yangea1fb292008-08-26 12:58:38 +02005850 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005851 * bus when acting as outputs.
5852 */
5853 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5854 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5855
5856 /* Start with output sum widgets muted and their output gains at min */
5857 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5858 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5859 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5860 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5861 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5862 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5863 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5864 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5865 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5866
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005867 /* Unmute Line-out pin widget amp left and right
5868 * (no equiv mixer ctrl)
5869 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005870 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005871 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5872 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005873 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5874 * inputs. If the pin mode is changed by the user the pin mode control
5875 * will take care of enabling the pin's input/output buffers as needed.
5876 * Therefore there's no need to enable the input buffer at this
5877 * stage.
5878 */
5879 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5880 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5881
5882 /* Mute capture amp left and right */
5883 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5884 /* Set ADC connection select to match default mixer setting - mic
5885 * (on mic1 pin)
5886 */
5887 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5888
5889 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005890 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005891 */
5892 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005893 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005894
5895 /* Mute all inputs to mixer widget (even unconnected ones) */
5896 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5897 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5898 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5899 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5900 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5901 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5902 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5903 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5904
5905 { }
5906};
5907
Michael Schwingencc959482009-02-22 18:58:45 +01005908/* Initialisation sequence for Maxdata Favorit 100XS
5909 * (adapted from Acer init verbs).
5910 */
5911static struct hda_verb alc260_favorit100_init_verbs[] = {
5912 /* GPIO 0 enables the output jack.
5913 * Turn this on and rely on the standard mute
5914 * methods whenever the user wants to turn these outputs off.
5915 */
5916 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5917 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5918 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5919 /* Line/Mic input jack is connected to Mic1 pin */
5920 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5921 /* Ensure all other unused pins are disabled and muted. */
5922 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5923 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5924 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5925 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5926 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5927 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5928 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5929 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5930 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5931 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5932 /* Disable digital (SPDIF) pins */
5933 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5934 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5935
5936 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5937 * bus when acting as outputs.
5938 */
5939 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5940 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5941
5942 /* Start with output sum widgets muted and their output gains at min */
5943 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5944 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5945 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5946 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5947 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5948 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5949 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5950 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5951 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5952
5953 /* Unmute Line-out pin widget amp left and right
5954 * (no equiv mixer ctrl)
5955 */
5956 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5957 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5958 * inputs. If the pin mode is changed by the user the pin mode control
5959 * will take care of enabling the pin's input/output buffers as needed.
5960 * Therefore there's no need to enable the input buffer at this
5961 * stage.
5962 */
5963 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5964
5965 /* Mute capture amp left and right */
5966 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5967 /* Set ADC connection select to match default mixer setting - mic
5968 * (on mic1 pin)
5969 */
5970 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5971
5972 /* Do similar with the second ADC: mute capture input amp and
5973 * set ADC connection to mic to match ALSA's default state.
5974 */
5975 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5976 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5977
5978 /* Mute all inputs to mixer widget (even unconnected ones) */
5979 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5980 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5981 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5982 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5983 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5984 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5985 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5986 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5987
5988 { }
5989};
5990
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005991static struct hda_verb alc260_will_verbs[] = {
5992 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5993 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5994 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5995 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5996 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5997 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5998 {}
5999};
6000
6001static struct hda_verb alc260_replacer_672v_verbs[] = {
6002 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6003 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6004 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6005
6006 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6007 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6008 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6009
6010 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6011 {}
6012};
6013
6014/* toggle speaker-output according to the hp-jack state */
6015static void alc260_replacer_672v_automute(struct hda_codec *codec)
6016{
6017 unsigned int present;
6018
6019 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006020 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006021 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006022 snd_hda_codec_write_cache(codec, 0x01, 0,
6023 AC_VERB_SET_GPIO_DATA, 1);
6024 snd_hda_codec_write_cache(codec, 0x0f, 0,
6025 AC_VERB_SET_PIN_WIDGET_CONTROL,
6026 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006027 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006028 snd_hda_codec_write_cache(codec, 0x01, 0,
6029 AC_VERB_SET_GPIO_DATA, 0);
6030 snd_hda_codec_write_cache(codec, 0x0f, 0,
6031 AC_VERB_SET_PIN_WIDGET_CONTROL,
6032 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006033 }
6034}
6035
6036static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6037 unsigned int res)
6038{
6039 if ((res >> 26) == ALC880_HP_EVENT)
6040 alc260_replacer_672v_automute(codec);
6041}
6042
Kailang Yang3f878302008-08-26 13:02:23 +02006043static struct hda_verb alc260_hp_dc7600_verbs[] = {
6044 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6045 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6046 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6047 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6048 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6049 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6050 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6051 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6052 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6053 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6054 {}
6055};
6056
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006057/* Test configuration for debugging, modelled after the ALC880 test
6058 * configuration.
6059 */
6060#ifdef CONFIG_SND_DEBUG
6061static hda_nid_t alc260_test_dac_nids[1] = {
6062 0x02,
6063};
6064static hda_nid_t alc260_test_adc_nids[2] = {
6065 0x04, 0x05,
6066};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006067/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006068 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006069 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006070 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006071static struct hda_input_mux alc260_test_capture_sources[2] = {
6072 {
6073 .num_items = 7,
6074 .items = {
6075 { "MIC1 pin", 0x0 },
6076 { "MIC2 pin", 0x1 },
6077 { "LINE1 pin", 0x2 },
6078 { "LINE2 pin", 0x3 },
6079 { "CD pin", 0x4 },
6080 { "LINE-OUT pin", 0x5 },
6081 { "HP-OUT pin", 0x6 },
6082 },
6083 },
6084 {
6085 .num_items = 8,
6086 .items = {
6087 { "MIC1 pin", 0x0 },
6088 { "MIC2 pin", 0x1 },
6089 { "LINE1 pin", 0x2 },
6090 { "LINE2 pin", 0x3 },
6091 { "CD pin", 0x4 },
6092 { "Mixer", 0x5 },
6093 { "LINE-OUT pin", 0x6 },
6094 { "HP-OUT pin", 0x7 },
6095 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006096 },
6097};
6098static struct snd_kcontrol_new alc260_test_mixer[] = {
6099 /* Output driver widgets */
6100 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6101 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6102 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6103 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6104 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6105 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6106
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006107 /* Modes for retasking pin widgets
6108 * Note: the ALC260 doesn't seem to act on requests to enable mic
6109 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6110 * mention this restriction. At this stage it's not clear whether
6111 * this behaviour is intentional or is a hardware bug in chip
6112 * revisions available at least up until early 2006. Therefore for
6113 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6114 * choices, but if it turns out that the lack of mic bias for these
6115 * NIDs is intentional we could change their modes from
6116 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6117 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006118 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6119 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6120 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6121 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6122 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6123 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6124
6125 /* Loopback mixer controls */
6126 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6127 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6128 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6129 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6130 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6131 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6132 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6133 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6134 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6135 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006136 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6137 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6138 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6139 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006140
6141 /* Controls for GPIO pins, assuming they are configured as outputs */
6142 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6143 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6144 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6145 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6146
Jonathan Woithe92621f12006-02-28 11:47:47 +01006147 /* Switches to allow the digital IO pins to be enabled. The datasheet
6148 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006149 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006150 */
6151 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6152 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6153
Jonathan Woithef8225f62008-01-08 12:16:54 +01006154 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6155 * this output to turn on an external amplifier.
6156 */
6157 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6158 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6159
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006160 { } /* end */
6161};
6162static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006163 /* Enable all GPIOs as outputs with an initial value of 0 */
6164 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6165 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6166 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6167
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006168 /* Enable retasking pins as output, initially without power amp */
6169 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6170 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6171 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6172 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6173 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6174 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6175
Jonathan Woithe92621f12006-02-28 11:47:47 +01006176 /* Disable digital (SPDIF) pins initially, but users can enable
6177 * them via a mixer switch. In the case of SPDIF-out, this initverb
6178 * payload also sets the generation to 0, output to be in "consumer"
6179 * PCM format, copyright asserted, no pre-emphasis and no validity
6180 * control.
6181 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006182 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6183 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6184
Kailang Yangea1fb292008-08-26 12:58:38 +02006185 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006186 * OUT1 sum bus when acting as an output.
6187 */
6188 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6189 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6190 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6191 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6192
6193 /* Start with output sum widgets muted and their output gains at min */
6194 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6195 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6196 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6197 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6198 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6199 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6200 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6201 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6202 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6203
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006204 /* Unmute retasking pin widget output buffers since the default
6205 * state appears to be output. As the pin mode is changed by the
6206 * user the pin mode control will take care of enabling the pin's
6207 * input/output buffers as needed.
6208 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006209 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6210 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6211 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6212 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6213 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6214 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6215 /* Also unmute the mono-out pin widget */
6216 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6217
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006218 /* Mute capture amp left and right */
6219 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006220 /* Set ADC connection select to match default mixer setting (mic1
6221 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006222 */
6223 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6224
6225 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006226 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006227 */
6228 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6229 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6230
6231 /* Mute all inputs to mixer widget (even unconnected ones) */
6232 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6233 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6234 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6235 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6236 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6237 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6238 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6239 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6240
6241 { }
6242};
6243#endif
6244
Takashi Iwai63300792008-01-24 15:31:36 +01006245#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6246#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006247
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006248#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6249#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6250
Kailang Yangdf694da2005-12-05 19:42:22 +01006251/*
6252 * for BIOS auto-configuration
6253 */
6254
6255static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006256 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006257{
6258 hda_nid_t nid_vol;
6259 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006260 int err;
6261
6262 if (nid >= 0x0f && nid < 0x11) {
6263 nid_vol = nid - 0x7;
6264 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6265 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6266 } else if (nid == 0x11) {
6267 nid_vol = nid - 0x7;
6268 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6269 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6270 } else if (nid >= 0x12 && nid <= 0x15) {
6271 nid_vol = 0x08;
6272 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6273 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6274 } else
6275 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006276
Takashi Iwai863b4512008-10-21 17:01:47 +02006277 if (!(*vol_bits & (1 << nid_vol))) {
6278 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006279 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006280 if (err < 0)
6281 return err;
6282 *vol_bits |= (1 << nid_vol);
6283 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006284 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006285 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006286 return err;
6287 return 1;
6288}
6289
6290/* add playback controls from the parsed DAC table */
6291static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6292 const struct auto_pin_cfg *cfg)
6293{
6294 hda_nid_t nid;
6295 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006296 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006297
6298 spec->multiout.num_dacs = 1;
6299 spec->multiout.dac_nids = spec->private_dac_nids;
6300 spec->multiout.dac_nids[0] = 0x02;
6301
6302 nid = cfg->line_out_pins[0];
6303 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006304 const char *pfx;
6305 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6306 pfx = "Master";
6307 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6308 pfx = "Speaker";
6309 else
6310 pfx = "Front";
6311 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006312 if (err < 0)
6313 return err;
6314 }
6315
Takashi Iwai82bc9552006-03-21 11:24:42 +01006316 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006317 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006318 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006319 if (err < 0)
6320 return err;
6321 }
6322
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006323 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006324 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006325 err = alc260_add_playback_controls(spec, nid, "Headphone",
6326 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006327 if (err < 0)
6328 return err;
6329 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006330 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006331}
6332
6333/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006334static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006335 const struct auto_pin_cfg *cfg)
6336{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006337 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006338}
6339
6340static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6341 hda_nid_t nid, int pin_type,
6342 int sel_idx)
6343{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006344 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006345 /* need the manual connection? */
6346 if (nid >= 0x12) {
6347 int idx = nid - 0x12;
6348 snd_hda_codec_write(codec, idx + 0x0b, 0,
6349 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006350 }
6351}
6352
6353static void alc260_auto_init_multi_out(struct hda_codec *codec)
6354{
6355 struct alc_spec *spec = codec->spec;
6356 hda_nid_t nid;
6357
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006358 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006359 if (nid) {
6360 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6361 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6362 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006363
Takashi Iwai82bc9552006-03-21 11:24:42 +01006364 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006365 if (nid)
6366 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6367
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006368 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006369 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006370 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006371}
Kailang Yangdf694da2005-12-05 19:42:22 +01006372
6373#define ALC260_PIN_CD_NID 0x16
6374static void alc260_auto_init_analog_input(struct hda_codec *codec)
6375{
6376 struct alc_spec *spec = codec->spec;
6377 int i;
6378
6379 for (i = 0; i < AUTO_PIN_LAST; i++) {
6380 hda_nid_t nid = spec->autocfg.input_pins[i];
6381 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006382 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006383 if (nid != ALC260_PIN_CD_NID &&
6384 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006385 snd_hda_codec_write(codec, nid, 0,
6386 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006387 AMP_OUT_MUTE);
6388 }
6389 }
6390}
6391
6392/*
6393 * generic initialization of ADC, input mixers and output mixers
6394 */
6395static struct hda_verb alc260_volume_init_verbs[] = {
6396 /*
6397 * Unmute ADC0-1 and set the default input to mic-in
6398 */
6399 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6400 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6401 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6402 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006403
Kailang Yangdf694da2005-12-05 19:42:22 +01006404 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6405 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006406 * Note: PASD motherboards uses the Line In 2 as the input for
6407 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006408 */
6409 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006410 /* mute analog inputs */
6411 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6412 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6413 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6414 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6415 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006416
6417 /*
6418 * Set up output mixers (0x08 - 0x0a)
6419 */
6420 /* set vol=0 to output mixers */
6421 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6422 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6423 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6424 /* set up input amps for analog loopback */
6425 /* Amp Indices: DAC = 0, mixer = 1 */
6426 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6427 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6428 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6429 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6430 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6431 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006432
Kailang Yangdf694da2005-12-05 19:42:22 +01006433 { }
6434};
6435
6436static int alc260_parse_auto_config(struct hda_codec *codec)
6437{
6438 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006439 int err;
6440 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6441
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006442 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6443 alc260_ignore);
6444 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006445 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006446 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6447 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006448 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006449 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006450 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006451 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006452 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006453 return err;
6454
6455 spec->multiout.max_channels = 2;
6456
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006457 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006458 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006459 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006460 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006461
Takashi Iwaid88897e2008-10-31 15:01:37 +01006462 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006463
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006464 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006465 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006466
Kailang Yang6227cdc2010-02-25 08:36:52 +01006467 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006468
Kailang Yangdf694da2005-12-05 19:42:22 +01006469 return 1;
6470}
6471
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006472/* additional initialization for auto-configuration model */
6473static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006474{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006475 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006476 alc260_auto_init_multi_out(codec);
6477 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006478 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006479 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006480}
6481
Takashi Iwaicb53c622007-08-10 17:21:45 +02006482#ifdef CONFIG_SND_HDA_POWER_SAVE
6483static struct hda_amp_list alc260_loopbacks[] = {
6484 { 0x07, HDA_INPUT, 0 },
6485 { 0x07, HDA_INPUT, 1 },
6486 { 0x07, HDA_INPUT, 2 },
6487 { 0x07, HDA_INPUT, 3 },
6488 { 0x07, HDA_INPUT, 4 },
6489 { } /* end */
6490};
6491#endif
6492
Kailang Yangdf694da2005-12-05 19:42:22 +01006493/*
6494 * ALC260 configurations
6495 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006496static const char *alc260_models[ALC260_MODEL_LAST] = {
6497 [ALC260_BASIC] = "basic",
6498 [ALC260_HP] = "hp",
6499 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006500 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006501 [ALC260_FUJITSU_S702X] = "fujitsu",
6502 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006503 [ALC260_WILL] = "will",
6504 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006505 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006506#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006507 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006508#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006509 [ALC260_AUTO] = "auto",
6510};
6511
6512static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006513 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006514 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006515 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006516 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006517 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006518 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006519 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006520 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006521 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006522 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6523 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6524 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6525 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6526 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6527 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6528 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6529 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6530 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006531 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006532 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006533 {}
6534};
6535
Kailang Yangdf694da2005-12-05 19:42:22 +01006536static struct alc_config_preset alc260_presets[] = {
6537 [ALC260_BASIC] = {
6538 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006539 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006540 .init_verbs = { alc260_init_verbs },
6541 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6542 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006543 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01006544 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006545 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6546 .channel_mode = alc260_modes,
6547 .input_mux = &alc260_capture_source,
6548 },
6549 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006550 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006551 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006552 .init_verbs = { alc260_init_verbs,
6553 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006554 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6555 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006556 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6557 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006558 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6559 .channel_mode = alc260_modes,
6560 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006561 .unsol_event = alc260_hp_unsol_event,
6562 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006563 },
Kailang Yang3f878302008-08-26 13:02:23 +02006564 [ALC260_HP_DC7600] = {
6565 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006566 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006567 .init_verbs = { alc260_init_verbs,
6568 alc260_hp_dc7600_verbs },
6569 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6570 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006571 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6572 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006573 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6574 .channel_mode = alc260_modes,
6575 .input_mux = &alc260_capture_source,
6576 .unsol_event = alc260_hp_3012_unsol_event,
6577 .init_hook = alc260_hp_3012_automute,
6578 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006579 [ALC260_HP_3013] = {
6580 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006581 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006582 .init_verbs = { alc260_hp_3013_init_verbs,
6583 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006584 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6585 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006586 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6587 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006588 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6589 .channel_mode = alc260_modes,
6590 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006591 .unsol_event = alc260_hp_3013_unsol_event,
6592 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006593 },
6594 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006595 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006596 .init_verbs = { alc260_fujitsu_init_verbs },
6597 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6598 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006599 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6600 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006601 .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_fujitsu_capture_sources),
6604 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006605 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006606 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006607 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006608 .init_verbs = { alc260_acer_init_verbs },
6609 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6610 .dac_nids = alc260_dac_nids,
6611 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6612 .adc_nids = alc260_dual_adc_nids,
6613 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6614 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006615 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6616 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006617 },
Michael Schwingencc959482009-02-22 18:58:45 +01006618 [ALC260_FAVORIT100] = {
6619 .mixers = { alc260_favorit100_mixer },
6620 .init_verbs = { alc260_favorit100_init_verbs },
6621 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6622 .dac_nids = alc260_dac_nids,
6623 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6624 .adc_nids = alc260_dual_adc_nids,
6625 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6626 .channel_mode = alc260_modes,
6627 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6628 .input_mux = alc260_favorit100_capture_sources,
6629 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006630 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006631 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006632 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6633 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6634 .dac_nids = alc260_dac_nids,
6635 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6636 .adc_nids = alc260_adc_nids,
6637 .dig_out_nid = ALC260_DIGOUT_NID,
6638 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6639 .channel_mode = alc260_modes,
6640 .input_mux = &alc260_capture_source,
6641 },
6642 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006643 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006644 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6645 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6646 .dac_nids = alc260_dac_nids,
6647 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6648 .adc_nids = alc260_adc_nids,
6649 .dig_out_nid = ALC260_DIGOUT_NID,
6650 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6651 .channel_mode = alc260_modes,
6652 .input_mux = &alc260_capture_source,
6653 .unsol_event = alc260_replacer_672v_unsol_event,
6654 .init_hook = alc260_replacer_672v_automute,
6655 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006656#ifdef CONFIG_SND_DEBUG
6657 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006658 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006659 .init_verbs = { alc260_test_init_verbs },
6660 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6661 .dac_nids = alc260_test_dac_nids,
6662 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6663 .adc_nids = alc260_test_adc_nids,
6664 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6665 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006666 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6667 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006668 },
6669#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006670};
6671
Linus Torvalds1da177e2005-04-16 15:20:36 -07006672static int patch_alc260(struct hda_codec *codec)
6673{
6674 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006675 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006676
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006677 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006678 if (spec == NULL)
6679 return -ENOMEM;
6680
6681 codec->spec = spec;
6682
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006683 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6684 alc260_models,
6685 alc260_cfg_tbl);
6686 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006687 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006688 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006689 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006690 }
6691
Kailang Yangdf694da2005-12-05 19:42:22 +01006692 if (board_config == ALC260_AUTO) {
6693 /* automatic parse from the BIOS config */
6694 err = alc260_parse_auto_config(codec);
6695 if (err < 0) {
6696 alc_free(codec);
6697 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006698 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006699 printk(KERN_INFO
6700 "hda_codec: Cannot set up configuration "
6701 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006702 board_config = ALC260_BASIC;
6703 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006704 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006705
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006706 err = snd_hda_attach_beep_device(codec, 0x1);
6707 if (err < 0) {
6708 alc_free(codec);
6709 return err;
6710 }
6711
Kailang Yangdf694da2005-12-05 19:42:22 +01006712 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006713 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006714
Linus Torvalds1da177e2005-04-16 15:20:36 -07006715 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6716 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6717
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006718 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6719 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6720
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006721 if (!spec->adc_nids && spec->input_mux) {
6722 /* check whether NID 0x04 is valid */
6723 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006724 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006725 /* get type */
6726 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6727 spec->adc_nids = alc260_adc_nids_alt;
6728 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6729 } else {
6730 spec->adc_nids = alc260_adc_nids;
6731 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6732 }
6733 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006734 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006735 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006736
Takashi Iwai2134ea42008-01-10 16:53:55 +01006737 spec->vmaster_nid = 0x08;
6738
Linus Torvalds1da177e2005-04-16 15:20:36 -07006739 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006740 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006741 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006742#ifdef CONFIG_SND_HDA_POWER_SAVE
6743 if (!spec->loopback.amplist)
6744 spec->loopback.amplist = alc260_loopbacks;
6745#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006746
6747 return 0;
6748}
6749
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006750
Linus Torvalds1da177e2005-04-16 15:20:36 -07006751/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006752 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006753 *
6754 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6755 * configuration. Each pin widget can choose any input DACs and a mixer.
6756 * Each ADC is connected from a mixer of all inputs. This makes possible
6757 * 6-channel independent captures.
6758 *
6759 * In addition, an independent DAC for the multi-playback (not used in this
6760 * driver yet).
6761 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006762#define ALC882_DIGOUT_NID 0x06
6763#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006764#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6765#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6766#define ALC1200_DIGOUT_NID 0x10
6767
Linus Torvalds1da177e2005-04-16 15:20:36 -07006768
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006769static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006770 { 8, NULL }
6771};
6772
Takashi Iwai4953550a2009-06-30 15:28:30 +02006773/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006774static hda_nid_t alc882_dac_nids[4] = {
6775 /* front, rear, clfe, rear_surr */
6776 0x02, 0x03, 0x04, 0x05
6777};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006778#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006779
Takashi Iwai4953550a2009-06-30 15:28:30 +02006780/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006781#define alc882_adc_nids alc880_adc_nids
6782#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006783#define alc883_adc_nids alc882_adc_nids_alt
6784static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6785static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6786#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006787
Takashi Iwaie1406342008-02-11 18:32:32 +01006788static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6789static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006790#define alc883_capsrc_nids alc882_capsrc_nids_alt
6791static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6792#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006793
Linus Torvalds1da177e2005-04-16 15:20:36 -07006794/* input MUX */
6795/* FIXME: should be a matrix-type input source selection */
6796
6797static struct hda_input_mux alc882_capture_source = {
6798 .num_items = 4,
6799 .items = {
6800 { "Mic", 0x0 },
6801 { "Front Mic", 0x1 },
6802 { "Line", 0x2 },
6803 { "CD", 0x4 },
6804 },
6805};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006806
Takashi Iwai4953550a2009-06-30 15:28:30 +02006807#define alc883_capture_source alc882_capture_source
6808
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006809static struct hda_input_mux alc889_capture_source = {
6810 .num_items = 3,
6811 .items = {
6812 { "Front Mic", 0x0 },
6813 { "Mic", 0x3 },
6814 { "Line", 0x2 },
6815 },
6816};
6817
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006818static struct hda_input_mux mb5_capture_source = {
6819 .num_items = 3,
6820 .items = {
6821 { "Mic", 0x1 },
6822 { "Line", 0x2 },
6823 { "CD", 0x4 },
6824 },
6825};
6826
Luke Yelaviche458b1f2010-02-12 16:28:29 +11006827static struct hda_input_mux macmini3_capture_source = {
6828 .num_items = 2,
6829 .items = {
6830 { "Line", 0x2 },
6831 { "CD", 0x4 },
6832 },
6833};
6834
Takashi Iwai4953550a2009-06-30 15:28:30 +02006835static struct hda_input_mux alc883_3stack_6ch_intel = {
6836 .num_items = 4,
6837 .items = {
6838 { "Mic", 0x1 },
6839 { "Front Mic", 0x0 },
6840 { "Line", 0x2 },
6841 { "CD", 0x4 },
6842 },
6843};
6844
6845static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6846 .num_items = 2,
6847 .items = {
6848 { "Mic", 0x1 },
6849 { "Line", 0x2 },
6850 },
6851};
6852
6853static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6854 .num_items = 4,
6855 .items = {
6856 { "Mic", 0x0 },
6857 { "iMic", 0x1 },
6858 { "Line", 0x2 },
6859 { "CD", 0x4 },
6860 },
6861};
6862
6863static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6864 .num_items = 2,
6865 .items = {
6866 { "Mic", 0x0 },
6867 { "Int Mic", 0x1 },
6868 },
6869};
6870
6871static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6872 .num_items = 3,
6873 .items = {
6874 { "Mic", 0x0 },
6875 { "Front Mic", 0x1 },
6876 { "Line", 0x4 },
6877 },
6878};
6879
6880static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6881 .num_items = 2,
6882 .items = {
6883 { "Mic", 0x0 },
6884 { "Line", 0x2 },
6885 },
6886};
6887
6888static struct hda_input_mux alc889A_mb31_capture_source = {
6889 .num_items = 2,
6890 .items = {
6891 { "Mic", 0x0 },
6892 /* Front Mic (0x01) unused */
6893 { "Line", 0x2 },
6894 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02006895 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006896 },
6897};
6898
6899/*
6900 * 2ch mode
6901 */
6902static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6903 { 2, NULL }
6904};
6905
Kailang Yangdf694da2005-12-05 19:42:22 +01006906/*
Kailang Yang272a5272007-05-14 11:00:38 +02006907 * 2ch mode
6908 */
6909static struct hda_verb alc882_3ST_ch2_init[] = {
6910 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6911 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6912 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6913 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6914 { } /* end */
6915};
6916
6917/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006918 * 4ch mode
6919 */
6920static struct hda_verb alc882_3ST_ch4_init[] = {
6921 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6922 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6923 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6924 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6925 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6926 { } /* end */
6927};
6928
6929/*
Kailang Yang272a5272007-05-14 11:00:38 +02006930 * 6ch mode
6931 */
6932static struct hda_verb alc882_3ST_ch6_init[] = {
6933 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6934 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6935 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6936 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6937 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6938 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6939 { } /* end */
6940};
6941
Takashi Iwai4953550a2009-06-30 15:28:30 +02006942static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006943 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006944 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006945 { 6, alc882_3ST_ch6_init },
6946};
6947
Takashi Iwai4953550a2009-06-30 15:28:30 +02006948#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6949
Kailang Yang272a5272007-05-14 11:00:38 +02006950/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306951 * 2ch mode
6952 */
6953static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6954 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6955 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6956 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6957 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6958 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6959 { } /* end */
6960};
6961
6962/*
6963 * 4ch mode
6964 */
6965static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6966 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6967 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6968 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6969 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6970 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6971 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6972 { } /* end */
6973};
6974
6975/*
6976 * 6ch mode
6977 */
6978static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6979 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6980 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6981 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6982 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6983 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6984 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6985 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6986 { } /* end */
6987};
6988
6989static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6990 { 2, alc883_3ST_ch2_clevo_init },
6991 { 4, alc883_3ST_ch4_clevo_init },
6992 { 6, alc883_3ST_ch6_clevo_init },
6993};
6994
6995
6996/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006997 * 6ch mode
6998 */
6999static struct hda_verb alc882_sixstack_ch6_init[] = {
7000 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7001 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7002 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7003 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7004 { } /* end */
7005};
7006
7007/*
7008 * 8ch mode
7009 */
7010static struct hda_verb alc882_sixstack_ch8_init[] = {
7011 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7012 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7013 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7014 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7015 { } /* end */
7016};
7017
7018static struct hda_channel_mode alc882_sixstack_modes[2] = {
7019 { 6, alc882_sixstack_ch6_init },
7020 { 8, alc882_sixstack_ch8_init },
7021};
7022
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007023
7024/* Macbook Air 2,1 */
7025
7026static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7027 { 2, NULL },
7028};
7029
Takashi Iwai87350ad2007-08-16 18:19:38 +02007030/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007031 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007032 */
7033
7034/*
7035 * 2ch mode
7036 */
7037static struct hda_verb alc885_mbp_ch2_init[] = {
7038 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7039 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7040 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7041 { } /* end */
7042};
7043
7044/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007045 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007046 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007047static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007048 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7049 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7050 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7051 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7052 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7053 { } /* end */
7054};
7055
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007056static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007057 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007058 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007059};
7060
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007061/*
7062 * 2ch
7063 * Speakers/Woofer/HP = Front
7064 * LineIn = Input
7065 */
7066static struct hda_verb alc885_mb5_ch2_init[] = {
7067 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7068 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7069 { } /* end */
7070};
7071
7072/*
7073 * 6ch mode
7074 * Speakers/HP = Front
7075 * Woofer = LFE
7076 * LineIn = Surround
7077 */
7078static struct hda_verb alc885_mb5_ch6_init[] = {
7079 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7080 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7081 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7082 { } /* end */
7083};
7084
7085static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7086 { 2, alc885_mb5_ch2_init },
7087 { 6, alc885_mb5_ch6_init },
7088};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007089
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007090#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007091
7092/*
7093 * 2ch mode
7094 */
7095static struct hda_verb alc883_4ST_ch2_init[] = {
7096 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7097 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7098 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7099 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7100 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7101 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7102 { } /* end */
7103};
7104
7105/*
7106 * 4ch mode
7107 */
7108static struct hda_verb alc883_4ST_ch4_init[] = {
7109 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7110 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7111 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7112 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7113 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7114 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7115 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7116 { } /* end */
7117};
7118
7119/*
7120 * 6ch mode
7121 */
7122static struct hda_verb alc883_4ST_ch6_init[] = {
7123 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7124 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7125 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7126 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7127 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7128 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7129 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7130 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7131 { } /* end */
7132};
7133
7134/*
7135 * 8ch mode
7136 */
7137static struct hda_verb alc883_4ST_ch8_init[] = {
7138 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7139 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7140 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7141 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7142 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7143 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7144 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7145 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7146 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7147 { } /* end */
7148};
7149
7150static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7151 { 2, alc883_4ST_ch2_init },
7152 { 4, alc883_4ST_ch4_init },
7153 { 6, alc883_4ST_ch6_init },
7154 { 8, alc883_4ST_ch8_init },
7155};
7156
7157
7158/*
7159 * 2ch mode
7160 */
7161static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7162 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7163 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7164 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7165 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7166 { } /* end */
7167};
7168
7169/*
7170 * 4ch mode
7171 */
7172static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7173 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7174 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7175 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7176 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7177 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7178 { } /* end */
7179};
7180
7181/*
7182 * 6ch mode
7183 */
7184static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7185 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7186 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7187 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7188 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7189 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7190 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7191 { } /* end */
7192};
7193
7194static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7195 { 2, alc883_3ST_ch2_intel_init },
7196 { 4, alc883_3ST_ch4_intel_init },
7197 { 6, alc883_3ST_ch6_intel_init },
7198};
7199
7200/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007201 * 2ch mode
7202 */
7203static struct hda_verb alc889_ch2_intel_init[] = {
7204 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7205 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7206 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7207 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7208 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7209 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7210 { } /* end */
7211};
7212
7213/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007214 * 6ch mode
7215 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007216static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007217 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7218 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7219 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7220 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7221 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007222 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7223 { } /* end */
7224};
7225
7226/*
7227 * 8ch mode
7228 */
7229static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007230 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7231 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7232 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7233 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7234 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007235 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7236 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007237 { } /* end */
7238};
7239
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007240static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7241 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007242 { 6, alc889_ch6_intel_init },
7243 { 8, alc889_ch8_intel_init },
7244};
7245
7246/*
7247 * 6ch mode
7248 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007249static struct hda_verb alc883_sixstack_ch6_init[] = {
7250 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7251 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7252 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7253 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7254 { } /* end */
7255};
7256
7257/*
7258 * 8ch mode
7259 */
7260static struct hda_verb alc883_sixstack_ch8_init[] = {
7261 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7262 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7263 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7264 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7265 { } /* end */
7266};
7267
7268static struct hda_channel_mode alc883_sixstack_modes[2] = {
7269 { 6, alc883_sixstack_ch6_init },
7270 { 8, alc883_sixstack_ch8_init },
7271};
7272
7273
Linus Torvalds1da177e2005-04-16 15:20:36 -07007274/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7275 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7276 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007277static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007278 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007279 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007280 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007281 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007282 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7283 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007284 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7285 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007286 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007287 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007288 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7289 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7290 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7291 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7292 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7293 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007294 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007295 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7296 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007297 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007298 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007299 { } /* end */
7300};
7301
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007302/* Macbook Air 2,1 same control for HP and internal Speaker */
7303
7304static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7305 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7306 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7307 { }
7308};
7309
7310
Takashi Iwai87350ad2007-08-16 18:19:38 +02007311static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007312 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7313 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7314 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7315 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7316 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007317 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7318 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007319 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7320 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007321 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007322 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7323 { } /* end */
7324};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007325
7326static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007327 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7328 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7329 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7330 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7331 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7332 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307333 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7334 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007335 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7336 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7337 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7338 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7339 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7340 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7341 { } /* end */
7342};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007343
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007344static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7345 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7346 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7347 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7348 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7349 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7350 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7351 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7352 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7353 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7354 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7355 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7356 { } /* end */
7357};
7358
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007359static struct snd_kcontrol_new alc885_imac91_mixer[] = {
7360 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7361 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
7362 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
7363 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7364 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7365 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7367 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7368 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7369 { } /* end */
7370};
7371
7372
Kailang Yangbdd148a2007-05-08 15:19:08 +02007373static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7374 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7375 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7376 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7377 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7378 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7379 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7380 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7381 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7382 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007383 { } /* end */
7384};
7385
Kailang Yang272a5272007-05-14 11:00:38 +02007386static struct snd_kcontrol_new alc882_targa_mixer[] = {
7387 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7388 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7389 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7390 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7391 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7392 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7393 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7394 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7395 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007396 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007397 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7398 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007399 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007400 { } /* end */
7401};
7402
7403/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7404 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7405 */
7406static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7407 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7408 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7409 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7410 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7411 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7412 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7413 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7414 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7415 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7416 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7417 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7418 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007419 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007420 { } /* end */
7421};
7422
Takashi Iwai914759b2007-09-06 14:52:04 +02007423static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7424 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7425 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7426 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7427 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7428 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7429 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7430 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7431 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7432 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7433 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007434 { } /* end */
7435};
7436
Kailang Yangdf694da2005-12-05 19:42:22 +01007437static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7438 {
7439 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7440 .name = "Channel Mode",
7441 .info = alc_ch_mode_info,
7442 .get = alc_ch_mode_get,
7443 .put = alc_ch_mode_put,
7444 },
7445 { } /* end */
7446};
7447
Takashi Iwai4953550a2009-06-30 15:28:30 +02007448static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007449 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007450 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7451 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007452 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007453 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7454 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007455 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007456 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7457 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007458 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007459 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7460 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007461
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007462 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007463 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007464 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007465 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007466 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007467 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007468 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007469 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007470 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007471 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007472 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007473 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007474 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007475 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007476 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007477 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007478 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007479 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007480 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7481 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007482 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007483 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7484 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007485 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007486 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7487 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7488 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7489 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7490 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007491 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007492 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007493
7494 /* FIXME: use matrix-type input source selection */
7495 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007496 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007497 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007498 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007499 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007500 /* ADC2: mute amp left and right */
7501 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007502 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007503 /* ADC3: mute amp left and right */
7504 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007505 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007506
7507 { }
7508};
7509
Takashi Iwai4953550a2009-06-30 15:28:30 +02007510static struct hda_verb alc882_adc1_init_verbs[] = {
7511 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7512 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7513 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7514 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7515 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7516 /* ADC1: mute amp left and right */
7517 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7518 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7519 { }
7520};
7521
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007522static struct hda_verb alc882_eapd_verbs[] = {
7523 /* change to EAPD mode */
7524 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007525 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007526 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007527};
7528
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007529static struct hda_verb alc889_eapd_verbs[] = {
7530 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7531 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7532 { }
7533};
7534
Wu Fengguang6732bd02009-07-30 09:19:14 +02007535static struct hda_verb alc_hp15_unsol_verbs[] = {
7536 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7537 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7538 {}
7539};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007540
7541static struct hda_verb alc885_init_verbs[] = {
7542 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01007543 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7544 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007545 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007546 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7547 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007548 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007549 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7550 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007551 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007552 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7553 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007554
7555 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007556 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007557 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7558 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7559 /* Front Pin: output 0 (0x0c) */
7560 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7561 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7562 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7563 /* Rear Pin: output 1 (0x0d) */
7564 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7565 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7566 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7567 /* CLFE Pin: output 2 (0x0e) */
7568 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7569 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7570 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7571 /* Side Pin: output 3 (0x0f) */
7572 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7573 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7574 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7575 /* Mic (rear) pin: input vref at 80% */
7576 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7577 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7578 /* Front Mic pin: input vref at 80% */
7579 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7580 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7581 /* Line In pin: input */
7582 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7583 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7584
7585 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7586 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01007587 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007588 /* Input mixer2 */
7589 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007590 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01007591 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007592 /* ADC2: mute amp left and right */
7593 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7594 /* ADC3: mute amp left and right */
7595 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7596
7597 { }
7598};
7599
7600static struct hda_verb alc885_init_input_verbs[] = {
7601 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7602 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7603 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7604 { }
7605};
7606
7607
7608/* Unmute Selector 24h and set the default input to front mic */
7609static struct hda_verb alc889_init_input_verbs[] = {
7610 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7611 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7612 { }
7613};
7614
7615
Takashi Iwai4953550a2009-06-30 15:28:30 +02007616#define alc883_init_verbs alc882_base_init_verbs
7617
Tobin Davis9102cd12006-12-15 10:02:12 +01007618/* Mac Pro test */
7619static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7620 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7621 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7622 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7623 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7624 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007625 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007626 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7627 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007628 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007629 { } /* end */
7630};
7631
7632static struct hda_verb alc882_macpro_init_verbs[] = {
7633 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7634 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7635 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7636 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7637 /* Front Pin: output 0 (0x0c) */
7638 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7639 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7640 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7641 /* Front Mic pin: input vref at 80% */
7642 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7643 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7644 /* Speaker: output */
7645 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7646 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7647 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7648 /* Headphone output (output 0 - 0x0c) */
7649 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7650 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7651 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7652
7653 /* FIXME: use matrix-type input source selection */
7654 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7655 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7656 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7657 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7658 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7659 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7660 /* Input mixer2 */
7661 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7662 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7663 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7664 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7665 /* Input mixer3 */
7666 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7667 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7668 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7669 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7670 /* ADC1: mute amp left and right */
7671 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7672 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7673 /* ADC2: mute amp left and right */
7674 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7675 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7676 /* ADC3: mute amp left and right */
7677 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7678 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7679
7680 { }
7681};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007682
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007683/* Macbook 5,1 */
7684static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007685 /* DACs */
7686 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7687 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7688 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7689 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007690 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007691 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7692 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7693 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007694 /* Surround mixer */
7695 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7696 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7697 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7698 /* LFE mixer */
7699 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7700 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7701 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7702 /* HP mixer */
7703 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7704 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7705 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7706 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007707 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7708 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007709 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7710 /* LFE Pin (0x0e) */
7711 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7712 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7713 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7714 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007715 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7716 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007717 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10307718 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007719 /* Front Mic pin: input vref at 80% */
7720 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7721 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7722 /* Line In pin */
7723 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7724 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7725
7726 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7727 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7728 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7729 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7730 { }
7731};
7732
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007733/* Macmini 3,1 */
7734static struct hda_verb alc885_macmini3_init_verbs[] = {
7735 /* DACs */
7736 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7737 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7738 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7739 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7740 /* Front mixer */
7741 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7742 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7743 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7744 /* Surround mixer */
7745 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7746 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7747 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7748 /* LFE mixer */
7749 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7750 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7751 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7752 /* HP mixer */
7753 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7754 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7755 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7756 /* Front Pin (0x0c) */
7757 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7758 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7759 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7760 /* LFE Pin (0x0e) */
7761 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7762 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7763 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7764 /* HP Pin (0x0f) */
7765 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7766 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7767 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
7768 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7769 /* Line In pin */
7770 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7771 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7772
7773 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7774 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7775 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7776 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7777 { }
7778};
7779
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007780
7781static struct hda_verb alc885_mba21_init_verbs[] = {
7782 /*Internal and HP Speaker Mixer*/
7783 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7784 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7785 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7786 /*Internal Speaker Pin (0x0c)*/
7787 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
7788 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7789 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7790 /* HP Pin: output 0 (0x0e) */
7791 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7792 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7793 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7794 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
7795 /* Line in (is hp when jack connected)*/
7796 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
7797 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7798
7799 { }
7800 };
7801
7802
Takashi Iwai87350ad2007-08-16 18:19:38 +02007803/* Macbook Pro rev3 */
7804static struct hda_verb alc885_mbp3_init_verbs[] = {
7805 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7806 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7808 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7809 /* Rear mixer */
7810 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7811 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7812 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007813 /* HP mixer */
7814 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7815 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7816 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007817 /* Front Pin: output 0 (0x0c) */
7818 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7819 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7820 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007821 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007822 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007823 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7824 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007825 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7826 /* Mic (rear) pin: input vref at 80% */
7827 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7828 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7829 /* Front Mic pin: input vref at 80% */
7830 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7831 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7832 /* Line In pin: use output 1 when in LineOut mode */
7833 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7834 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7835 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7836
7837 /* FIXME: use matrix-type input source selection */
7838 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7839 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7840 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7841 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7842 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7843 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7844 /* Input mixer2 */
7845 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7846 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7847 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7848 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7849 /* Input mixer3 */
7850 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7851 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7852 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7853 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7854 /* ADC1: mute amp left and right */
7855 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7856 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7857 /* ADC2: mute amp left and right */
7858 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7859 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7860 /* ADC3: mute amp left and right */
7861 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7862 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7863
7864 { }
7865};
7866
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007867/* iMac 9,1 */
7868static struct hda_verb alc885_imac91_init_verbs[] = {
7869 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
7870 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7871 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7872 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7873 /* Rear mixer */
7874 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7875 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7876 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7877 /* HP Pin: output 0 (0x0c) */
7878 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7879 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7880 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7881 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7882 /* Internal Speakers: output 0 (0x0d) */
7883 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7884 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7885 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7886 /* Mic (rear) pin: input vref at 80% */
7887 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7888 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7889 /* Front Mic pin: input vref at 80% */
7890 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7891 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7892 /* Line In pin: use output 1 when in LineOut mode */
7893 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7894 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7895 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7896
7897 /* FIXME: use matrix-type input source selection */
7898 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7899 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7900 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7901 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7902 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7903 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7904 /* Input mixer2 */
7905 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7906 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7907 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7908 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7909 /* Input mixer3 */
7910 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7911 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7912 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7913 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7914 /* ADC1: mute amp left and right */
7915 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7916 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7917 /* ADC2: mute amp left and right */
7918 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7919 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7920 /* ADC3: mute amp left and right */
7921 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7922 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7923
7924 { }
7925};
7926
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007927/* iMac 24 mixer. */
7928static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7929 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7930 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7931 { } /* end */
7932};
7933
7934/* iMac 24 init verbs. */
7935static struct hda_verb alc885_imac24_init_verbs[] = {
7936 /* Internal speakers: output 0 (0x0c) */
7937 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7938 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7939 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7940 /* Internal speakers: output 0 (0x0c) */
7941 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7942 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7943 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7944 /* Headphone: output 0 (0x0c) */
7945 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7946 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7947 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7948 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7949 /* Front Mic: input vref at 80% */
7950 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7951 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7952 { }
7953};
7954
7955/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007956static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007957{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007958 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007959
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007960 spec->autocfg.hp_pins[0] = 0x14;
7961 spec->autocfg.speaker_pins[0] = 0x18;
7962 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007963}
7964
Takashi Iwai9d54f082010-02-22 08:34:40 +01007965#define alc885_mb5_setup alc885_imac24_setup
7966#define alc885_macmini3_setup alc885_imac24_setup
7967
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007968/* Macbook Air 2,1 */
7969static void alc885_mba21_setup(struct hda_codec *codec)
7970{
7971 struct alc_spec *spec = codec->spec;
7972
7973 spec->autocfg.hp_pins[0] = 0x14;
7974 spec->autocfg.speaker_pins[0] = 0x18;
7975}
7976
7977
7978
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007979static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007980{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007981 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007982
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007983 spec->autocfg.hp_pins[0] = 0x15;
7984 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007985}
7986
Takashi Iwai9d54f082010-02-22 08:34:40 +01007987static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10307988{
Takashi Iwai9d54f082010-02-22 08:34:40 +01007989 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10307990
Takashi Iwai9d54f082010-02-22 08:34:40 +01007991 spec->autocfg.hp_pins[0] = 0x14;
7992 spec->autocfg.speaker_pins[0] = 0x15;
7993 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007994}
Takashi Iwai87350ad2007-08-16 18:19:38 +02007995
Kailang Yang272a5272007-05-14 11:00:38 +02007996static struct hda_verb alc882_targa_verbs[] = {
7997 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7998 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7999
8000 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8001 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008002
Kailang Yang272a5272007-05-14 11:00:38 +02008003 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8004 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8005 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8006
8007 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008008 { } /* end */
8009};
8010
8011/* toggle speaker-output according to the hp-jack state */
8012static void alc882_targa_automute(struct hda_codec *codec)
8013{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008014 struct alc_spec *spec = codec->spec;
8015 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008016 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008017 spec->jack_present ? 1 : 3);
8018}
8019
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008020static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008021{
8022 struct alc_spec *spec = codec->spec;
8023
8024 spec->autocfg.hp_pins[0] = 0x14;
8025 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008026}
8027
8028static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8029{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008030 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008031 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008032}
8033
8034static struct hda_verb alc882_asus_a7j_verbs[] = {
8035 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8036 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8037
8038 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8039 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8040 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008041
Kailang Yang272a5272007-05-14 11:00:38 +02008042 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8043 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8044 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8045
8046 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8047 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8048 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8049 { } /* end */
8050};
8051
Takashi Iwai914759b2007-09-06 14:52:04 +02008052static struct hda_verb alc882_asus_a7m_verbs[] = {
8053 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8055
8056 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8057 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8058 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008059
Takashi Iwai914759b2007-09-06 14:52:04 +02008060 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8061 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8062 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8063
8064 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8065 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8066 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8067 { } /* end */
8068};
8069
Tobin Davis9102cd12006-12-15 10:02:12 +01008070static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8071{
8072 unsigned int gpiostate, gpiomask, gpiodir;
8073
8074 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8075 AC_VERB_GET_GPIO_DATA, 0);
8076
8077 if (!muted)
8078 gpiostate |= (1 << pin);
8079 else
8080 gpiostate &= ~(1 << pin);
8081
8082 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8083 AC_VERB_GET_GPIO_MASK, 0);
8084 gpiomask |= (1 << pin);
8085
8086 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8087 AC_VERB_GET_GPIO_DIRECTION, 0);
8088 gpiodir |= (1 << pin);
8089
8090
8091 snd_hda_codec_write(codec, codec->afg, 0,
8092 AC_VERB_SET_GPIO_MASK, gpiomask);
8093 snd_hda_codec_write(codec, codec->afg, 0,
8094 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8095
8096 msleep(1);
8097
8098 snd_hda_codec_write(codec, codec->afg, 0,
8099 AC_VERB_SET_GPIO_DATA, gpiostate);
8100}
8101
Takashi Iwai7debbe52007-08-16 15:01:03 +02008102/* set up GPIO at initialization */
8103static void alc885_macpro_init_hook(struct hda_codec *codec)
8104{
8105 alc882_gpio_mute(codec, 0, 0);
8106 alc882_gpio_mute(codec, 1, 0);
8107}
8108
8109/* set up GPIO and update auto-muting at initialization */
8110static void alc885_imac24_init_hook(struct hda_codec *codec)
8111{
8112 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008113 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008114}
8115
Kailang Yangdf694da2005-12-05 19:42:22 +01008116/*
8117 * generic initialization of ADC, input mixers and output mixers
8118 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008119static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008120 /*
8121 * Unmute ADC0-2 and set the default input to mic-in
8122 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008123 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8124 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8125 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8126 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8127
Kailang Yangdf694da2005-12-05 19:42:22 +01008128 /*
8129 * Set up output mixers (0x0c - 0x0f)
8130 */
8131 /* set vol=0 to output mixers */
8132 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8133 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8134 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8135 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8136 /* set up input amps for analog loopback */
8137 /* Amp Indices: DAC = 0, mixer = 1 */
8138 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8139 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8140 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8141 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8142 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8143 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8144 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8145 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8146 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8147 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8148
8149 /* FIXME: use matrix-type input source selection */
8150 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008151 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008152 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008153 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008154 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008155 { }
8156};
8157
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008158/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8159static struct hda_verb alc889A_mb31_ch2_init[] = {
8160 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8161 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8162 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8163 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8164 { } /* end */
8165};
8166
8167/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8168static struct hda_verb alc889A_mb31_ch4_init[] = {
8169 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8170 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8171 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8172 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8173 { } /* end */
8174};
8175
8176/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8177static struct hda_verb alc889A_mb31_ch5_init[] = {
8178 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8179 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8180 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8181 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8182 { } /* end */
8183};
8184
8185/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8186static struct hda_verb alc889A_mb31_ch6_init[] = {
8187 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8188 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8189 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8190 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8191 { } /* end */
8192};
8193
8194static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8195 { 2, alc889A_mb31_ch2_init },
8196 { 4, alc889A_mb31_ch4_init },
8197 { 5, alc889A_mb31_ch5_init },
8198 { 6, alc889A_mb31_ch6_init },
8199};
8200
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008201static struct hda_verb alc883_medion_eapd_verbs[] = {
8202 /* eanable EAPD on medion laptop */
8203 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8204 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8205 { }
8206};
8207
Takashi Iwai4953550a2009-06-30 15:28:30 +02008208#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008209
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008210static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8211 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8212 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8213 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8214 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8215 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8216 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8217 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8218 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8219 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8220 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8221 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8222 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8223 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008224 { } /* end */
8225};
8226
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008227static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008228 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8229 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8230 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8231 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8232 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8233 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8234 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8235 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8236 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8237 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008238 { } /* end */
8239};
8240
Jiang zhefb97dc62008-03-06 11:07:11 +01008241static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8242 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8243 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8244 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8245 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8246 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8247 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8248 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8249 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8250 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8251 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008252 { } /* end */
8253};
8254
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008255static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8256 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8257 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8258 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8259 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8260 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8261 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8262 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8263 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008264 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008265 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8266 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008267 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008268 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008269 { } /* end */
8270};
8271
8272static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8273 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8274 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8275 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8276 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8277 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8278 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8279 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8280 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8281 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8282 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8283 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8284 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8285 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8286 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008287 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008288 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8289 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008290 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008291 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008292 { } /* end */
8293};
8294
Jiang zhe17bba1b2008-06-04 12:11:07 +02008295static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8296 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8297 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8298 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8299 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8300 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8301 HDA_OUTPUT),
8302 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8303 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8304 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8305 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8306 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8307 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8308 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8309 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8310 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8311 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8312 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8313 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8314 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8315 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008316 { } /* end */
8317};
8318
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008319static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8320 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8321 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8322 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8323 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8324 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8325 HDA_OUTPUT),
8326 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8327 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8328 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8329 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8330 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8331 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8332 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8333 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8335 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8336 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8337 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8338 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8339 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8340 { } /* end */
8341};
8342
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008343static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008344 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008345 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008346 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008347 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008348 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8349 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008350 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8351 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008352 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8353 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8354 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8355 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8356 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8357 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008358 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008359 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8360 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008361 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008362 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008363 { } /* end */
8364};
8365
Sasha Alexandrc2592492009-06-16 14:52:54 -04008366static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008367 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008368 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008369 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008370 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008371 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8372 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8373 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8374 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8375 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8376 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8377 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8378 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8379 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8380 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8381 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008382 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008383 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008384 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008385};
Kailang Yangccc656c2006-10-17 12:32:26 +02008386
Sasha Alexandrc2592492009-06-16 14:52:54 -04008387static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008388 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008389 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008390 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008391 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008392 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8393 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8394 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008395 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008396 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008397 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8398 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8399 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008400 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008401};
Kailang Yangccc656c2006-10-17 12:32:26 +02008402
Takashi Iwaib99dba32009-09-17 18:23:00 +02008403static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8404 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8405 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8406 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8407 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8408 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8409 { } /* end */
8410};
8411
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008412static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8413 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8414 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008415 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8416 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008417 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8418 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8419 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8420 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008421 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008422};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008423
Kailang Yang272a5272007-05-14 11:00:38 +02008424static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8425 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8426 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8427 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8428 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8429 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8430 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8431 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8432 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8433 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008434 { } /* end */
8435};
8436
8437static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8438 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8439 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8440 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8441 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8442 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8443 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8444 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8445 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8446 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008447 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008448};
Kailang Yang272a5272007-05-14 11:00:38 +02008449
Tobin Davis2880a862007-08-07 11:50:26 +02008450static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008451 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8452 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008453 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008454 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8455 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008456 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8457 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8458 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008459 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008460};
Tobin Davis2880a862007-08-07 11:50:26 +02008461
Tony Vroond2fd4b02009-06-21 00:40:10 +01008462static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8463 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8464 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8465 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8466 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008467 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8468 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008469 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8470 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8471 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8472 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8473 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8474 { } /* end */
8475};
8476
Kailang Yange2757d52008-08-26 13:17:46 +02008477static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8478 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8479 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8480 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8481 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8482 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8483 0x0d, 1, 0x0, HDA_OUTPUT),
8484 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8485 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8486 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8487 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8488 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008489 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8490 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8491 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8492 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8493 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8494 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8495 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8496 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8497 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8498 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008499 { } /* end */
8500};
8501
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008502static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8503 /* Output mixers */
8504 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8505 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8506 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8507 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8508 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8509 HDA_OUTPUT),
8510 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8511 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8512 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8513 /* Output switches */
8514 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8515 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8516 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8517 /* Boost mixers */
8518 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8519 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8520 /* Input mixers */
8521 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8522 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8523 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8524 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8525 { } /* end */
8526};
8527
Guido Günther3e1647c2009-06-05 00:47:26 +02008528static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8529 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8530 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8531 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8532 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8533 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8534 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8535 { } /* end */
8536};
8537
Kailang Yange2757d52008-08-26 13:17:46 +02008538static struct hda_bind_ctls alc883_bind_cap_vol = {
8539 .ops = &snd_hda_bind_vol,
8540 .values = {
8541 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8542 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8543 0
8544 },
8545};
8546
8547static struct hda_bind_ctls alc883_bind_cap_switch = {
8548 .ops = &snd_hda_bind_sw,
8549 .values = {
8550 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8551 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8552 0
8553 },
8554};
8555
8556static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8557 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8558 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8559 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8560 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8561 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8562 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8563 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8564 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008565 { } /* end */
8566};
8567
8568static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008569 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8570 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8571 {
8572 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8573 /* .name = "Capture Source", */
8574 .name = "Input Source",
8575 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008576 .info = alc_mux_enum_info,
8577 .get = alc_mux_enum_get,
8578 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008579 },
8580 { } /* end */
8581};
8582
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008583static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8584 {
8585 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8586 .name = "Channel Mode",
8587 .info = alc_ch_mode_info,
8588 .get = alc_ch_mode_get,
8589 .put = alc_ch_mode_put,
8590 },
8591 { } /* end */
8592};
8593
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008594/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008595static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008596{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008597 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008598
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008599 spec->autocfg.hp_pins[0] = 0x15;
8600 spec->autocfg.speaker_pins[0] = 0x14;
8601 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008602}
8603
8604/* auto-toggle front mic */
8605/*
8606static void alc883_mitac_mic_automute(struct hda_codec *codec)
8607{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008608 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008609
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008610 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8611}
8612*/
8613
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008614static struct hda_verb alc883_mitac_verbs[] = {
8615 /* HP */
8616 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8617 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8618 /* Subwoofer */
8619 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8620 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8621
8622 /* enable unsolicited event */
8623 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8624 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8625
8626 { } /* end */
8627};
8628
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308629static struct hda_verb alc883_clevo_m540r_verbs[] = {
8630 /* HP */
8631 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8632 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8633 /* Int speaker */
8634 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8635
8636 /* enable unsolicited event */
8637 /*
8638 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8639 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8640 */
8641
8642 { } /* end */
8643};
8644
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008645static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008646 /* HP */
8647 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8648 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8649 /* Int speaker */
8650 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8651 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8652
8653 /* enable unsolicited event */
8654 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008655 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008656
8657 { } /* end */
8658};
8659
Jiang zhefb97dc62008-03-06 11:07:11 +01008660static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8661 /* HP */
8662 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8663 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8664 /* Subwoofer */
8665 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8666 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8667
8668 /* enable unsolicited event */
8669 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8670
8671 { } /* end */
8672};
8673
Sasha Alexandrc2592492009-06-16 14:52:54 -04008674static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008675 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8676 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8677
8678 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8679 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008680
David Heidelberger64a8be72009-06-08 16:15:18 +02008681/* Connect Line-Out side jack (SPDIF) to Side */
8682 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8683 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8684 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8685/* Connect Mic jack to CLFE */
8686 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8687 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8688 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8689/* Connect Line-in jack to Surround */
8690 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8692 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8693/* Connect HP out jack to Front */
8694 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8695 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8696 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008697
8698 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008699
8700 { } /* end */
8701};
8702
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008703static struct hda_verb alc883_lenovo_101e_verbs[] = {
8704 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8705 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8706 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8707 { } /* end */
8708};
8709
Kailang Yang272a5272007-05-14 11:00:38 +02008710static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8711 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8712 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8713 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8714 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8715 { } /* end */
8716};
8717
8718static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8719 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8720 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8721 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8722 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8723 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8724 { } /* end */
8725};
8726
Kailang Yang189609a2007-08-20 11:31:23 +02008727static struct hda_verb alc883_haier_w66_verbs[] = {
8728 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8729 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8730
8731 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8732
8733 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8734 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8735 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8736 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8737 { } /* end */
8738};
8739
Kailang Yange2757d52008-08-26 13:17:46 +02008740static struct hda_verb alc888_lenovo_sky_verbs[] = {
8741 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8742 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8743 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8744 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8745 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8746 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8747 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8748 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8749 { } /* end */
8750};
8751
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008752static struct hda_verb alc888_6st_dell_verbs[] = {
8753 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8754 { }
8755};
8756
Guido Günther3e1647c2009-06-05 00:47:26 +02008757static struct hda_verb alc883_vaiott_verbs[] = {
8758 /* HP */
8759 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8760 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8761
8762 /* enable unsolicited event */
8763 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8764
8765 { } /* end */
8766};
8767
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008768static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008769{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008770 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008771
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008772 spec->autocfg.hp_pins[0] = 0x1b;
8773 spec->autocfg.speaker_pins[0] = 0x14;
8774 spec->autocfg.speaker_pins[1] = 0x16;
8775 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008776}
8777
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008778static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008779 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008780 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8781 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008782 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008783 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008784};
8785
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008786/*
8787 * 2ch mode
8788 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008789static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008790 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8791 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8792 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8793 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008794 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008795};
8796
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008797/*
8798 * 4ch mode
8799 */
8800static struct hda_verb alc888_3st_hp_4ch_init[] = {
8801 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8802 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8803 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8804 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8805 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8806 { } /* end */
8807};
8808
8809/*
8810 * 6ch mode
8811 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008812static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008813 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8814 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008815 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008816 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8817 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008818 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8819 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008820};
8821
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008822static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008823 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008824 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008825 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008826};
8827
Kailang Yang272a5272007-05-14 11:00:38 +02008828/* toggle front-jack and RCA according to the hp-jack state */
8829static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8830{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008831 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008832
Takashi Iwai47fd8302007-08-10 17:11:07 +02008833 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8834 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8835 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8836 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008837}
8838
8839/* toggle RCA according to the front-jack state */
8840static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8841{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008842 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02008843
Takashi Iwai47fd8302007-08-10 17:11:07 +02008844 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8845 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008846}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008847
Kailang Yang272a5272007-05-14 11:00:38 +02008848static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8849 unsigned int res)
8850{
8851 if ((res >> 26) == ALC880_HP_EVENT)
8852 alc888_lenovo_ms7195_front_automute(codec);
8853 if ((res >> 26) == ALC880_FRONT_EVENT)
8854 alc888_lenovo_ms7195_rca_automute(codec);
8855}
8856
8857static struct hda_verb alc883_medion_md2_verbs[] = {
8858 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8859 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8860
8861 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8862
8863 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8864 { } /* end */
8865};
8866
8867/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008868static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008869{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008870 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008871
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008872 spec->autocfg.hp_pins[0] = 0x14;
8873 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008874}
8875
Kailang Yangccc656c2006-10-17 12:32:26 +02008876/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008877#define alc883_targa_init_hook alc882_targa_init_hook
8878#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008879
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008880static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8881{
8882 unsigned int present;
8883
Takashi Iwaid56757a2009-11-18 08:00:14 +01008884 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008885 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8886 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8887}
8888
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008889static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008890{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008891 struct alc_spec *spec = codec->spec;
8892
8893 spec->autocfg.hp_pins[0] = 0x15;
8894 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008895}
8896
8897static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8898{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008899 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008900 alc883_clevo_m720_mic_automute(codec);
8901}
8902
8903static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008904 unsigned int res)
8905{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008906 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008907 case ALC880_MIC_EVENT:
8908 alc883_clevo_m720_mic_automute(codec);
8909 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008910 default:
8911 alc_automute_amp_unsol_event(codec, res);
8912 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008913 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008914}
8915
Jiang zhefb97dc62008-03-06 11:07:11 +01008916/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008917static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008918{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008919 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008920
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008921 spec->autocfg.hp_pins[0] = 0x14;
8922 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008923}
8924
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008925static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008926{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008927 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008928
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008929 spec->autocfg.hp_pins[0] = 0x1b;
8930 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008931}
8932
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008933static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8934{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008935 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008936
Takashi Iwai47fd8302007-08-10 17:11:07 +02008937 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8938 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008939}
8940
8941static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8942{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008943 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008944
Takashi Iwai47fd8302007-08-10 17:11:07 +02008945 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8946 HDA_AMP_MUTE, bits);
8947 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8948 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008949}
8950
8951static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8952 unsigned int res)
8953{
8954 if ((res >> 26) == ALC880_HP_EVENT)
8955 alc883_lenovo_101e_all_automute(codec);
8956 if ((res >> 26) == ALC880_FRONT_EVENT)
8957 alc883_lenovo_101e_ispeaker_automute(codec);
8958}
8959
Takashi Iwai676a9b52007-08-16 15:23:35 +02008960/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008961static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008962{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008963 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008964
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008965 spec->autocfg.hp_pins[0] = 0x14;
8966 spec->autocfg.speaker_pins[0] = 0x15;
8967 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008968}
8969
Kailang Yangd1a991a2007-08-15 16:21:59 +02008970static struct hda_verb alc883_acer_eapd_verbs[] = {
8971 /* HP Pin: output 0 (0x0c) */
8972 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8973 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8974 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8975 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008976 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8977 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008978 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008979 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8980 /* eanable EAPD on medion laptop */
8981 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8982 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008983 /* enable unsolicited event */
8984 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008985 { }
8986};
8987
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008988static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8989 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8990 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8991 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8992 { } /* end */
8993};
8994
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008995static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008996{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008997 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008998
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008999 spec->autocfg.hp_pins[0] = 0x1b;
9000 spec->autocfg.speaker_pins[0] = 0x14;
9001 spec->autocfg.speaker_pins[1] = 0x15;
9002 spec->autocfg.speaker_pins[2] = 0x16;
9003 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009004}
9005
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009006static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009007{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009008 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009009
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009010 spec->autocfg.hp_pins[0] = 0x1b;
9011 spec->autocfg.speaker_pins[0] = 0x14;
9012 spec->autocfg.speaker_pins[1] = 0x15;
9013 spec->autocfg.speaker_pins[2] = 0x16;
9014 spec->autocfg.speaker_pins[3] = 0x17;
9015 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009016}
9017
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009018static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009019{
9020 struct alc_spec *spec = codec->spec;
9021
9022 spec->autocfg.hp_pins[0] = 0x15;
9023 spec->autocfg.speaker_pins[0] = 0x14;
9024 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009025}
9026
Kailang Yange2757d52008-08-26 13:17:46 +02009027static struct hda_verb alc888_asus_m90v_verbs[] = {
9028 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9029 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9030 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9031 /* enable unsolicited event */
9032 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9033 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9034 { } /* end */
9035};
9036
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009037static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009038{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009039 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009040
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009041 spec->autocfg.hp_pins[0] = 0x1b;
9042 spec->autocfg.speaker_pins[0] = 0x14;
9043 spec->autocfg.speaker_pins[1] = 0x15;
9044 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009045 spec->ext_mic.pin = 0x18;
9046 spec->int_mic.pin = 0x19;
9047 spec->ext_mic.mux_idx = 0;
9048 spec->int_mic.mux_idx = 1;
9049 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009050}
9051
9052static struct hda_verb alc888_asus_eee1601_verbs[] = {
9053 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9054 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9055 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9056 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9057 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9058 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9059 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9060 /* enable unsolicited event */
9061 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9062 { } /* end */
9063};
9064
Kailang Yange2757d52008-08-26 13:17:46 +02009065static void alc883_eee1601_inithook(struct hda_codec *codec)
9066{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009067 struct alc_spec *spec = codec->spec;
9068
9069 spec->autocfg.hp_pins[0] = 0x14;
9070 spec->autocfg.speaker_pins[0] = 0x1b;
9071 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009072}
9073
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009074static struct hda_verb alc889A_mb31_verbs[] = {
9075 /* Init rear pin (used as headphone output) */
9076 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9077 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9078 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9079 /* Init line pin (used as output in 4ch and 6ch mode) */
9080 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9081 /* Init line 2 pin (used as headphone out by default) */
9082 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9083 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9084 { } /* end */
9085};
9086
9087/* Mute speakers according to the headphone jack state */
9088static void alc889A_mb31_automute(struct hda_codec *codec)
9089{
9090 unsigned int present;
9091
9092 /* Mute only in 2ch or 4ch mode */
9093 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9094 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009095 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009096 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9097 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9098 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9099 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9100 }
9101}
9102
9103static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9104{
9105 if ((res >> 26) == ALC880_HP_EVENT)
9106 alc889A_mb31_automute(codec);
9107}
9108
Takashi Iwai4953550a2009-06-30 15:28:30 +02009109
Takashi Iwaicb53c622007-08-10 17:21:45 +02009110#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009111#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009112#endif
9113
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009114/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009115#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9116#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9117#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9118#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9119
9120static hda_nid_t alc883_slave_dig_outs[] = {
9121 ALC1200_DIGOUT_NID, 0,
9122};
9123
9124static hda_nid_t alc1200_slave_dig_outs[] = {
9125 ALC883_DIGOUT_NID, 0,
9126};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009127
9128/*
9129 * configuration and preset
9130 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009131static const char *alc882_models[ALC882_MODEL_LAST] = {
9132 [ALC882_3ST_DIG] = "3stack-dig",
9133 [ALC882_6ST_DIG] = "6stack-dig",
9134 [ALC882_ARIMA] = "arima",
9135 [ALC882_W2JC] = "w2jc",
9136 [ALC882_TARGA] = "targa",
9137 [ALC882_ASUS_A7J] = "asus-a7j",
9138 [ALC882_ASUS_A7M] = "asus-a7m",
9139 [ALC885_MACPRO] = "macpro",
9140 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009141 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009142 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009143 [ALC885_MBP3] = "mbp3",
9144 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009145 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009146 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009147 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9148 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009149 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009150 [ALC883_TARGA_DIG] = "targa-dig",
9151 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009152 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009153 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009154 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009155 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009156 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009157 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009158 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009159 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009160 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009161 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009162 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009163 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9164 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009165 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009166 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009167 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009168 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009169 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309170 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009171 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009172 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009173 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009174 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009175 [ALC889A_INTEL] = "intel-alc889a",
9176 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009177 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009178 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009179 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009180 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009181};
9182
Takashi Iwai4953550a2009-06-30 15:28:30 +02009183static struct snd_pci_quirk alc882_cfg_tbl[] = {
9184 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9185
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009186 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009187 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009188 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009189 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9190 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009191 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009192 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9193 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009194 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009195 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009196 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9197 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009198 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9199 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009200 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9201 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009202 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009203 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009204 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009205 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009206 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9207 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009208 /* default Acer -- disabled as it causes more problems.
9209 * model=auto should work fine now
9210 */
9211 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009212
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009213 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009214
Tobin Davisfebe3372007-06-12 11:27:46 +02009215 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009216 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9217 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009218 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009219 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009220 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009221
9222 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9223 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9224 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009225 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009226 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9227 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9228 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009229 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009230 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009231 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009232 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009233
9234 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009235 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009236 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009237 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009238 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9239 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009240 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009241 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009242 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9243
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009244 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9245 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9246 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009247 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009248 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009249 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009250 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009251 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009252 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9253 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9254 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9255 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9256 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9257 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009258 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009259 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9260 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9261 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009262 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009263 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009264 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9265 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009266 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009267 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009268 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009269 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009270 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009271 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009272 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009273 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009274 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009275
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009276 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009277 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9278 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309279 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009280 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009281 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009282 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009283 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009284 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009285 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009286 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009287 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009288 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009289 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009290 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9291 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009292 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009293 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009294 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009295 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009296 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009297
Jiang zhe17bba1b2008-06-04 12:11:07 +02009298 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9299 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009300 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009301 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9302 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9303 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009304 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009305
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009306 {}
9307};
9308
Takashi Iwai4953550a2009-06-30 15:28:30 +02009309/* codec SSID table for Intel Mac */
9310static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9311 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9312 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9313 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9314 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9315 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9316 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9317 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
9318 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9319 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9320 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009321 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009322 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009323 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9324 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009325 */
9326 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009327 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009328 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009329 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009330};
9331
Takashi Iwai4953550a2009-06-30 15:28:30 +02009332static struct alc_config_preset alc882_presets[] = {
9333 [ALC882_3ST_DIG] = {
9334 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009335 .init_verbs = { alc882_base_init_verbs,
9336 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009337 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9338 .dac_nids = alc882_dac_nids,
9339 .dig_out_nid = ALC882_DIGOUT_NID,
9340 .dig_in_nid = ALC882_DIGIN_NID,
9341 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9342 .channel_mode = alc882_ch_modes,
9343 .need_dac_fix = 1,
9344 .input_mux = &alc882_capture_source,
9345 },
9346 [ALC882_6ST_DIG] = {
9347 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009348 .init_verbs = { alc882_base_init_verbs,
9349 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009350 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9351 .dac_nids = alc882_dac_nids,
9352 .dig_out_nid = ALC882_DIGOUT_NID,
9353 .dig_in_nid = ALC882_DIGIN_NID,
9354 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9355 .channel_mode = alc882_sixstack_modes,
9356 .input_mux = &alc882_capture_source,
9357 },
9358 [ALC882_ARIMA] = {
9359 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009360 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9361 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009362 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9363 .dac_nids = alc882_dac_nids,
9364 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9365 .channel_mode = alc882_sixstack_modes,
9366 .input_mux = &alc882_capture_source,
9367 },
9368 [ALC882_W2JC] = {
9369 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009370 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9371 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009372 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9373 .dac_nids = alc882_dac_nids,
9374 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9375 .channel_mode = alc880_threestack_modes,
9376 .need_dac_fix = 1,
9377 .input_mux = &alc882_capture_source,
9378 .dig_out_nid = ALC882_DIGOUT_NID,
9379 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009380 [ALC885_MBA21] = {
9381 .mixers = { alc885_mba21_mixer },
9382 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9383 .num_dacs = 2,
9384 .dac_nids = alc882_dac_nids,
9385 .channel_mode = alc885_mba21_ch_modes,
9386 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9387 .input_mux = &alc882_capture_source,
9388 .unsol_event = alc_automute_amp_unsol_event,
9389 .setup = alc885_mba21_setup,
9390 .init_hook = alc_automute_amp,
9391 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009392 [ALC885_MBP3] = {
9393 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9394 .init_verbs = { alc885_mbp3_init_verbs,
9395 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009396 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009397 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009398 .hp_nid = 0x04,
9399 .channel_mode = alc885_mbp_4ch_modes,
9400 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009401 .input_mux = &alc882_capture_source,
9402 .dig_out_nid = ALC882_DIGOUT_NID,
9403 .dig_in_nid = ALC882_DIGIN_NID,
9404 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009405 .setup = alc885_mbp3_setup,
9406 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009407 },
9408 [ALC885_MB5] = {
9409 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9410 .init_verbs = { alc885_mb5_init_verbs,
9411 alc880_gpio1_init_verbs },
9412 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9413 .dac_nids = alc882_dac_nids,
9414 .channel_mode = alc885_mb5_6ch_modes,
9415 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9416 .input_mux = &mb5_capture_source,
9417 .dig_out_nid = ALC882_DIGOUT_NID,
9418 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009419 .unsol_event = alc_automute_amp_unsol_event,
9420 .setup = alc885_mb5_setup,
9421 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009422 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009423 [ALC885_MACMINI3] = {
9424 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9425 .init_verbs = { alc885_macmini3_init_verbs,
9426 alc880_gpio1_init_verbs },
9427 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9428 .dac_nids = alc882_dac_nids,
9429 .channel_mode = alc885_macmini3_6ch_modes,
9430 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9431 .input_mux = &macmini3_capture_source,
9432 .dig_out_nid = ALC882_DIGOUT_NID,
9433 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009434 .unsol_event = alc_automute_amp_unsol_event,
9435 .setup = alc885_macmini3_setup,
9436 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009437 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009438 [ALC885_MACPRO] = {
9439 .mixers = { alc882_macpro_mixer },
9440 .init_verbs = { alc882_macpro_init_verbs },
9441 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9442 .dac_nids = alc882_dac_nids,
9443 .dig_out_nid = ALC882_DIGOUT_NID,
9444 .dig_in_nid = ALC882_DIGIN_NID,
9445 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9446 .channel_mode = alc882_ch_modes,
9447 .input_mux = &alc882_capture_source,
9448 .init_hook = alc885_macpro_init_hook,
9449 },
9450 [ALC885_IMAC24] = {
9451 .mixers = { alc885_imac24_mixer },
9452 .init_verbs = { alc885_imac24_init_verbs },
9453 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9454 .dac_nids = alc882_dac_nids,
9455 .dig_out_nid = ALC882_DIGOUT_NID,
9456 .dig_in_nid = ALC882_DIGIN_NID,
9457 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9458 .channel_mode = alc882_ch_modes,
9459 .input_mux = &alc882_capture_source,
9460 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009461 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009462 .init_hook = alc885_imac24_init_hook,
9463 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009464 [ALC885_IMAC91] = {
9465 .mixers = { alc885_imac91_mixer, alc882_chmode_mixer },
9466 .init_verbs = { alc885_imac91_init_verbs,
9467 alc880_gpio1_init_verbs },
9468 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9469 .dac_nids = alc882_dac_nids,
9470 .channel_mode = alc885_mbp_4ch_modes,
9471 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
9472 .input_mux = &alc882_capture_source,
9473 .dig_out_nid = ALC882_DIGOUT_NID,
9474 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009475 .unsol_event = alc_automute_amp_unsol_event,
9476 .setup = alc885_imac91_setup,
9477 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009478 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009479 [ALC882_TARGA] = {
9480 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009481 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009482 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009483 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9484 .dac_nids = alc882_dac_nids,
9485 .dig_out_nid = ALC882_DIGOUT_NID,
9486 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9487 .adc_nids = alc882_adc_nids,
9488 .capsrc_nids = alc882_capsrc_nids,
9489 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9490 .channel_mode = alc882_3ST_6ch_modes,
9491 .need_dac_fix = 1,
9492 .input_mux = &alc882_capture_source,
9493 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009494 .setup = alc882_targa_setup,
9495 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009496 },
9497 [ALC882_ASUS_A7J] = {
9498 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009499 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9500 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009501 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9502 .dac_nids = alc882_dac_nids,
9503 .dig_out_nid = ALC882_DIGOUT_NID,
9504 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9505 .adc_nids = alc882_adc_nids,
9506 .capsrc_nids = alc882_capsrc_nids,
9507 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9508 .channel_mode = alc882_3ST_6ch_modes,
9509 .need_dac_fix = 1,
9510 .input_mux = &alc882_capture_source,
9511 },
9512 [ALC882_ASUS_A7M] = {
9513 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009514 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9515 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009516 alc882_asus_a7m_verbs },
9517 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9518 .dac_nids = alc882_dac_nids,
9519 .dig_out_nid = ALC882_DIGOUT_NID,
9520 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9521 .channel_mode = alc880_threestack_modes,
9522 .need_dac_fix = 1,
9523 .input_mux = &alc882_capture_source,
9524 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009525 [ALC883_3ST_2ch_DIG] = {
9526 .mixers = { alc883_3ST_2ch_mixer },
9527 .init_verbs = { alc883_init_verbs },
9528 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9529 .dac_nids = alc883_dac_nids,
9530 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009531 .dig_in_nid = ALC883_DIGIN_NID,
9532 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9533 .channel_mode = alc883_3ST_2ch_modes,
9534 .input_mux = &alc883_capture_source,
9535 },
9536 [ALC883_3ST_6ch_DIG] = {
9537 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9538 .init_verbs = { alc883_init_verbs },
9539 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9540 .dac_nids = alc883_dac_nids,
9541 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009542 .dig_in_nid = ALC883_DIGIN_NID,
9543 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9544 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009545 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009546 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009547 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009548 [ALC883_3ST_6ch] = {
9549 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9550 .init_verbs = { alc883_init_verbs },
9551 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9552 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009553 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9554 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009555 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009556 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009557 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009558 [ALC883_3ST_6ch_INTEL] = {
9559 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9560 .init_verbs = { alc883_init_verbs },
9561 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9562 .dac_nids = alc883_dac_nids,
9563 .dig_out_nid = ALC883_DIGOUT_NID,
9564 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009565 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009566 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9567 .channel_mode = alc883_3ST_6ch_intel_modes,
9568 .need_dac_fix = 1,
9569 .input_mux = &alc883_3stack_6ch_intel,
9570 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009571 [ALC889A_INTEL] = {
9572 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009573 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9574 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009575 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9576 .dac_nids = alc883_dac_nids,
9577 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9578 .adc_nids = alc889_adc_nids,
9579 .dig_out_nid = ALC883_DIGOUT_NID,
9580 .dig_in_nid = ALC883_DIGIN_NID,
9581 .slave_dig_outs = alc883_slave_dig_outs,
9582 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9583 .channel_mode = alc889_8ch_intel_modes,
9584 .capsrc_nids = alc889_capsrc_nids,
9585 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009586 .setup = alc889_automute_setup,
9587 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009588 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009589 .need_dac_fix = 1,
9590 },
9591 [ALC889_INTEL] = {
9592 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9593 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009594 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009595 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9596 .dac_nids = alc883_dac_nids,
9597 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9598 .adc_nids = alc889_adc_nids,
9599 .dig_out_nid = ALC883_DIGOUT_NID,
9600 .dig_in_nid = ALC883_DIGIN_NID,
9601 .slave_dig_outs = alc883_slave_dig_outs,
9602 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9603 .channel_mode = alc889_8ch_intel_modes,
9604 .capsrc_nids = alc889_capsrc_nids,
9605 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009606 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009607 .init_hook = alc889_intel_init_hook,
9608 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009609 .need_dac_fix = 1,
9610 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009611 [ALC883_6ST_DIG] = {
9612 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9613 .init_verbs = { alc883_init_verbs },
9614 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9615 .dac_nids = alc883_dac_nids,
9616 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009617 .dig_in_nid = ALC883_DIGIN_NID,
9618 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9619 .channel_mode = alc883_sixstack_modes,
9620 .input_mux = &alc883_capture_source,
9621 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009622 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009623 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009624 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9625 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009626 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9627 .dac_nids = alc883_dac_nids,
9628 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009629 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9630 .channel_mode = alc883_3ST_6ch_modes,
9631 .need_dac_fix = 1,
9632 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009633 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009634 .setup = alc882_targa_setup,
9635 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009636 },
9637 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009638 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009639 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9640 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009641 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9642 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009643 .adc_nids = alc883_adc_nids_alt,
9644 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009645 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009646 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009647 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9648 .channel_mode = alc883_3ST_2ch_modes,
9649 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009650 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009651 .setup = alc882_targa_setup,
9652 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009653 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009654 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009655 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9656 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009657 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009658 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009659 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9660 .dac_nids = alc883_dac_nids,
9661 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9662 .adc_nids = alc883_adc_nids_rev,
9663 .capsrc_nids = alc883_capsrc_nids_rev,
9664 .dig_out_nid = ALC883_DIGOUT_NID,
9665 .dig_in_nid = ALC883_DIGIN_NID,
9666 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9667 .channel_mode = alc883_4ST_8ch_modes,
9668 .need_dac_fix = 1,
9669 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009670 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009671 .setup = alc882_targa_setup,
9672 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009673 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009674 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009675 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009676 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9677 * and the headphone jack. Turn this on and rely on the
9678 * standard mute methods whenever the user wants to turn
9679 * these outputs off.
9680 */
9681 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9682 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9683 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009684 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9685 .channel_mode = alc883_3ST_2ch_modes,
9686 .input_mux = &alc883_capture_source,
9687 },
Tobin Davis2880a862007-08-07 11:50:26 +02009688 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009689 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009690 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009691 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9692 .dac_nids = alc883_dac_nids,
9693 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009694 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9695 .channel_mode = alc883_3ST_2ch_modes,
9696 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009697 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009698 .setup = alc883_acer_aspire_setup,
9699 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009700 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009701 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009702 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009703 alc883_chmode_mixer },
9704 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9705 alc888_acer_aspire_4930g_verbs },
9706 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9707 .dac_nids = alc883_dac_nids,
9708 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9709 .adc_nids = alc883_adc_nids_rev,
9710 .capsrc_nids = alc883_capsrc_nids_rev,
9711 .dig_out_nid = ALC883_DIGOUT_NID,
9712 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9713 .channel_mode = alc883_3ST_6ch_modes,
9714 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +01009715 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009716 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009717 ARRAY_SIZE(alc888_2_capture_sources),
9718 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009719 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009720 .setup = alc888_acer_aspire_4930g_setup,
9721 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009722 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009723 [ALC888_ACER_ASPIRE_6530G] = {
9724 .mixers = { alc888_acer_aspire_6530_mixer },
9725 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9726 alc888_acer_aspire_6530g_verbs },
9727 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9728 .dac_nids = alc883_dac_nids,
9729 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9730 .adc_nids = alc883_adc_nids_rev,
9731 .capsrc_nids = alc883_capsrc_nids_rev,
9732 .dig_out_nid = ALC883_DIGOUT_NID,
9733 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9734 .channel_mode = alc883_3ST_2ch_modes,
9735 .num_mux_defs =
9736 ARRAY_SIZE(alc888_2_capture_sources),
9737 .input_mux = alc888_acer_aspire_6530_sources,
9738 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009739 .setup = alc888_acer_aspire_6530g_setup,
9740 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009741 },
Hector Martin3b315d72009-06-02 10:54:19 +02009742 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +01009743 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +02009744 alc883_chmode_mixer },
9745 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +01009746 alc889_acer_aspire_8930g_verbs,
9747 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +02009748 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9749 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009750 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9751 .adc_nids = alc889_adc_nids,
9752 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009753 .dig_out_nid = ALC883_DIGOUT_NID,
9754 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9755 .channel_mode = alc883_3ST_6ch_modes,
9756 .need_dac_fix = 1,
9757 .const_channel_count = 6,
9758 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009759 ARRAY_SIZE(alc889_capture_sources),
9760 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009761 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009762 .setup = alc889_acer_aspire_8930g_setup,
9763 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +01009764#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05009765 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +01009766#endif
Hector Martin3b315d72009-06-02 10:54:19 +02009767 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009768 [ALC888_ACER_ASPIRE_7730G] = {
9769 .mixers = { alc883_3ST_6ch_mixer,
9770 alc883_chmode_mixer },
9771 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9772 alc888_acer_aspire_7730G_verbs },
9773 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9774 .dac_nids = alc883_dac_nids,
9775 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9776 .adc_nids = alc883_adc_nids_rev,
9777 .capsrc_nids = alc883_capsrc_nids_rev,
9778 .dig_out_nid = ALC883_DIGOUT_NID,
9779 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9780 .channel_mode = alc883_3ST_6ch_modes,
9781 .need_dac_fix = 1,
9782 .const_channel_count = 6,
9783 .input_mux = &alc883_capture_source,
9784 .unsol_event = alc_automute_amp_unsol_event,
9785 .setup = alc888_acer_aspire_6530g_setup,
9786 .init_hook = alc_automute_amp,
9787 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009788 [ALC883_MEDION] = {
9789 .mixers = { alc883_fivestack_mixer,
9790 alc883_chmode_mixer },
9791 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009792 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009793 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9794 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009795 .adc_nids = alc883_adc_nids_alt,
9796 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009797 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009798 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9799 .channel_mode = alc883_sixstack_modes,
9800 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009801 },
Kailang Yang272a5272007-05-14 11:00:38 +02009802 [ALC883_MEDION_MD2] = {
9803 .mixers = { alc883_medion_md2_mixer},
9804 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9805 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9806 .dac_nids = alc883_dac_nids,
9807 .dig_out_nid = ALC883_DIGOUT_NID,
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 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009811 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009812 .setup = alc883_medion_md2_setup,
9813 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009814 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009815 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009816 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009817 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9818 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9819 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009820 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9821 .channel_mode = alc883_3ST_2ch_modes,
9822 .input_mux = &alc883_capture_source,
9823 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309824 [ALC883_CLEVO_M540R] = {
9825 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9826 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9827 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9828 .dac_nids = alc883_dac_nids,
9829 .dig_out_nid = ALC883_DIGOUT_NID,
9830 .dig_in_nid = ALC883_DIGIN_NID,
9831 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9832 .channel_mode = alc883_3ST_6ch_clevo_modes,
9833 .need_dac_fix = 1,
9834 .input_mux = &alc883_capture_source,
9835 /* This machine has the hardware HP auto-muting, thus
9836 * we need no software mute via unsol event
9837 */
9838 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009839 [ALC883_CLEVO_M720] = {
9840 .mixers = { alc883_clevo_m720_mixer },
9841 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009842 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9843 .dac_nids = alc883_dac_nids,
9844 .dig_out_nid = ALC883_DIGOUT_NID,
9845 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9846 .channel_mode = alc883_3ST_2ch_modes,
9847 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009848 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009849 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009850 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009851 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009852 [ALC883_LENOVO_101E_2ch] = {
9853 .mixers = { alc883_lenovo_101e_2ch_mixer},
9854 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9855 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9856 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009857 .adc_nids = alc883_adc_nids_alt,
9858 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009859 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009860 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9861 .channel_mode = alc883_3ST_2ch_modes,
9862 .input_mux = &alc883_lenovo_101e_capture_source,
9863 .unsol_event = alc883_lenovo_101e_unsol_event,
9864 .init_hook = alc883_lenovo_101e_all_automute,
9865 },
Kailang Yang272a5272007-05-14 11:00:38 +02009866 [ALC883_LENOVO_NB0763] = {
9867 .mixers = { alc883_lenovo_nb0763_mixer },
9868 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9869 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9870 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009871 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9872 .channel_mode = alc883_3ST_2ch_modes,
9873 .need_dac_fix = 1,
9874 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009875 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009876 .setup = alc883_medion_md2_setup,
9877 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009878 },
9879 [ALC888_LENOVO_MS7195_DIG] = {
9880 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9881 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9882 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9883 .dac_nids = alc883_dac_nids,
9884 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009885 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9886 .channel_mode = alc883_3ST_6ch_modes,
9887 .need_dac_fix = 1,
9888 .input_mux = &alc883_capture_source,
9889 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9890 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009891 },
9892 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009893 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009894 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9895 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9896 .dac_nids = alc883_dac_nids,
9897 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009898 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9899 .channel_mode = alc883_3ST_2ch_modes,
9900 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009901 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009902 .setup = alc883_haier_w66_setup,
9903 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009904 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009905 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009906 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009907 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009908 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9909 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009910 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9911 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009912 .need_dac_fix = 1,
9913 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009914 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009915 .setup = alc888_3st_hp_setup,
9916 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009917 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009918 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009919 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009920 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9921 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9922 .dac_nids = alc883_dac_nids,
9923 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009924 .dig_in_nid = ALC883_DIGIN_NID,
9925 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9926 .channel_mode = alc883_sixstack_modes,
9927 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009928 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009929 .setup = alc888_6st_dell_setup,
9930 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009931 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009932 [ALC883_MITAC] = {
9933 .mixers = { alc883_mitac_mixer },
9934 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9935 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9936 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009937 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9938 .channel_mode = alc883_3ST_2ch_modes,
9939 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009940 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009941 .setup = alc883_mitac_setup,
9942 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009943 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009944 [ALC883_FUJITSU_PI2515] = {
9945 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9946 .init_verbs = { alc883_init_verbs,
9947 alc883_2ch_fujitsu_pi2515_verbs},
9948 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9949 .dac_nids = alc883_dac_nids,
9950 .dig_out_nid = ALC883_DIGOUT_NID,
9951 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9952 .channel_mode = alc883_3ST_2ch_modes,
9953 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009954 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009955 .setup = alc883_2ch_fujitsu_pi2515_setup,
9956 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009957 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009958 [ALC888_FUJITSU_XA3530] = {
9959 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9960 .init_verbs = { alc883_init_verbs,
9961 alc888_fujitsu_xa3530_verbs },
9962 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9963 .dac_nids = alc883_dac_nids,
9964 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9965 .adc_nids = alc883_adc_nids_rev,
9966 .capsrc_nids = alc883_capsrc_nids_rev,
9967 .dig_out_nid = ALC883_DIGOUT_NID,
9968 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9969 .channel_mode = alc888_4ST_8ch_intel_modes,
9970 .num_mux_defs =
9971 ARRAY_SIZE(alc888_2_capture_sources),
9972 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009973 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009974 .setup = alc888_fujitsu_xa3530_setup,
9975 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009976 },
Kailang Yange2757d52008-08-26 13:17:46 +02009977 [ALC888_LENOVO_SKY] = {
9978 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9979 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9980 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9981 .dac_nids = alc883_dac_nids,
9982 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009983 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9984 .channel_mode = alc883_sixstack_modes,
9985 .need_dac_fix = 1,
9986 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009987 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009988 .setup = alc888_lenovo_sky_setup,
9989 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009990 },
9991 [ALC888_ASUS_M90V] = {
9992 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9993 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9994 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9995 .dac_nids = alc883_dac_nids,
9996 .dig_out_nid = ALC883_DIGOUT_NID,
9997 .dig_in_nid = ALC883_DIGIN_NID,
9998 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9999 .channel_mode = alc883_3ST_6ch_modes,
10000 .need_dac_fix = 1,
10001 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010002 .unsol_event = alc_sku_unsol_event,
10003 .setup = alc883_mode2_setup,
10004 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010005 },
10006 [ALC888_ASUS_EEE1601] = {
10007 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010008 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010009 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10010 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10011 .dac_nids = alc883_dac_nids,
10012 .dig_out_nid = ALC883_DIGOUT_NID,
10013 .dig_in_nid = ALC883_DIGIN_NID,
10014 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10015 .channel_mode = alc883_3ST_2ch_modes,
10016 .need_dac_fix = 1,
10017 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010018 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010019 .init_hook = alc883_eee1601_inithook,
10020 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010021 [ALC1200_ASUS_P5Q] = {
10022 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10023 .init_verbs = { alc883_init_verbs },
10024 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10025 .dac_nids = alc883_dac_nids,
10026 .dig_out_nid = ALC1200_DIGOUT_NID,
10027 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010028 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010029 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10030 .channel_mode = alc883_sixstack_modes,
10031 .input_mux = &alc883_capture_source,
10032 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010033 [ALC889A_MB31] = {
10034 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10035 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10036 alc880_gpio1_init_verbs },
10037 .adc_nids = alc883_adc_nids,
10038 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010039 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010040 .dac_nids = alc883_dac_nids,
10041 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10042 .channel_mode = alc889A_mb31_6ch_modes,
10043 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10044 .input_mux = &alc889A_mb31_capture_source,
10045 .dig_out_nid = ALC883_DIGOUT_NID,
10046 .unsol_event = alc889A_mb31_unsol_event,
10047 .init_hook = alc889A_mb31_automute,
10048 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010049 [ALC883_SONY_VAIO_TT] = {
10050 .mixers = { alc883_vaiott_mixer },
10051 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10052 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10053 .dac_nids = alc883_dac_nids,
10054 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10055 .channel_mode = alc883_3ST_2ch_modes,
10056 .input_mux = &alc883_capture_source,
10057 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010058 .setup = alc883_vaiott_setup,
10059 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010060 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010061};
10062
10063
10064/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010065 * Pin config fixes
10066 */
10067enum {
10068 PINFIX_ABIT_AW9D_MAX
10069};
10070
10071static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
10072 { 0x15, 0x01080104 }, /* side */
10073 { 0x16, 0x01011012 }, /* rear */
10074 { 0x17, 0x01016011 }, /* clfe */
10075 { }
10076};
10077
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010078static const struct alc_fixup alc882_fixups[] = {
10079 [PINFIX_ABIT_AW9D_MAX] = {
10080 .pins = alc882_abit_aw9d_pinfix
10081 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010082};
10083
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010084static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +020010085 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10086 {}
10087};
10088
10089/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010090 * BIOS auto configuration
10091 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010092static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10093 const struct auto_pin_cfg *cfg)
10094{
10095 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10096}
10097
Takashi Iwai4953550a2009-06-30 15:28:30 +020010098static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010099 hda_nid_t nid, int pin_type,
10100 int dac_idx)
10101{
10102 /* set as output */
10103 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010104 int idx;
10105
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010106 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010107 if (spec->multiout.dac_nids[dac_idx] == 0x25)
10108 idx = 4;
Takashi Iwai6a4f2cc2010-03-25 15:00:15 +010010109 else {
10110 if (spec->multiout.num_dacs >= dac_idx)
10111 return;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010112 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai6a4f2cc2010-03-25 15:00:15 +010010113 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010114 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
10115
10116}
10117
Takashi Iwai4953550a2009-06-30 15:28:30 +020010118static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010119{
10120 struct alc_spec *spec = codec->spec;
10121 int i;
10122
10123 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010124 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010125 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010126 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010127 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010128 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010129 }
10130}
10131
Takashi Iwai4953550a2009-06-30 15:28:30 +020010132static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010133{
10134 struct alc_spec *spec = codec->spec;
10135 hda_nid_t pin;
10136
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010137 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010138 if (pin) /* connect to front */
10139 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010140 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010141 pin = spec->autocfg.speaker_pins[0];
10142 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010143 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010144}
10145
Takashi Iwai4953550a2009-06-30 15:28:30 +020010146static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010147{
10148 struct alc_spec *spec = codec->spec;
10149 int i;
10150
10151 for (i = 0; i < AUTO_PIN_LAST; i++) {
10152 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010153 if (!nid)
10154 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +020010155 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010156 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10157 snd_hda_codec_write(codec, nid, 0,
10158 AC_VERB_SET_AMP_GAIN_MUTE,
10159 AMP_OUT_MUTE);
10160 }
10161}
10162
10163static void alc882_auto_init_input_src(struct hda_codec *codec)
10164{
10165 struct alc_spec *spec = codec->spec;
10166 int c;
10167
10168 for (c = 0; c < spec->num_adc_nids; c++) {
10169 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10170 hda_nid_t nid = spec->capsrc_nids[c];
10171 unsigned int mux_idx;
10172 const struct hda_input_mux *imux;
10173 int conns, mute, idx, item;
10174
10175 conns = snd_hda_get_connections(codec, nid, conn_list,
10176 ARRAY_SIZE(conn_list));
10177 if (conns < 0)
10178 continue;
10179 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10180 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010181 if (!imux->num_items && mux_idx > 0)
10182 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010183 for (idx = 0; idx < conns; idx++) {
10184 /* if the current connection is the selected one,
10185 * unmute it as default - otherwise mute it
10186 */
10187 mute = AMP_IN_MUTE(idx);
10188 for (item = 0; item < imux->num_items; item++) {
10189 if (imux->items[item].index == idx) {
10190 if (spec->cur_mux[c] == item)
10191 mute = AMP_IN_UNMUTE(idx);
10192 break;
10193 }
10194 }
10195 /* check if we have a selector or mixer
10196 * we could check for the widget type instead, but
10197 * just check for Amp-In presence (in case of mixer
10198 * without amp-in there is something wrong, this
10199 * function shouldn't be used or capsrc nid is wrong)
10200 */
10201 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010202 snd_hda_codec_write(codec, nid, 0,
10203 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010204 mute);
10205 else if (mute != AMP_IN_MUTE(idx))
10206 snd_hda_codec_write(codec, nid, 0,
10207 AC_VERB_SET_CONNECT_SEL,
10208 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010209 }
10210 }
10211}
10212
Takashi Iwai4953550a2009-06-30 15:28:30 +020010213/* add mic boosts if needed */
10214static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010215{
10216 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010217 int err;
10218 hda_nid_t nid;
10219
10220 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
10221 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10222 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10223 "Mic Boost",
10224 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10225 if (err < 0)
10226 return err;
10227 }
10228 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
10229 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10230 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10231 "Front Mic Boost",
10232 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10233 if (err < 0)
10234 return err;
10235 }
10236 return 0;
10237}
10238
10239/* almost identical with ALC880 parser... */
10240static int alc882_parse_auto_config(struct hda_codec *codec)
10241{
10242 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010243 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
10244 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010245
Takashi Iwai05f5f472009-08-25 13:10:18 +020010246 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10247 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010248 if (err < 0)
10249 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010250 if (!spec->autocfg.line_outs)
10251 return 0; /* can't find valid BIOS pin config */
10252
10253 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10254 if (err < 0)
10255 return err;
10256 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10257 if (err < 0)
10258 return err;
10259 err = alc880_auto_create_extra_out(spec,
10260 spec->autocfg.speaker_pins[0],
10261 "Speaker");
10262 if (err < 0)
10263 return err;
10264 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10265 "Headphone");
10266 if (err < 0)
10267 return err;
10268 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10269 if (err < 0)
10270 return err;
10271
10272 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10273
10274 /* check multiple SPDIF-out (for recent codecs) */
10275 for (i = 0; i < spec->autocfg.dig_outs; i++) {
10276 hda_nid_t dig_nid;
10277 err = snd_hda_get_connections(codec,
10278 spec->autocfg.dig_out_pins[i],
10279 &dig_nid, 1);
10280 if (err < 0)
10281 continue;
10282 if (!i)
10283 spec->multiout.dig_out_nid = dig_nid;
10284 else {
10285 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010286 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +020010287 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010288 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010289 }
10290 }
10291 if (spec->autocfg.dig_in_pin)
10292 spec->dig_in_nid = ALC880_DIGIN_NID;
10293
10294 if (spec->kctls.list)
10295 add_mixer(spec, spec->kctls.list);
10296
10297 add_verb(spec, alc883_auto_init_verbs);
10298 /* if ADC 0x07 is available, initialize it, too */
10299 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10300 add_verb(spec, alc882_adc1_init_verbs);
10301
10302 spec->num_mux_defs = 1;
10303 spec->input_mux = &spec->private_imux[0];
10304
Kailang Yang6227cdc2010-02-25 08:36:52 +010010305 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010306
10307 err = alc_auto_add_mic_boost(codec);
10308 if (err < 0)
10309 return err;
10310
Takashi Iwai776e1842007-08-29 15:07:11 +020010311 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010312}
10313
10314/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010315static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010316{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010317 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010318 alc882_auto_init_multi_out(codec);
10319 alc882_auto_init_hp_out(codec);
10320 alc882_auto_init_analog_input(codec);
10321 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010322 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010323 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010324}
10325
Takashi Iwai4953550a2009-06-30 15:28:30 +020010326static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010327{
10328 struct alc_spec *spec;
10329 int err, board_config;
10330
10331 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10332 if (spec == NULL)
10333 return -ENOMEM;
10334
10335 codec->spec = spec;
10336
Takashi Iwai4953550a2009-06-30 15:28:30 +020010337 switch (codec->vendor_id) {
10338 case 0x10ec0882:
10339 case 0x10ec0885:
10340 break;
10341 default:
10342 /* ALC883 and variants */
10343 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10344 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010345 }
10346
Takashi Iwai4953550a2009-06-30 15:28:30 +020010347 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10348 alc882_models,
10349 alc882_cfg_tbl);
10350
10351 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10352 board_config = snd_hda_check_board_codec_sid_config(codec,
10353 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10354
10355 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010356 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010357 codec->chip_name);
10358 board_config = ALC882_AUTO;
10359 }
10360
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010361 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010362
10363 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010364 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010365 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010366 if (err < 0) {
10367 alc_free(codec);
10368 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010369 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010370 printk(KERN_INFO
10371 "hda_codec: Cannot set up configuration "
10372 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010373 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010374 }
10375 }
10376
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010377 err = snd_hda_attach_beep_device(codec, 0x1);
10378 if (err < 0) {
10379 alc_free(codec);
10380 return err;
10381 }
10382
Takashi Iwai4953550a2009-06-30 15:28:30 +020010383 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010384 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010385
Takashi Iwai4953550a2009-06-30 15:28:30 +020010386 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10387 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10388 /* FIXME: setup DAC5 */
10389 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10390 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10391
10392 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10393 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10394
10395 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010396 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010397
10398 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010399 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010400 spec->num_adc_nids = 0;
10401 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010402 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010403 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010404 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010405 hda_nid_t nid = alc882_adc_nids[i];
10406 unsigned int wcap = get_wcaps(codec, nid);
10407 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010408 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010409 if (wcap != AC_WID_AUD_IN)
10410 continue;
10411 spec->private_adc_nids[spec->num_adc_nids] = nid;
10412 err = snd_hda_get_connections(codec, nid, &cap, 1);
10413 if (err < 0)
10414 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010415 err = snd_hda_get_connections(codec, cap, items,
10416 ARRAY_SIZE(items));
10417 if (err < 0)
10418 continue;
10419 for (j = 0; j < imux->num_items; j++)
10420 if (imux->items[j].index >= err)
10421 break;
10422 if (j < imux->num_items)
10423 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010424 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10425 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010426 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010427 spec->adc_nids = spec->private_adc_nids;
10428 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010429 }
10430
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010431 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010010432 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010433
Takashi Iwai2134ea42008-01-10 16:53:55 +010010434 spec->vmaster_nid = 0x0c;
10435
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010436 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010437 if (board_config == ALC882_AUTO)
10438 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010439#ifdef CONFIG_SND_HDA_POWER_SAVE
10440 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010441 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010442#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010443
10444 return 0;
10445}
10446
Takashi Iwai4953550a2009-06-30 15:28:30 +020010447
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010448/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010449 * ALC262 support
10450 */
10451
10452#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10453#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10454
10455#define alc262_dac_nids alc260_dac_nids
10456#define alc262_adc_nids alc882_adc_nids
10457#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010458#define alc262_capsrc_nids alc882_capsrc_nids
10459#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010460
10461#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010462#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010463
Kailang Yang4e555fe2008-08-26 13:05:55 +020010464static hda_nid_t alc262_dmic_adc_nids[1] = {
10465 /* ADC0 */
10466 0x09
10467};
10468
10469static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10470
Kailang Yangdf694da2005-12-05 19:42:22 +010010471static struct snd_kcontrol_new alc262_base_mixer[] = {
10472 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10473 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10474 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10475 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10476 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10477 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10478 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10479 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010480 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010481 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10482 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010483 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010484 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10485 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10486 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10487 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010488 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010489};
10490
Takashi Iwaice875f02008-01-28 18:17:43 +010010491/* update HP, line and mono-out pins according to the master switch */
10492static void alc262_hp_master_update(struct hda_codec *codec)
10493{
10494 struct alc_spec *spec = codec->spec;
10495 int val = spec->master_sw;
10496
10497 /* HP & line-out */
10498 snd_hda_codec_write_cache(codec, 0x1b, 0,
10499 AC_VERB_SET_PIN_WIDGET_CONTROL,
10500 val ? PIN_HP : 0);
10501 snd_hda_codec_write_cache(codec, 0x15, 0,
10502 AC_VERB_SET_PIN_WIDGET_CONTROL,
10503 val ? PIN_HP : 0);
10504 /* mono (speaker) depending on the HP jack sense */
10505 val = val && !spec->jack_present;
10506 snd_hda_codec_write_cache(codec, 0x16, 0,
10507 AC_VERB_SET_PIN_WIDGET_CONTROL,
10508 val ? PIN_OUT : 0);
10509}
10510
10511static void alc262_hp_bpc_automute(struct hda_codec *codec)
10512{
10513 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010514
10515 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010516 alc262_hp_master_update(codec);
10517}
10518
10519static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10520{
10521 if ((res >> 26) != ALC880_HP_EVENT)
10522 return;
10523 alc262_hp_bpc_automute(codec);
10524}
10525
10526static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10527{
10528 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010529
10530 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010531 alc262_hp_master_update(codec);
10532}
10533
10534static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10535 unsigned int res)
10536{
10537 if ((res >> 26) != ALC880_HP_EVENT)
10538 return;
10539 alc262_hp_wildwest_automute(codec);
10540}
10541
Takashi Iwaib72519b2009-05-08 14:31:55 +020010542#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010543
10544static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10545 struct snd_ctl_elem_value *ucontrol)
10546{
10547 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10548 struct alc_spec *spec = codec->spec;
10549 int val = !!*ucontrol->value.integer.value;
10550
10551 if (val == spec->master_sw)
10552 return 0;
10553 spec->master_sw = val;
10554 alc262_hp_master_update(codec);
10555 return 1;
10556}
10557
Takashi Iwaib72519b2009-05-08 14:31:55 +020010558#define ALC262_HP_MASTER_SWITCH \
10559 { \
10560 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10561 .name = "Master Playback Switch", \
10562 .info = snd_ctl_boolean_mono_info, \
10563 .get = alc262_hp_master_sw_get, \
10564 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010565 }, \
10566 { \
10567 .iface = NID_MAPPING, \
10568 .name = "Master Playback Switch", \
10569 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020010570 }
10571
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010572
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010573static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010574 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010575 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10576 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10577 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010578 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10579 HDA_OUTPUT),
10580 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10581 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010582 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10583 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010584 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010585 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10586 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010587 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010588 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10589 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10590 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10591 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010592 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10593 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10594 { } /* end */
10595};
10596
Kailang Yangcd7509a2007-01-26 18:33:17 +010010597static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010598 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010599 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10600 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10601 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10602 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010603 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10604 HDA_OUTPUT),
10605 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10606 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010607 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10608 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010609 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010610 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10611 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10612 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10613 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010614 { } /* end */
10615};
10616
10617static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10618 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10619 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010620 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010621 { } /* end */
10622};
10623
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010624/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010625static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010626{
10627 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010628
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010629 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010010630 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010631}
10632
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010633static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010634 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10635 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010636 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10637 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10638 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10639 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10640 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10641 { } /* end */
10642};
10643
10644static struct hda_verb alc262_hp_t5735_verbs[] = {
10645 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10646 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10647
10648 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10649 { }
10650};
10651
Kailang Yang8c427222008-01-10 13:03:59 +010010652static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010653 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10654 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010655 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10656 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010657 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10658 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10659 { } /* end */
10660};
10661
10662static struct hda_verb alc262_hp_rp5700_verbs[] = {
10663 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10664 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10665 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10666 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10667 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10668 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10669 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10670 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10671 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10672 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10673 {}
10674};
10675
10676static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10677 .num_items = 1,
10678 .items = {
10679 { "Line", 0x1 },
10680 },
10681};
10682
Takashi Iwai42171c12009-05-08 14:11:43 +020010683/* bind hp and internal speaker mute (with plug check) as master switch */
10684static void alc262_hippo_master_update(struct hda_codec *codec)
10685{
10686 struct alc_spec *spec = codec->spec;
10687 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10688 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10689 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10690 unsigned int mute;
10691
10692 /* HP */
10693 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10694 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10695 HDA_AMP_MUTE, mute);
10696 /* mute internal speaker per jack sense */
10697 if (spec->jack_present)
10698 mute = HDA_AMP_MUTE;
10699 if (line_nid)
10700 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10701 HDA_AMP_MUTE, mute);
10702 if (speaker_nid && speaker_nid != line_nid)
10703 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10704 HDA_AMP_MUTE, mute);
10705}
10706
10707#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10708
10709static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10710 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010711{
10712 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010713 struct alc_spec *spec = codec->spec;
10714 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010715
Takashi Iwai42171c12009-05-08 14:11:43 +020010716 if (val == spec->master_sw)
10717 return 0;
10718 spec->master_sw = val;
10719 alc262_hippo_master_update(codec);
10720 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010721}
Takashi Iwai5b319542007-07-26 11:49:22 +020010722
Takashi Iwai42171c12009-05-08 14:11:43 +020010723#define ALC262_HIPPO_MASTER_SWITCH \
10724 { \
10725 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10726 .name = "Master Playback Switch", \
10727 .info = snd_ctl_boolean_mono_info, \
10728 .get = alc262_hippo_master_sw_get, \
10729 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010730 }, \
10731 { \
10732 .iface = NID_MAPPING, \
10733 .name = "Master Playback Switch", \
10734 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
10735 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020010736 }
10737
10738static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10739 ALC262_HIPPO_MASTER_SWITCH,
10740 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10741 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10742 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10743 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10744 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10745 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10746 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10747 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10748 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10749 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10750 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10751 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10752 { } /* end */
10753};
10754
10755static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10756 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10757 ALC262_HIPPO_MASTER_SWITCH,
10758 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10759 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10760 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10761 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10762 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10763 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10764 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10765 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10766 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10767 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10768 { } /* end */
10769};
10770
10771/* mute/unmute internal speaker according to the hp jack and mute state */
10772static void alc262_hippo_automute(struct hda_codec *codec)
10773{
10774 struct alc_spec *spec = codec->spec;
10775 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010776
Wu Fengguang864f92b2009-11-18 12:38:02 +080010777 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010778 alc262_hippo_master_update(codec);
10779}
10780
10781static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10782{
10783 if ((res >> 26) != ALC880_HP_EVENT)
10784 return;
10785 alc262_hippo_automute(codec);
10786}
10787
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010788static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010789{
10790 struct alc_spec *spec = codec->spec;
10791
10792 spec->autocfg.hp_pins[0] = 0x15;
10793 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010794}
10795
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010796static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010797{
10798 struct alc_spec *spec = codec->spec;
10799
10800 spec->autocfg.hp_pins[0] = 0x1b;
10801 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010802}
10803
10804
Kailang Yang272a5272007-05-14 11:00:38 +020010805static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010806 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010807 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10809 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10810 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10811 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10812 { } /* end */
10813};
10814
Kailang Yang83c34212007-07-05 11:43:05 +020010815static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010816 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10817 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010818 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10820 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10821 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10822 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10823 { } /* end */
10824};
Kailang Yang272a5272007-05-14 11:00:38 +020010825
Tony Vroonba340e82009-02-02 19:01:30 +000010826static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10827 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10828 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10829 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10830 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10831 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10832 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10834 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10835 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10836 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10837 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10838 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10839 { } /* end */
10840};
10841
10842static struct hda_verb alc262_tyan_verbs[] = {
10843 /* Headphone automute */
10844 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10845 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10846 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10847
10848 /* P11 AUX_IN, white 4-pin connector */
10849 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10850 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10851 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10852 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10853
10854 {}
10855};
10856
10857/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010858static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010859{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010860 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010861
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010862 spec->autocfg.hp_pins[0] = 0x1b;
10863 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010864}
10865
Tony Vroonba340e82009-02-02 19:01:30 +000010866
Kailang Yangdf694da2005-12-05 19:42:22 +010010867#define alc262_capture_mixer alc882_capture_mixer
10868#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10869
10870/*
10871 * generic initialization of ADC, input mixers and output mixers
10872 */
10873static struct hda_verb alc262_init_verbs[] = {
10874 /*
10875 * Unmute ADC0-2 and set the default input to mic-in
10876 */
10877 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10878 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10879 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10880 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10881 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10882 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10883
Takashi Iwaicb53c622007-08-10 17:21:45 +020010884 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010885 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010886 * Note: PASD motherboards uses the Line In 2 as the input for
10887 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010888 */
10889 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010890 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10891 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10892 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10893 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10894 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010895
10896 /*
10897 * Set up output mixers (0x0c - 0x0e)
10898 */
10899 /* set vol=0 to output mixers */
10900 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10901 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10902 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10903 /* set up input amps for analog loopback */
10904 /* Amp Indices: DAC = 0, mixer = 1 */
10905 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10906 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10907 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10908 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10909 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10910 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10911
10912 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10913 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10914 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10915 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10916 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10917 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10918
10919 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10920 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10921 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10922 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10923 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010924
Kailang Yangdf694da2005-12-05 19:42:22 +010010925 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10926 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010927
Kailang Yangdf694da2005-12-05 19:42:22 +010010928 /* FIXME: use matrix-type input source selection */
10929 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10930 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10931 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10932 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10933 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10934 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10935 /* Input mixer2 */
10936 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10937 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10938 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10939 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10940 /* Input mixer3 */
10941 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10942 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10943 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010944 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010945
10946 { }
10947};
10948
Kailang Yang4e555fe2008-08-26 13:05:55 +020010949static struct hda_verb alc262_eapd_verbs[] = {
10950 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10951 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10952 { }
10953};
10954
Kailang Yangccc656c2006-10-17 12:32:26 +020010955static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10956 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10957 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10958 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10959
10960 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10961 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10962 {}
10963};
10964
Kailang Yang272a5272007-05-14 11:00:38 +020010965static struct hda_verb alc262_sony_unsol_verbs[] = {
10966 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10967 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10968 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10969
10970 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10971 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010972 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010973};
10974
Kailang Yang4e555fe2008-08-26 13:05:55 +020010975static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10976 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10977 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10978 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10979 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10980 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010981 { } /* end */
10982};
10983
10984static struct hda_verb alc262_toshiba_s06_verbs[] = {
10985 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10986 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10987 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10988 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10989 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10990 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10991 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10992 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10993 {}
10994};
10995
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010996static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010997{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010998 struct alc_spec *spec = codec->spec;
10999
11000 spec->autocfg.hp_pins[0] = 0x15;
11001 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011002 spec->ext_mic.pin = 0x18;
11003 spec->ext_mic.mux_idx = 0;
11004 spec->int_mic.pin = 0x12;
11005 spec->int_mic.mux_idx = 9;
11006 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011007}
11008
Takashi Iwai834be882006-03-01 14:16:17 +010011009/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011010 * nec model
11011 * 0x15 = headphone
11012 * 0x16 = internal speaker
11013 * 0x18 = external mic
11014 */
11015
11016static struct snd_kcontrol_new alc262_nec_mixer[] = {
11017 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11018 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11019
11020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11021 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11022 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11023
11024 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11025 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11026 { } /* end */
11027};
11028
11029static struct hda_verb alc262_nec_verbs[] = {
11030 /* Unmute Speaker */
11031 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11032
11033 /* Headphone */
11034 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11035 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11036
11037 /* External mic to headphone */
11038 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11039 /* External mic to speaker */
11040 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11041 {}
11042};
11043
11044/*
Takashi Iwai834be882006-03-01 14:16:17 +010011045 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011046 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11047 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011048 */
11049
11050#define ALC_HP_EVENT 0x37
11051
11052static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11053 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11054 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011055 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11056 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011057 {}
11058};
11059
Jiang zhe0e31daf2008-03-20 12:12:39 +010011060static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11061 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11062 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11063 {}
11064};
11065
Daniel T Chene2595322009-12-19 18:19:02 -050011066static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11067 /* Front Mic pin: input vref at 50% */
11068 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11069 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11070 {}
11071};
11072
Takashi Iwai834be882006-03-01 14:16:17 +010011073static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011074 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011075 .items = {
11076 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011077 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011078 { "CD", 0x4 },
11079 },
11080};
11081
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011082static struct hda_input_mux alc262_HP_capture_source = {
11083 .num_items = 5,
11084 .items = {
11085 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011086 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011087 { "Line", 0x2 },
11088 { "CD", 0x4 },
11089 { "AUX IN", 0x6 },
11090 },
11091};
11092
zhejiangaccbe492007-08-31 12:36:05 +020011093static struct hda_input_mux alc262_HP_D7000_capture_source = {
11094 .num_items = 4,
11095 .items = {
11096 { "Mic", 0x0 },
11097 { "Front Mic", 0x2 },
11098 { "Line", 0x1 },
11099 { "CD", 0x4 },
11100 },
11101};
11102
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011103/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011104static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11105{
11106 struct alc_spec *spec = codec->spec;
11107 unsigned int mute;
11108
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011109 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011110 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11111 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011112 spec->sense_updated = 1;
11113 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011114 /* unmute internal speaker only if both HPs are unplugged and
11115 * master switch is on
11116 */
11117 if (spec->jack_present)
11118 mute = HDA_AMP_MUTE;
11119 else
Takashi Iwai834be882006-03-01 14:16:17 +010011120 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011121 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11122 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011123}
11124
11125/* unsolicited event for HP jack sensing */
11126static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11127 unsigned int res)
11128{
11129 if ((res >> 26) != ALC_HP_EVENT)
11130 return;
11131 alc262_fujitsu_automute(codec, 1);
11132}
11133
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011134static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11135{
11136 alc262_fujitsu_automute(codec, 1);
11137}
11138
Takashi Iwai834be882006-03-01 14:16:17 +010011139/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011140static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11141 .ops = &snd_hda_bind_vol,
11142 .values = {
11143 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11144 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11145 0
11146 },
11147};
Takashi Iwai834be882006-03-01 14:16:17 +010011148
Jiang zhe0e31daf2008-03-20 12:12:39 +010011149/* mute/unmute internal speaker according to the hp jack and mute state */
11150static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11151{
11152 struct alc_spec *spec = codec->spec;
11153 unsigned int mute;
11154
11155 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011156 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011157 spec->sense_updated = 1;
11158 }
11159 if (spec->jack_present) {
11160 /* mute internal speaker */
11161 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11162 HDA_AMP_MUTE, HDA_AMP_MUTE);
11163 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11164 HDA_AMP_MUTE, HDA_AMP_MUTE);
11165 } else {
11166 /* unmute internal speaker if necessary */
11167 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11168 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11169 HDA_AMP_MUTE, mute);
11170 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11171 HDA_AMP_MUTE, mute);
11172 }
11173}
11174
11175/* unsolicited event for HP jack sensing */
11176static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11177 unsigned int res)
11178{
11179 if ((res >> 26) != ALC_HP_EVENT)
11180 return;
11181 alc262_lenovo_3000_automute(codec, 1);
11182}
11183
Takashi Iwai8de56b72009-07-24 16:51:47 +020011184static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11185 int dir, int idx, long *valp)
11186{
11187 int i, change = 0;
11188
11189 for (i = 0; i < 2; i++, valp++)
11190 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11191 HDA_AMP_MUTE,
11192 *valp ? 0 : HDA_AMP_MUTE);
11193 return change;
11194}
11195
Takashi Iwai834be882006-03-01 14:16:17 +010011196/* bind hp and internal speaker mute (with plug check) */
11197static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11198 struct snd_ctl_elem_value *ucontrol)
11199{
11200 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11201 long *valp = ucontrol->value.integer.value;
11202 int change;
11203
Takashi Iwai8de56b72009-07-24 16:51:47 +020011204 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11205 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011206 if (change)
11207 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011208 return change;
11209}
11210
11211static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011212 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011213 {
11214 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11215 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011216 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011217 .info = snd_hda_mixer_amp_switch_info,
11218 .get = snd_hda_mixer_amp_switch_get,
11219 .put = alc262_fujitsu_master_sw_put,
11220 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11221 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011222 {
11223 .iface = NID_MAPPING,
11224 .name = "Master Playback Switch",
11225 .private_value = 0x1b,
11226 },
Takashi Iwai834be882006-03-01 14:16:17 +010011227 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11228 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11229 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11230 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11231 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011232 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11233 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11234 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011235 { } /* end */
11236};
11237
Jiang zhe0e31daf2008-03-20 12:12:39 +010011238/* bind hp and internal speaker mute (with plug check) */
11239static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11240 struct snd_ctl_elem_value *ucontrol)
11241{
11242 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11243 long *valp = ucontrol->value.integer.value;
11244 int change;
11245
Takashi Iwai8de56b72009-07-24 16:51:47 +020011246 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011247 if (change)
11248 alc262_lenovo_3000_automute(codec, 0);
11249 return change;
11250}
11251
11252static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11253 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11254 {
11255 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11256 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011257 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011258 .info = snd_hda_mixer_amp_switch_info,
11259 .get = snd_hda_mixer_amp_switch_get,
11260 .put = alc262_lenovo_3000_master_sw_put,
11261 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11262 },
11263 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11264 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11265 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11266 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11267 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11268 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11269 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11270 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11271 { } /* end */
11272};
11273
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011274static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11275 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011276 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011277 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11278 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11279 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11280 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11281 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11282 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11283 { } /* end */
11284};
11285
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011286/* additional init verbs for Benq laptops */
11287static struct hda_verb alc262_EAPD_verbs[] = {
11288 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11289 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11290 {}
11291};
11292
Kailang Yang83c34212007-07-05 11:43:05 +020011293static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11294 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11295 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11296
11297 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11298 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11299 {}
11300};
11301
Tobin Davisf651b502007-10-26 12:40:47 +020011302/* Samsung Q1 Ultra Vista model setup */
11303static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011304 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11305 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011306 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11307 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11308 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011309 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011310 { } /* end */
11311};
11312
11313static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011314 /* output mixer */
11315 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11316 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11317 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11318 /* speaker */
11319 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11320 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11321 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11322 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11323 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011324 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011325 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11326 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11327 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11328 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11329 /* internal mic */
11330 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11331 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11332 /* ADC, choose mic */
11333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11334 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11335 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11336 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11337 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11338 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11339 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11340 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11341 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11342 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011343 {}
11344};
11345
Tobin Davisf651b502007-10-26 12:40:47 +020011346/* mute/unmute internal speaker according to the hp jack and mute state */
11347static void alc262_ultra_automute(struct hda_codec *codec)
11348{
11349 struct alc_spec *spec = codec->spec;
11350 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011351
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011352 mute = 0;
11353 /* auto-mute only when HP is used as HP */
11354 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011355 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011356 if (spec->jack_present)
11357 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011358 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011359 /* mute/unmute internal speaker */
11360 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11361 HDA_AMP_MUTE, mute);
11362 /* mute/unmute HP */
11363 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11364 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011365}
11366
11367/* unsolicited event for HP jack sensing */
11368static void alc262_ultra_unsol_event(struct hda_codec *codec,
11369 unsigned int res)
11370{
11371 if ((res >> 26) != ALC880_HP_EVENT)
11372 return;
11373 alc262_ultra_automute(codec);
11374}
11375
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011376static struct hda_input_mux alc262_ultra_capture_source = {
11377 .num_items = 2,
11378 .items = {
11379 { "Mic", 0x1 },
11380 { "Headphone", 0x7 },
11381 },
11382};
11383
11384static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11385 struct snd_ctl_elem_value *ucontrol)
11386{
11387 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11388 struct alc_spec *spec = codec->spec;
11389 int ret;
11390
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011391 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011392 if (!ret)
11393 return 0;
11394 /* reprogram the HP pin as mic or HP according to the input source */
11395 snd_hda_codec_write_cache(codec, 0x15, 0,
11396 AC_VERB_SET_PIN_WIDGET_CONTROL,
11397 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11398 alc262_ultra_automute(codec); /* mute/unmute HP */
11399 return ret;
11400}
11401
11402static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11403 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11404 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11405 {
11406 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11407 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011408 .info = alc_mux_enum_info,
11409 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011410 .put = alc262_ultra_mux_enum_put,
11411 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011412 {
11413 .iface = NID_MAPPING,
11414 .name = "Capture Source",
11415 .private_value = 0x15,
11416 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011417 { } /* end */
11418};
11419
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011420/* We use two mixers depending on the output pin; 0x16 is a mono output
11421 * and thus it's bound with a different mixer.
11422 * This function returns which mixer amp should be used.
11423 */
11424static int alc262_check_volbit(hda_nid_t nid)
11425{
11426 if (!nid)
11427 return 0;
11428 else if (nid == 0x16)
11429 return 2;
11430 else
11431 return 1;
11432}
11433
11434static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11435 const char *pfx, int *vbits)
11436{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011437 unsigned long val;
11438 int vbit;
11439
11440 vbit = alc262_check_volbit(nid);
11441 if (!vbit)
11442 return 0;
11443 if (*vbits & vbit) /* a volume control for this mixer already there */
11444 return 0;
11445 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011446 if (vbit == 2)
11447 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11448 else
11449 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011450 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011451}
11452
11453static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11454 const char *pfx)
11455{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011456 unsigned long val;
11457
11458 if (!nid)
11459 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011460 if (nid == 0x16)
11461 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11462 else
11463 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011464 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011465}
11466
Kailang Yangdf694da2005-12-05 19:42:22 +010011467/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011468static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11469 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011470{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011471 const char *pfx;
11472 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011473 int err;
11474
11475 spec->multiout.num_dacs = 1; /* only use one dac */
11476 spec->multiout.dac_nids = spec->private_dac_nids;
11477 spec->multiout.dac_nids[0] = 2;
11478
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011479 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11480 pfx = "Master";
11481 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11482 pfx = "Speaker";
11483 else
11484 pfx = "Front";
11485 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11486 if (err < 0)
11487 return err;
11488 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11489 if (err < 0)
11490 return err;
11491 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11492 if (err < 0)
11493 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011494
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011495 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11496 alc262_check_volbit(cfg->speaker_pins[0]) |
11497 alc262_check_volbit(cfg->hp_pins[0]);
11498 if (vbits == 1 || vbits == 2)
11499 pfx = "Master"; /* only one mixer is used */
11500 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11501 pfx = "Speaker";
11502 else
11503 pfx = "Front";
11504 vbits = 0;
11505 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11506 if (err < 0)
11507 return err;
11508 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11509 &vbits);
11510 if (err < 0)
11511 return err;
11512 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11513 &vbits);
11514 if (err < 0)
11515 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011516 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011517}
11518
Takashi Iwai05f5f472009-08-25 13:10:18 +020011519#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011520 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011521
11522/*
11523 * generic initialization of ADC, input mixers and output mixers
11524 */
11525static struct hda_verb alc262_volume_init_verbs[] = {
11526 /*
11527 * Unmute ADC0-2 and set the default input to mic-in
11528 */
11529 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11530 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11531 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11532 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11533 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11534 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11535
Takashi Iwaicb53c622007-08-10 17:21:45 +020011536 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011537 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011538 * Note: PASD motherboards uses the Line In 2 as the input for
11539 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011540 */
11541 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11544 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011547
11548 /*
11549 * Set up output mixers (0x0c - 0x0f)
11550 */
11551 /* set vol=0 to output mixers */
11552 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11553 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11554 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011555
Kailang Yangdf694da2005-12-05 19:42:22 +010011556 /* set up input amps for analog loopback */
11557 /* Amp Indices: DAC = 0, mixer = 1 */
11558 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11559 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11560 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11561 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11562 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11563 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11564
11565 /* FIXME: use matrix-type input source selection */
11566 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11567 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11568 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11569 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11570 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11571 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11572 /* Input mixer2 */
11573 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11574 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11575 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11576 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11577 /* Input mixer3 */
11578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11579 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11580 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11581 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11582
11583 { }
11584};
11585
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011586static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11587 /*
11588 * Unmute ADC0-2 and set the default input to mic-in
11589 */
11590 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11591 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11592 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11593 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11594 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11595 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11596
Takashi Iwaicb53c622007-08-10 17:21:45 +020011597 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011598 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011599 * Note: PASD motherboards uses the Line In 2 as the input for
11600 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011601 */
11602 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011603 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11604 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11605 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11606 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11607 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11608 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11609 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011610
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011611 /*
11612 * Set up output mixers (0x0c - 0x0e)
11613 */
11614 /* set vol=0 to output mixers */
11615 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11616 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11617 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11618
11619 /* set up input amps for analog loopback */
11620 /* Amp Indices: DAC = 0, mixer = 1 */
11621 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11622 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11623 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11624 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11625 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11626 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11627
Takashi Iwaice875f02008-01-28 18:17:43 +010011628 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011629 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11630 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11631
11632 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11633 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11634
11635 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11636 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11637
11638 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11639 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11640 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11641 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11642 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11643
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011644 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011645 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11646 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011647 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011648 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11649 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11650
11651
11652 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011653 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11654 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011655 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011656 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11657 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11658 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11659 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11660 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11661 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11662 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11663 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011664 /* Input mixer2 */
11665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011666 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11667 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11668 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11669 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11670 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11671 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11672 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11673 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011674 /* Input mixer3 */
11675 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011676 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11677 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11678 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11679 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11680 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11681 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11682 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11683 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011684
Takashi Iwaice875f02008-01-28 18:17:43 +010011685 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11686
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011687 { }
11688};
11689
Kailang Yangcd7509a2007-01-26 18:33:17 +010011690static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11691 /*
11692 * Unmute ADC0-2 and set the default input to mic-in
11693 */
11694 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11695 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11696 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11697 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11698 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11699 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11700
Takashi Iwaicb53c622007-08-10 17:21:45 +020011701 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011702 * mixer widget
11703 * Note: PASD motherboards uses the Line In 2 as the input for front
11704 * panel mic (mic 2)
11705 */
11706 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011707 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11708 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11709 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11710 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11711 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11712 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11713 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11714 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011715 /*
11716 * Set up output mixers (0x0c - 0x0e)
11717 */
11718 /* set vol=0 to output mixers */
11719 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11720 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11721 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11722
11723 /* set up input amps for analog loopback */
11724 /* Amp Indices: DAC = 0, mixer = 1 */
11725 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11726 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11727 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11728 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11729 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11730 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11731
11732
11733 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11734 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11735 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11736 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11737 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11738 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11739 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11740
11741 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11742 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11743
11744 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11745 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11746
11747 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11748 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11749 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11750 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11751 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11752 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11753
11754 /* FIXME: use matrix-type input source selection */
11755 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11756 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11757 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11758 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11759 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11760 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11761 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11762 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11763 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11764 /* Input mixer2 */
11765 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11766 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11767 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11768 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11769 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11770 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11771 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11772 /* Input mixer3 */
11773 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11774 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11775 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11776 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11778 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11779 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11780
Takashi Iwaice875f02008-01-28 18:17:43 +010011781 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11782
Kailang Yangcd7509a2007-01-26 18:33:17 +010011783 { }
11784};
11785
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011786static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11787
11788 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11789 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11790 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11791
11792 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11793 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11794 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11795 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11796
11797 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11798 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11799 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11800 {}
11801};
11802
11803
Takashi Iwaicb53c622007-08-10 17:21:45 +020011804#ifdef CONFIG_SND_HDA_POWER_SAVE
11805#define alc262_loopbacks alc880_loopbacks
11806#endif
11807
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011808/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011809#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11810#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11811#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11812#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11813
11814/*
11815 * BIOS auto configuration
11816 */
11817static int alc262_parse_auto_config(struct hda_codec *codec)
11818{
11819 struct alc_spec *spec = codec->spec;
11820 int err;
11821 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11822
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011823 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11824 alc262_ignore);
11825 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011826 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011827 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011828 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011829 spec->multiout.max_channels = 2;
11830 spec->no_analog = 1;
11831 goto dig_only;
11832 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011833 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011834 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011835 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11836 if (err < 0)
11837 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011838 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011839 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011840 return err;
11841
11842 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11843
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011844 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011845 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011846 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011847 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011848 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011849 if (spec->autocfg.dig_in_pin)
11850 spec->dig_in_nid = ALC262_DIGIN_NID;
11851
Takashi Iwai603c4012008-07-30 15:01:44 +020011852 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011853 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011854
Takashi Iwaid88897e2008-10-31 15:01:37 +010011855 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011856 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011857 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011858
Takashi Iwai776e1842007-08-29 15:07:11 +020011859 err = alc_auto_add_mic_boost(codec);
11860 if (err < 0)
11861 return err;
11862
Kailang Yang6227cdc2010-02-25 08:36:52 +010011863 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011864
Kailang Yangdf694da2005-12-05 19:42:22 +010011865 return 1;
11866}
11867
11868#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11869#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11870#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011871#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011872
11873
11874/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011875static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011876{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011877 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011878 alc262_auto_init_multi_out(codec);
11879 alc262_auto_init_hp_out(codec);
11880 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011881 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011882 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011883 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011884}
11885
11886/*
11887 * configuration and preset
11888 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011889static const char *alc262_models[ALC262_MODEL_LAST] = {
11890 [ALC262_BASIC] = "basic",
11891 [ALC262_HIPPO] = "hippo",
11892 [ALC262_HIPPO_1] = "hippo_1",
11893 [ALC262_FUJITSU] = "fujitsu",
11894 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011895 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011896 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011897 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011898 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011899 [ALC262_BENQ_T31] = "benq-t31",
11900 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011901 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011902 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011903 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011904 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011905 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011906 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011907 [ALC262_AUTO] = "auto",
11908};
11909
11910static struct snd_pci_quirk alc262_cfg_tbl[] = {
11911 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011912 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011913 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11914 ALC262_HP_BPC),
11915 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11916 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011917 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11918 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011919 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011920 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011921 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011922 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011923 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011924 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011925 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011926 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011927 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11928 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11929 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011930 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11931 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011932 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011933 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011934 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011935 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011936 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011937 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050011938 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010011939 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011940#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010011941 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11942 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011943#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090011944 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011945 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011946 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011947 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011948 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011949 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011950 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11951 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011952 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011953 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011954 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011955 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011956 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011957 {}
11958};
11959
11960static struct alc_config_preset alc262_presets[] = {
11961 [ALC262_BASIC] = {
11962 .mixers = { alc262_base_mixer },
11963 .init_verbs = { alc262_init_verbs },
11964 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11965 .dac_nids = alc262_dac_nids,
11966 .hp_nid = 0x03,
11967 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11968 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011969 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011970 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011971 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011972 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011973 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011974 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11975 .dac_nids = alc262_dac_nids,
11976 .hp_nid = 0x03,
11977 .dig_out_nid = ALC262_DIGOUT_NID,
11978 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11979 .channel_mode = alc262_modes,
11980 .input_mux = &alc262_capture_source,
11981 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011982 .setup = alc262_hippo_setup,
11983 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011984 },
11985 [ALC262_HIPPO_1] = {
11986 .mixers = { alc262_hippo1_mixer },
11987 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11988 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11989 .dac_nids = alc262_dac_nids,
11990 .hp_nid = 0x02,
11991 .dig_out_nid = ALC262_DIGOUT_NID,
11992 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11993 .channel_mode = alc262_modes,
11994 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011995 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011996 .setup = alc262_hippo1_setup,
11997 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011998 },
Takashi Iwai834be882006-03-01 14:16:17 +010011999 [ALC262_FUJITSU] = {
12000 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012001 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12002 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012003 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12004 .dac_nids = alc262_dac_nids,
12005 .hp_nid = 0x03,
12006 .dig_out_nid = ALC262_DIGOUT_NID,
12007 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12008 .channel_mode = alc262_modes,
12009 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012010 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012011 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012012 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012013 [ALC262_HP_BPC] = {
12014 .mixers = { alc262_HP_BPC_mixer },
12015 .init_verbs = { alc262_HP_BPC_init_verbs },
12016 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12017 .dac_nids = alc262_dac_nids,
12018 .hp_nid = 0x03,
12019 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12020 .channel_mode = alc262_modes,
12021 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012022 .unsol_event = alc262_hp_bpc_unsol_event,
12023 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012024 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012025 [ALC262_HP_BPC_D7000_WF] = {
12026 .mixers = { alc262_HP_BPC_WildWest_mixer },
12027 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12028 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12029 .dac_nids = alc262_dac_nids,
12030 .hp_nid = 0x03,
12031 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12032 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012033 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012034 .unsol_event = alc262_hp_wildwest_unsol_event,
12035 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012036 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012037 [ALC262_HP_BPC_D7000_WL] = {
12038 .mixers = { alc262_HP_BPC_WildWest_mixer,
12039 alc262_HP_BPC_WildWest_option_mixer },
12040 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12041 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12042 .dac_nids = alc262_dac_nids,
12043 .hp_nid = 0x03,
12044 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12045 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012046 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012047 .unsol_event = alc262_hp_wildwest_unsol_event,
12048 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012049 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012050 [ALC262_HP_TC_T5735] = {
12051 .mixers = { alc262_hp_t5735_mixer },
12052 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12053 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12054 .dac_nids = alc262_dac_nids,
12055 .hp_nid = 0x03,
12056 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12057 .channel_mode = alc262_modes,
12058 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012059 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012060 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012061 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012062 },
12063 [ALC262_HP_RP5700] = {
12064 .mixers = { alc262_hp_rp5700_mixer },
12065 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12066 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12067 .dac_nids = alc262_dac_nids,
12068 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12069 .channel_mode = alc262_modes,
12070 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012071 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012072 [ALC262_BENQ_ED8] = {
12073 .mixers = { alc262_base_mixer },
12074 .init_verbs = { alc262_init_verbs, alc262_EAPD_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,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012081 },
Kailang Yang272a5272007-05-14 11:00:38 +020012082 [ALC262_SONY_ASSAMD] = {
12083 .mixers = { alc262_sony_mixer },
12084 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12085 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12086 .dac_nids = alc262_dac_nids,
12087 .hp_nid = 0x02,
12088 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12089 .channel_mode = alc262_modes,
12090 .input_mux = &alc262_capture_source,
12091 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012092 .setup = alc262_hippo_setup,
12093 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012094 },
12095 [ALC262_BENQ_T31] = {
12096 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012097 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12098 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012099 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12100 .dac_nids = alc262_dac_nids,
12101 .hp_nid = 0x03,
12102 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12103 .channel_mode = alc262_modes,
12104 .input_mux = &alc262_capture_source,
12105 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012106 .setup = alc262_hippo_setup,
12107 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012108 },
Tobin Davisf651b502007-10-26 12:40:47 +020012109 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012110 .mixers = { alc262_ultra_mixer },
12111 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012112 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012113 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12114 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012115 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12116 .channel_mode = alc262_modes,
12117 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012118 .adc_nids = alc262_adc_nids, /* ADC0 */
12119 .capsrc_nids = alc262_capsrc_nids,
12120 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012121 .unsol_event = alc262_ultra_unsol_event,
12122 .init_hook = alc262_ultra_automute,
12123 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012124 [ALC262_LENOVO_3000] = {
12125 .mixers = { alc262_lenovo_3000_mixer },
12126 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012127 alc262_lenovo_3000_unsol_verbs,
12128 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012129 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12130 .dac_nids = alc262_dac_nids,
12131 .hp_nid = 0x03,
12132 .dig_out_nid = ALC262_DIGOUT_NID,
12133 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12134 .channel_mode = alc262_modes,
12135 .input_mux = &alc262_fujitsu_capture_source,
12136 .unsol_event = alc262_lenovo_3000_unsol_event,
12137 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012138 [ALC262_NEC] = {
12139 .mixers = { alc262_nec_mixer },
12140 .init_verbs = { alc262_nec_verbs },
12141 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12142 .dac_nids = alc262_dac_nids,
12143 .hp_nid = 0x03,
12144 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12145 .channel_mode = alc262_modes,
12146 .input_mux = &alc262_capture_source,
12147 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012148 [ALC262_TOSHIBA_S06] = {
12149 .mixers = { alc262_toshiba_s06_mixer },
12150 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12151 alc262_eapd_verbs },
12152 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12153 .capsrc_nids = alc262_dmic_capsrc_nids,
12154 .dac_nids = alc262_dac_nids,
12155 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012156 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012157 .dig_out_nid = ALC262_DIGOUT_NID,
12158 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12159 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012160 .unsol_event = alc_sku_unsol_event,
12161 .setup = alc262_toshiba_s06_setup,
12162 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012163 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012164 [ALC262_TOSHIBA_RX1] = {
12165 .mixers = { alc262_toshiba_rx1_mixer },
12166 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12167 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12168 .dac_nids = alc262_dac_nids,
12169 .hp_nid = 0x03,
12170 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12171 .channel_mode = alc262_modes,
12172 .input_mux = &alc262_capture_source,
12173 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012174 .setup = alc262_hippo_setup,
12175 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012176 },
Tony Vroonba340e82009-02-02 19:01:30 +000012177 [ALC262_TYAN] = {
12178 .mixers = { alc262_tyan_mixer },
12179 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12180 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12181 .dac_nids = alc262_dac_nids,
12182 .hp_nid = 0x02,
12183 .dig_out_nid = ALC262_DIGOUT_NID,
12184 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12185 .channel_mode = alc262_modes,
12186 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012187 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012188 .setup = alc262_tyan_setup,
12189 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012190 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012191};
12192
12193static int patch_alc262(struct hda_codec *codec)
12194{
12195 struct alc_spec *spec;
12196 int board_config;
12197 int err;
12198
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012199 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012200 if (spec == NULL)
12201 return -ENOMEM;
12202
12203 codec->spec = spec;
12204#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012205 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12206 * under-run
12207 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012208 {
12209 int tmp;
12210 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12211 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12212 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12213 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12214 }
12215#endif
12216
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012217 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12218
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012219 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12220 alc262_models,
12221 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012222
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012223 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012224 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12225 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012226 board_config = ALC262_AUTO;
12227 }
12228
12229 if (board_config == ALC262_AUTO) {
12230 /* automatic parse from the BIOS config */
12231 err = alc262_parse_auto_config(codec);
12232 if (err < 0) {
12233 alc_free(codec);
12234 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012235 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012236 printk(KERN_INFO
12237 "hda_codec: Cannot set up configuration "
12238 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012239 board_config = ALC262_BASIC;
12240 }
12241 }
12242
Takashi Iwai07eba612009-02-19 08:06:35 +010012243 if (!spec->no_analog) {
12244 err = snd_hda_attach_beep_device(codec, 0x1);
12245 if (err < 0) {
12246 alc_free(codec);
12247 return err;
12248 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012249 }
12250
Kailang Yangdf694da2005-12-05 19:42:22 +010012251 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012252 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012253
Kailang Yangdf694da2005-12-05 19:42:22 +010012254 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12255 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012256
Kailang Yangdf694da2005-12-05 19:42:22 +010012257 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12258 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12259
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012260 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012261 int i;
12262 /* check whether the digital-mic has to be supported */
12263 for (i = 0; i < spec->input_mux->num_items; i++) {
12264 if (spec->input_mux->items[i].index >= 9)
12265 break;
12266 }
12267 if (i < spec->input_mux->num_items) {
12268 /* use only ADC0 */
12269 spec->adc_nids = alc262_dmic_adc_nids;
12270 spec->num_adc_nids = 1;
12271 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012272 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012273 /* all analog inputs */
12274 /* check whether NID 0x07 is valid */
12275 unsigned int wcap = get_wcaps(codec, 0x07);
12276
12277 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012278 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012279 if (wcap != AC_WID_AUD_IN) {
12280 spec->adc_nids = alc262_adc_nids_alt;
12281 spec->num_adc_nids =
12282 ARRAY_SIZE(alc262_adc_nids_alt);
12283 spec->capsrc_nids = alc262_capsrc_nids_alt;
12284 } else {
12285 spec->adc_nids = alc262_adc_nids;
12286 spec->num_adc_nids =
12287 ARRAY_SIZE(alc262_adc_nids);
12288 spec->capsrc_nids = alc262_capsrc_nids;
12289 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012290 }
12291 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012292 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012293 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010012294 if (!spec->no_analog)
12295 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012296
Takashi Iwai2134ea42008-01-10 16:53:55 +010012297 spec->vmaster_nid = 0x0c;
12298
Kailang Yangdf694da2005-12-05 19:42:22 +010012299 codec->patch_ops = alc_patch_ops;
12300 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012301 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012302#ifdef CONFIG_SND_HDA_POWER_SAVE
12303 if (!spec->loopback.amplist)
12304 spec->loopback.amplist = alc262_loopbacks;
12305#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012306
Kailang Yangdf694da2005-12-05 19:42:22 +010012307 return 0;
12308}
12309
Kailang Yangdf694da2005-12-05 19:42:22 +010012310/*
Kailang Yanga361d842007-06-05 12:30:55 +020012311 * ALC268 channel source setting (2 channel)
12312 */
12313#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12314#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012315
Kailang Yanga361d842007-06-05 12:30:55 +020012316static hda_nid_t alc268_dac_nids[2] = {
12317 /* front, hp */
12318 0x02, 0x03
12319};
12320
12321static hda_nid_t alc268_adc_nids[2] = {
12322 /* ADC0-1 */
12323 0x08, 0x07
12324};
12325
12326static hda_nid_t alc268_adc_nids_alt[1] = {
12327 /* ADC0 */
12328 0x08
12329};
12330
Takashi Iwaie1406342008-02-11 18:32:32 +010012331static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12332
Kailang Yanga361d842007-06-05 12:30:55 +020012333static struct snd_kcontrol_new alc268_base_mixer[] = {
12334 /* output mixer control */
12335 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12336 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12337 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12338 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012339 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12340 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12341 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012342 { }
12343};
12344
Takashi Iwai42171c12009-05-08 14:11:43 +020012345static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12346 /* output mixer control */
12347 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12348 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12349 ALC262_HIPPO_MASTER_SWITCH,
12350 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12351 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12352 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12353 { }
12354};
12355
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012356/* bind Beep switches of both NID 0x0f and 0x10 */
12357static struct hda_bind_ctls alc268_bind_beep_sw = {
12358 .ops = &snd_hda_bind_sw,
12359 .values = {
12360 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12361 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12362 0
12363 },
12364};
12365
12366static struct snd_kcontrol_new alc268_beep_mixer[] = {
12367 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12368 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12369 { }
12370};
12371
Kailang Yangd1a991a2007-08-15 16:21:59 +020012372static struct hda_verb alc268_eapd_verbs[] = {
12373 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12374 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12375 { }
12376};
12377
Takashi Iwaid2738092007-08-16 14:59:45 +020012378/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012379static struct hda_verb alc268_toshiba_verbs[] = {
12380 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12381 { } /* end */
12382};
12383
12384/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012385/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012386static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12387 .ops = &snd_hda_bind_vol,
12388 .values = {
12389 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12390 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12391 0
12392 },
12393};
12394
Takashi Iwai889c4392007-08-23 18:56:52 +020012395/* mute/unmute internal speaker according to the hp jack and mute state */
12396static void alc268_acer_automute(struct hda_codec *codec, int force)
12397{
12398 struct alc_spec *spec = codec->spec;
12399 unsigned int mute;
12400
12401 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012402 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012403 spec->sense_updated = 1;
12404 }
12405 if (spec->jack_present)
12406 mute = HDA_AMP_MUTE; /* mute internal speaker */
12407 else /* unmute internal speaker if necessary */
12408 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12409 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12410 HDA_AMP_MUTE, mute);
12411}
12412
12413
12414/* bind hp and internal speaker mute (with plug check) */
12415static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12416 struct snd_ctl_elem_value *ucontrol)
12417{
12418 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12419 long *valp = ucontrol->value.integer.value;
12420 int change;
12421
Takashi Iwai8de56b72009-07-24 16:51:47 +020012422 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012423 if (change)
12424 alc268_acer_automute(codec, 0);
12425 return change;
12426}
Takashi Iwaid2738092007-08-16 14:59:45 +020012427
Kailang Yang8ef355d2008-08-26 13:10:22 +020012428static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12429 /* output mixer control */
12430 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12431 {
12432 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12433 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012434 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012435 .info = snd_hda_mixer_amp_switch_info,
12436 .get = snd_hda_mixer_amp_switch_get,
12437 .put = alc268_acer_master_sw_put,
12438 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12439 },
12440 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12441 { }
12442};
12443
Takashi Iwaid2738092007-08-16 14:59:45 +020012444static struct snd_kcontrol_new alc268_acer_mixer[] = {
12445 /* output mixer control */
12446 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12447 {
12448 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12449 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012450 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012451 .info = snd_hda_mixer_amp_switch_info,
12452 .get = snd_hda_mixer_amp_switch_get,
12453 .put = alc268_acer_master_sw_put,
12454 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12455 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012456 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12457 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12458 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012459 { }
12460};
12461
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012462static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12463 /* output mixer control */
12464 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12465 {
12466 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12467 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012468 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012469 .info = snd_hda_mixer_amp_switch_info,
12470 .get = snd_hda_mixer_amp_switch_get,
12471 .put = alc268_acer_master_sw_put,
12472 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12473 },
12474 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12475 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12476 { }
12477};
12478
Kailang Yang8ef355d2008-08-26 13:10:22 +020012479static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12480 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12481 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12482 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12483 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12484 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12485 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12486 { }
12487};
12488
Takashi Iwaid2738092007-08-16 14:59:45 +020012489static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012490 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12491 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012492 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12493 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012494 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12495 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012496 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12497 { }
12498};
12499
12500/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012501#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012502#define alc268_toshiba_setup alc262_hippo_setup
12503#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012504
12505static void alc268_acer_unsol_event(struct hda_codec *codec,
12506 unsigned int res)
12507{
Takashi Iwai889c4392007-08-23 18:56:52 +020012508 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012509 return;
12510 alc268_acer_automute(codec, 1);
12511}
12512
Takashi Iwai889c4392007-08-23 18:56:52 +020012513static void alc268_acer_init_hook(struct hda_codec *codec)
12514{
12515 alc268_acer_automute(codec, 1);
12516}
12517
Kailang Yang8ef355d2008-08-26 13:10:22 +020012518/* toggle speaker-output according to the hp-jack state */
12519static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12520{
12521 unsigned int present;
12522 unsigned char bits;
12523
Wu Fengguang864f92b2009-11-18 12:38:02 +080012524 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012525 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012526 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012527 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012528 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012529 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012530}
12531
Kailang Yang8ef355d2008-08-26 13:10:22 +020012532static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12533 unsigned int res)
12534{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012535 switch (res >> 26) {
12536 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012537 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012538 break;
12539 case ALC880_MIC_EVENT:
12540 alc_mic_automute(codec);
12541 break;
12542 }
12543}
12544
12545static void alc268_acer_lc_setup(struct hda_codec *codec)
12546{
12547 struct alc_spec *spec = codec->spec;
12548 spec->ext_mic.pin = 0x18;
12549 spec->ext_mic.mux_idx = 0;
12550 spec->int_mic.pin = 0x12;
12551 spec->int_mic.mux_idx = 6;
12552 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012553}
12554
12555static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12556{
12557 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012558 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012559}
12560
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012561static struct snd_kcontrol_new alc268_dell_mixer[] = {
12562 /* output mixer control */
12563 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12564 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12565 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12566 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12567 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12568 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12569 { }
12570};
12571
12572static struct hda_verb alc268_dell_verbs[] = {
12573 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12574 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12575 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012576 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012577 { }
12578};
12579
12580/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012581static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012582{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012583 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012584
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012585 spec->autocfg.hp_pins[0] = 0x15;
12586 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012587 spec->ext_mic.pin = 0x18;
12588 spec->ext_mic.mux_idx = 0;
12589 spec->int_mic.pin = 0x19;
12590 spec->int_mic.mux_idx = 1;
12591 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012592}
12593
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012594static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12595 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12596 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12597 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12598 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12599 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12600 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12601 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12602 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12603 { }
12604};
12605
12606static struct hda_verb alc267_quanta_il1_verbs[] = {
12607 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12608 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12609 { }
12610};
12611
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012612static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012613{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012614 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012615 spec->autocfg.hp_pins[0] = 0x15;
12616 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012617 spec->ext_mic.pin = 0x18;
12618 spec->ext_mic.mux_idx = 0;
12619 spec->int_mic.pin = 0x19;
12620 spec->int_mic.mux_idx = 1;
12621 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012622}
12623
Kailang Yanga361d842007-06-05 12:30:55 +020012624/*
12625 * generic initialization of ADC, input mixers and output mixers
12626 */
12627static struct hda_verb alc268_base_init_verbs[] = {
12628 /* Unmute DAC0-1 and set vol = 0 */
12629 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012630 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012631
12632 /*
12633 * Set up output mixers (0x0c - 0x0e)
12634 */
12635 /* set vol=0 to output mixers */
12636 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012637 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12638
12639 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12640 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12641
12642 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12643 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12644 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12645 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12646 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12647 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12648 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12649 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12650
12651 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12652 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12653 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12654 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012655 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012656
12657 /* set PCBEEP vol = 0, mute connections */
12658 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12659 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12660 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012661
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012662 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012663
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012664 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12666 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12667 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012668
Kailang Yanga361d842007-06-05 12:30:55 +020012669 { }
12670};
12671
12672/*
12673 * generic initialization of ADC, input mixers and output mixers
12674 */
12675static struct hda_verb alc268_volume_init_verbs[] = {
12676 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012677 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12678 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012679
12680 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12681 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12682 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12683 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12684 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12685
Kailang Yanga361d842007-06-05 12:30:55 +020012686 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012687 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12688 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12689
12690 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012692
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012693 /* set PCBEEP vol = 0, mute connections */
12694 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12695 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12696 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012697
12698 { }
12699};
12700
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012701static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12702 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12703 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12704 { } /* end */
12705};
12706
Kailang Yanga361d842007-06-05 12:30:55 +020012707static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12708 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12709 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012710 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012711 { } /* end */
12712};
12713
12714static struct snd_kcontrol_new alc268_capture_mixer[] = {
12715 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12716 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12717 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12718 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012719 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012720 { } /* end */
12721};
12722
12723static struct hda_input_mux alc268_capture_source = {
12724 .num_items = 4,
12725 .items = {
12726 { "Mic", 0x0 },
12727 { "Front Mic", 0x1 },
12728 { "Line", 0x2 },
12729 { "CD", 0x3 },
12730 },
12731};
12732
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012733static struct hda_input_mux alc268_acer_capture_source = {
12734 .num_items = 3,
12735 .items = {
12736 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012737 { "Internal Mic", 0x1 },
12738 { "Line", 0x2 },
12739 },
12740};
12741
12742static struct hda_input_mux alc268_acer_dmic_capture_source = {
12743 .num_items = 3,
12744 .items = {
12745 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012746 { "Internal Mic", 0x6 },
12747 { "Line", 0x2 },
12748 },
12749};
12750
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012751#ifdef CONFIG_SND_DEBUG
12752static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012753 /* Volume widgets */
12754 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12755 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12756 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12757 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12758 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12759 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12760 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12761 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12762 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12763 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12764 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12765 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12766 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012767 /* The below appears problematic on some hardwares */
12768 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012769 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12770 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12771 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12772 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12773
12774 /* Modes for retasking pin widgets */
12775 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12776 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12777 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12778 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12779
12780 /* Controls for GPIO pins, assuming they are configured as outputs */
12781 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12782 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12783 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12784 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12785
12786 /* Switches to allow the digital SPDIF output pin to be enabled.
12787 * The ALC268 does not have an SPDIF input.
12788 */
12789 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12790
12791 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12792 * this output to turn on an external amplifier.
12793 */
12794 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12795 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12796
12797 { } /* end */
12798};
12799#endif
12800
Kailang Yanga361d842007-06-05 12:30:55 +020012801/* create input playback/capture controls for the given pin */
12802static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12803 const char *ctlname, int idx)
12804{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012805 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012806 int err;
12807
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012808 switch (nid) {
12809 case 0x14:
12810 case 0x16:
12811 dac = 0x02;
12812 break;
12813 case 0x15:
12814 dac = 0x03;
12815 break;
12816 default:
12817 return 0;
12818 }
12819 if (spec->multiout.dac_nids[0] != dac &&
12820 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012821 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012822 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012823 HDA_OUTPUT));
12824 if (err < 0)
12825 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012826 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12827 }
12828
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012829 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012830 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020012831 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012832 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012833 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012834 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012835 if (err < 0)
12836 return err;
12837 return 0;
12838}
12839
12840/* add playback controls from the parsed DAC table */
12841static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12842 const struct auto_pin_cfg *cfg)
12843{
12844 hda_nid_t nid;
12845 int err;
12846
Kailang Yanga361d842007-06-05 12:30:55 +020012847 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012848
12849 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012850 if (nid) {
12851 const char *name;
12852 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12853 name = "Speaker";
12854 else
12855 name = "Front";
12856 err = alc268_new_analog_output(spec, nid, name, 0);
12857 if (err < 0)
12858 return err;
12859 }
Kailang Yanga361d842007-06-05 12:30:55 +020012860
12861 nid = cfg->speaker_pins[0];
12862 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012863 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020012864 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12865 if (err < 0)
12866 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012867 } else {
12868 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12869 if (err < 0)
12870 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012871 }
12872 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012873 if (nid) {
12874 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12875 if (err < 0)
12876 return err;
12877 }
Kailang Yanga361d842007-06-05 12:30:55 +020012878
12879 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12880 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012881 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012882 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012883 if (err < 0)
12884 return err;
12885 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012886 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012887}
12888
12889/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012890static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012891 const struct auto_pin_cfg *cfg)
12892{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012893 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012894}
12895
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012896static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12897 hda_nid_t nid, int pin_type)
12898{
12899 int idx;
12900
12901 alc_set_pin_output(codec, nid, pin_type);
12902 if (nid == 0x14 || nid == 0x16)
12903 idx = 0;
12904 else
12905 idx = 1;
12906 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12907}
12908
12909static void alc268_auto_init_multi_out(struct hda_codec *codec)
12910{
12911 struct alc_spec *spec = codec->spec;
12912 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12913 if (nid) {
12914 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12915 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12916 }
12917}
12918
12919static void alc268_auto_init_hp_out(struct hda_codec *codec)
12920{
12921 struct alc_spec *spec = codec->spec;
12922 hda_nid_t pin;
12923
12924 pin = spec->autocfg.hp_pins[0];
12925 if (pin)
12926 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12927 pin = spec->autocfg.speaker_pins[0];
12928 if (pin)
12929 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12930}
12931
Kailang Yanga361d842007-06-05 12:30:55 +020012932static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12933{
12934 struct alc_spec *spec = codec->spec;
12935 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12936 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12937 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12938 unsigned int dac_vol1, dac_vol2;
12939
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012940 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012941 snd_hda_codec_write(codec, speaker_nid, 0,
12942 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012943 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012944 snd_hda_codec_write(codec, 0x0f, 0,
12945 AC_VERB_SET_AMP_GAIN_MUTE,
12946 AMP_IN_UNMUTE(1));
12947 snd_hda_codec_write(codec, 0x10, 0,
12948 AC_VERB_SET_AMP_GAIN_MUTE,
12949 AMP_IN_UNMUTE(1));
12950 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012951 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012952 snd_hda_codec_write(codec, 0x0f, 0,
12953 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12954 snd_hda_codec_write(codec, 0x10, 0,
12955 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12956 }
12957
12958 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012959 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012960 dac_vol2 = AMP_OUT_ZERO;
12961 else if (line_nid == 0x15)
12962 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012963 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012964 dac_vol2 = AMP_OUT_ZERO;
12965 else if (hp_nid == 0x15)
12966 dac_vol1 = AMP_OUT_ZERO;
12967 if (line_nid != 0x16 || hp_nid != 0x16 ||
12968 spec->autocfg.line_out_pins[1] != 0x16 ||
12969 spec->autocfg.line_out_pins[2] != 0x16)
12970 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12971
12972 snd_hda_codec_write(codec, 0x02, 0,
12973 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12974 snd_hda_codec_write(codec, 0x03, 0,
12975 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12976}
12977
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012978/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012979#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12980#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012981#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012982#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12983
12984/*
12985 * BIOS auto configuration
12986 */
12987static int alc268_parse_auto_config(struct hda_codec *codec)
12988{
12989 struct alc_spec *spec = codec->spec;
12990 int err;
12991 static hda_nid_t alc268_ignore[] = { 0 };
12992
12993 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12994 alc268_ignore);
12995 if (err < 0)
12996 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012997 if (!spec->autocfg.line_outs) {
12998 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12999 spec->multiout.max_channels = 2;
13000 spec->no_analog = 1;
13001 goto dig_only;
13002 }
Kailang Yanga361d842007-06-05 12:30:55 +020013003 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013004 }
Kailang Yanga361d842007-06-05 12:30:55 +020013005 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13006 if (err < 0)
13007 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013008 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013009 if (err < 0)
13010 return err;
13011
13012 spec->multiout.max_channels = 2;
13013
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013014 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013015 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013016 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020013017 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013018 spec->dig_out_type = spec->autocfg.dig_out_type[0];
13019 }
Takashi Iwai603c4012008-07-30 15:01:44 +020013020 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013021 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013022
Takashi Iwai892981f2009-03-02 08:04:35 +010013023 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013024 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013025
Takashi Iwaid88897e2008-10-31 15:01:37 +010013026 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013027 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013028 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013029
Takashi Iwai776e1842007-08-29 15:07:11 +020013030 err = alc_auto_add_mic_boost(codec);
13031 if (err < 0)
13032 return err;
13033
Kailang Yang6227cdc2010-02-25 08:36:52 +010013034 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013035
Kailang Yanga361d842007-06-05 12:30:55 +020013036 return 1;
13037}
13038
Kailang Yanga361d842007-06-05 12:30:55 +020013039#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13040
13041/* init callback for auto-configuration model -- overriding the default init */
13042static void alc268_auto_init(struct hda_codec *codec)
13043{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013044 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013045 alc268_auto_init_multi_out(codec);
13046 alc268_auto_init_hp_out(codec);
13047 alc268_auto_init_mono_speaker_out(codec);
13048 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013049 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013050 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013051}
13052
13053/*
13054 * configuration and preset
13055 */
13056static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013057 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013058 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013059 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013060 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013061 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013062 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013063 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013064 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013065#ifdef CONFIG_SND_DEBUG
13066 [ALC268_TEST] = "test",
13067#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013068 [ALC268_AUTO] = "auto",
13069};
13070
13071static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013072 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013073 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013074 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013075 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013076 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013077 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13078 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013079 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013080 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13081 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013082 /* almost compatible with toshiba but with optional digital outs;
13083 * auto-probing seems working fine
13084 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013085 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013086 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013087 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013088 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013089 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013090 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013091 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013092 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020013093 {}
13094};
13095
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013096/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13097static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13098 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13099 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13100 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13101 ALC268_TOSHIBA),
13102 {}
13103};
13104
Kailang Yanga361d842007-06-05 12:30:55 +020013105static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013106 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013107 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13108 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013109 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13110 alc267_quanta_il1_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 .hp_nid = 0x03,
13116 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13117 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013118 .unsol_event = alc_sku_unsol_event,
13119 .setup = alc267_quanta_il1_setup,
13120 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013121 },
Kailang Yanga361d842007-06-05 12:30:55 +020013122 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013123 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13124 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013125 .init_verbs = { alc268_base_init_verbs },
13126 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13127 .dac_nids = alc268_dac_nids,
13128 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13129 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013130 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013131 .hp_nid = 0x03,
13132 .dig_out_nid = ALC268_DIGOUT_NID,
13133 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13134 .channel_mode = alc268_modes,
13135 .input_mux = &alc268_capture_source,
13136 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013137 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013138 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013139 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013140 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13141 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013142 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13143 .dac_nids = alc268_dac_nids,
13144 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13145 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013146 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013147 .hp_nid = 0x03,
13148 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13149 .channel_mode = alc268_modes,
13150 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013151 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013152 .setup = alc268_toshiba_setup,
13153 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013154 },
13155 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013156 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013157 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013158 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13159 alc268_acer_verbs },
13160 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13161 .dac_nids = alc268_dac_nids,
13162 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13163 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013164 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013165 .hp_nid = 0x02,
13166 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13167 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013168 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013169 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013170 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013171 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013172 [ALC268_ACER_DMIC] = {
13173 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13174 alc268_beep_mixer },
13175 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13176 alc268_acer_verbs },
13177 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13178 .dac_nids = alc268_dac_nids,
13179 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13180 .adc_nids = alc268_adc_nids_alt,
13181 .capsrc_nids = alc268_capsrc_nids,
13182 .hp_nid = 0x02,
13183 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13184 .channel_mode = alc268_modes,
13185 .input_mux = &alc268_acer_dmic_capture_source,
13186 .unsol_event = alc268_acer_unsol_event,
13187 .init_hook = alc268_acer_init_hook,
13188 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013189 [ALC268_ACER_ASPIRE_ONE] = {
13190 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013191 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013192 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013193 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13194 alc268_acer_aspire_one_verbs },
13195 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13196 .dac_nids = alc268_dac_nids,
13197 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13198 .adc_nids = alc268_adc_nids_alt,
13199 .capsrc_nids = alc268_capsrc_nids,
13200 .hp_nid = 0x03,
13201 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13202 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013203 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013204 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013205 .init_hook = alc268_acer_lc_init_hook,
13206 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013207 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013208 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13209 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013210 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13211 alc268_dell_verbs },
13212 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13213 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013214 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13215 .adc_nids = alc268_adc_nids_alt,
13216 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013217 .hp_nid = 0x02,
13218 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13219 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013220 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013221 .setup = alc268_dell_setup,
13222 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013223 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013224 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013225 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13226 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013227 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13228 alc268_toshiba_verbs },
13229 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13230 .dac_nids = alc268_dac_nids,
13231 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13232 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013233 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013234 .hp_nid = 0x03,
13235 .dig_out_nid = ALC268_DIGOUT_NID,
13236 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13237 .channel_mode = alc268_modes,
13238 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013239 .setup = alc268_toshiba_setup,
13240 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013241 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013242#ifdef CONFIG_SND_DEBUG
13243 [ALC268_TEST] = {
13244 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13245 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13246 alc268_volume_init_verbs },
13247 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13248 .dac_nids = alc268_dac_nids,
13249 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13250 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013251 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013252 .hp_nid = 0x03,
13253 .dig_out_nid = ALC268_DIGOUT_NID,
13254 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13255 .channel_mode = alc268_modes,
13256 .input_mux = &alc268_capture_source,
13257 },
13258#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013259};
13260
13261static int patch_alc268(struct hda_codec *codec)
13262{
13263 struct alc_spec *spec;
13264 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013265 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013266
Julia Lawallef86f582009-12-19 08:18:03 +010013267 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013268 if (spec == NULL)
13269 return -ENOMEM;
13270
13271 codec->spec = spec;
13272
13273 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13274 alc268_models,
13275 alc268_cfg_tbl);
13276
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013277 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13278 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013279 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013280
Kailang Yanga361d842007-06-05 12:30:55 +020013281 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013282 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13283 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013284 board_config = ALC268_AUTO;
13285 }
13286
13287 if (board_config == ALC268_AUTO) {
13288 /* automatic parse from the BIOS config */
13289 err = alc268_parse_auto_config(codec);
13290 if (err < 0) {
13291 alc_free(codec);
13292 return err;
13293 } else if (!err) {
13294 printk(KERN_INFO
13295 "hda_codec: Cannot set up configuration "
13296 "from BIOS. Using base mode...\n");
13297 board_config = ALC268_3ST;
13298 }
13299 }
13300
13301 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013302 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013303
Kailang Yanga361d842007-06-05 12:30:55 +020013304 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13305 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013306 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013307
Kailang Yanga361d842007-06-05 12:30:55 +020013308 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13309
Takashi Iwai22971e32009-02-10 11:56:44 +010013310 has_beep = 0;
13311 for (i = 0; i < spec->num_mixers; i++) {
13312 if (spec->mixers[i] == alc268_beep_mixer) {
13313 has_beep = 1;
13314 break;
13315 }
13316 }
13317
13318 if (has_beep) {
13319 err = snd_hda_attach_beep_device(codec, 0x1);
13320 if (err < 0) {
13321 alc_free(codec);
13322 return err;
13323 }
13324 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13325 /* override the amp caps for beep generator */
13326 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013327 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13328 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13329 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13330 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013331 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013332
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013333 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013334 /* check whether NID 0x07 is valid */
13335 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013336 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013337
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013338 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013339 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013340 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013341 if (spec->auto_mic ||
13342 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013343 spec->adc_nids = alc268_adc_nids_alt;
13344 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013345 if (spec->auto_mic)
13346 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013347 if (spec->auto_mic || spec->input_mux->num_items == 1)
13348 add_mixer(spec, alc268_capture_nosrc_mixer);
13349 else
13350 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013351 } else {
13352 spec->adc_nids = alc268_adc_nids;
13353 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013354 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013355 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013356 /* set default input source */
13357 for (i = 0; i < spec->num_adc_nids; i++)
13358 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13359 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013360 i < spec->num_mux_defs ?
13361 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013362 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013363 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013364
13365 spec->vmaster_nid = 0x02;
13366
Kailang Yanga361d842007-06-05 12:30:55 +020013367 codec->patch_ops = alc_patch_ops;
13368 if (board_config == ALC268_AUTO)
13369 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013370
Kailang Yanga361d842007-06-05 12:30:55 +020013371 return 0;
13372}
13373
13374/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013375 * ALC269 channel source setting (2 channel)
13376 */
13377#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13378
13379#define alc269_dac_nids alc260_dac_nids
13380
13381static hda_nid_t alc269_adc_nids[1] = {
13382 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013383 0x08,
13384};
13385
Takashi Iwaie01bf502008-08-21 16:25:07 +020013386static hda_nid_t alc269_capsrc_nids[1] = {
13387 0x23,
13388};
13389
Kailang Yang84898e82010-02-04 14:16:14 +010013390static hda_nid_t alc269vb_adc_nids[1] = {
13391 /* ADC1 */
13392 0x09,
13393};
13394
13395static hda_nid_t alc269vb_capsrc_nids[1] = {
13396 0x22,
13397};
13398
Takashi Iwai66946352010-03-29 17:21:45 +020013399static hda_nid_t alc269_adc_candidates[] = {
13400 0x08, 0x09, 0x07,
13401};
Takashi Iwaie01bf502008-08-21 16:25:07 +020013402
Kailang Yangf6a92242007-12-13 16:52:54 +010013403#define alc269_modes alc260_modes
13404#define alc269_capture_source alc880_lg_lw_capture_source
13405
13406static struct snd_kcontrol_new alc269_base_mixer[] = {
13407 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13408 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13409 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13410 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13411 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13412 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13413 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13414 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13415 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13416 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13417 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13418 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13419 { } /* end */
13420};
13421
Kailang Yang60db6b52008-08-26 13:13:00 +020013422static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13423 /* output mixer control */
13424 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13425 {
13426 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13427 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013428 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013429 .info = snd_hda_mixer_amp_switch_info,
13430 .get = snd_hda_mixer_amp_switch_get,
13431 .put = alc268_acer_master_sw_put,
13432 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13433 },
13434 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13435 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13436 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13437 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13438 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13439 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013440 { }
13441};
13442
Tony Vroon64154832008-11-06 15:08:49 +000013443static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13444 /* output mixer control */
13445 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13446 {
13447 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13448 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013449 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013450 .info = snd_hda_mixer_amp_switch_info,
13451 .get = snd_hda_mixer_amp_switch_get,
13452 .put = alc268_acer_master_sw_put,
13453 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13454 },
13455 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13456 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13457 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13458 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13459 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13460 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13461 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13462 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13463 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013464 { }
13465};
13466
Kailang Yang84898e82010-02-04 14:16:14 +010013467static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013468 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013469 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013470 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013471 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013472 { } /* end */
13473};
13474
Kailang Yang84898e82010-02-04 14:16:14 +010013475static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
13476 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13477 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13478 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13479 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13480 { } /* end */
13481};
13482
Kailang Yangf6a92242007-12-13 16:52:54 +010013483/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010013484static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
13485 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13486 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13487 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13488 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13489 { } /* end */
13490};
13491
13492static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020013493 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13494 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013495 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13496 { } /* end */
13497};
13498
Kailang Yang84898e82010-02-04 14:16:14 +010013499static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
13500 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13501 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13502 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13503 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13504 { } /* end */
13505};
13506
13507static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
13508 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13509 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13510 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13511 { } /* end */
13512};
13513
Takashi Iwai26f5df22008-11-03 17:39:46 +010013514/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010013515#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013516
Kailang Yang60db6b52008-08-26 13:13:00 +020013517static struct hda_verb alc269_quanta_fl1_verbs[] = {
13518 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13519 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13520 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13521 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13522 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13523 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13524 { }
13525};
13526
Tony Vroon64154832008-11-06 15:08:49 +000013527static struct hda_verb alc269_lifebook_verbs[] = {
13528 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13529 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13530 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13531 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13532 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13533 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13534 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13535 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13536 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13537 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13538 { }
13539};
13540
Kailang Yang60db6b52008-08-26 13:13:00 +020013541/* toggle speaker-output according to the hp-jack state */
13542static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13543{
13544 unsigned int present;
13545 unsigned char bits;
13546
Wu Fengguang864f92b2009-11-18 12:38:02 +080013547 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013548 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013549 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013550 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013551 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013552 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013553
13554 snd_hda_codec_write(codec, 0x20, 0,
13555 AC_VERB_SET_COEF_INDEX, 0x0c);
13556 snd_hda_codec_write(codec, 0x20, 0,
13557 AC_VERB_SET_PROC_COEF, 0x680);
13558
13559 snd_hda_codec_write(codec, 0x20, 0,
13560 AC_VERB_SET_COEF_INDEX, 0x0c);
13561 snd_hda_codec_write(codec, 0x20, 0,
13562 AC_VERB_SET_PROC_COEF, 0x480);
13563}
13564
Tony Vroon64154832008-11-06 15:08:49 +000013565/* toggle speaker-output according to the hp-jacks state */
13566static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13567{
13568 unsigned int present;
13569 unsigned char bits;
13570
13571 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013572 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013573
13574 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013575 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013576
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013577 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000013578 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013579 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013580 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013581 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013582
13583 snd_hda_codec_write(codec, 0x20, 0,
13584 AC_VERB_SET_COEF_INDEX, 0x0c);
13585 snd_hda_codec_write(codec, 0x20, 0,
13586 AC_VERB_SET_PROC_COEF, 0x680);
13587
13588 snd_hda_codec_write(codec, 0x20, 0,
13589 AC_VERB_SET_COEF_INDEX, 0x0c);
13590 snd_hda_codec_write(codec, 0x20, 0,
13591 AC_VERB_SET_PROC_COEF, 0x480);
13592}
13593
Tony Vroon64154832008-11-06 15:08:49 +000013594static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13595{
13596 unsigned int present_laptop;
13597 unsigned int present_dock;
13598
Wu Fengguang864f92b2009-11-18 12:38:02 +080013599 present_laptop = snd_hda_jack_detect(codec, 0x18);
13600 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013601
13602 /* Laptop mic port overrides dock mic port, design decision */
13603 if (present_dock)
13604 snd_hda_codec_write(codec, 0x23, 0,
13605 AC_VERB_SET_CONNECT_SEL, 0x3);
13606 if (present_laptop)
13607 snd_hda_codec_write(codec, 0x23, 0,
13608 AC_VERB_SET_CONNECT_SEL, 0x0);
13609 if (!present_dock && !present_laptop)
13610 snd_hda_codec_write(codec, 0x23, 0,
13611 AC_VERB_SET_CONNECT_SEL, 0x1);
13612}
13613
Kailang Yang60db6b52008-08-26 13:13:00 +020013614static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13615 unsigned int res)
13616{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013617 switch (res >> 26) {
13618 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013619 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013620 break;
13621 case ALC880_MIC_EVENT:
13622 alc_mic_automute(codec);
13623 break;
13624 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013625}
13626
Tony Vroon64154832008-11-06 15:08:49 +000013627static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13628 unsigned int res)
13629{
13630 if ((res >> 26) == ALC880_HP_EVENT)
13631 alc269_lifebook_speaker_automute(codec);
13632 if ((res >> 26) == ALC880_MIC_EVENT)
13633 alc269_lifebook_mic_autoswitch(codec);
13634}
13635
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013636static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13637{
13638 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013639 spec->autocfg.hp_pins[0] = 0x15;
13640 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013641 spec->ext_mic.pin = 0x18;
13642 spec->ext_mic.mux_idx = 0;
13643 spec->int_mic.pin = 0x19;
13644 spec->int_mic.mux_idx = 1;
13645 spec->auto_mic = 1;
13646}
13647
Kailang Yang60db6b52008-08-26 13:13:00 +020013648static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13649{
13650 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013651 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013652}
13653
Tony Vroon64154832008-11-06 15:08:49 +000013654static void alc269_lifebook_init_hook(struct hda_codec *codec)
13655{
13656 alc269_lifebook_speaker_automute(codec);
13657 alc269_lifebook_mic_autoswitch(codec);
13658}
13659
Kailang Yang84898e82010-02-04 14:16:14 +010013660static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013661 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13662 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13663 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13664 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13665 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13666 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13667 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13668 {}
13669};
13670
Kailang Yang84898e82010-02-04 14:16:14 +010013671static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013672 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13673 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13674 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13675 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13676 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13677 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13678 {}
13679};
13680
Kailang Yang84898e82010-02-04 14:16:14 +010013681static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
13682 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13683 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
13684 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13685 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13686 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13687 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13688 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13689 {}
13690};
13691
13692static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
13693 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13694 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
13695 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13696 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13697 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13698 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13699 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13700 {}
13701};
13702
Kailang Yang60db6b52008-08-26 13:13:00 +020013703/* toggle speaker-output according to the hp-jack state */
13704static void alc269_speaker_automute(struct hda_codec *codec)
13705{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013706 struct alc_spec *spec = codec->spec;
13707 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013708 unsigned int present;
13709 unsigned char bits;
13710
Kailang Yangebb83ee2009-12-17 12:23:00 +010013711 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013712 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013713 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013714 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013715 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013716 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013717}
13718
Kailang Yang60db6b52008-08-26 13:13:00 +020013719/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010013720static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013721 unsigned int res)
13722{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013723 switch (res >> 26) {
13724 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013725 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013726 break;
13727 case ALC880_MIC_EVENT:
13728 alc_mic_automute(codec);
13729 break;
13730 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013731}
13732
Kailang Yang84898e82010-02-04 14:16:14 +010013733static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013734{
13735 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013736 spec->autocfg.hp_pins[0] = 0x15;
13737 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013738 spec->ext_mic.pin = 0x18;
13739 spec->ext_mic.mux_idx = 0;
13740 spec->int_mic.pin = 0x12;
13741 spec->int_mic.mux_idx = 5;
13742 spec->auto_mic = 1;
13743}
13744
Kailang Yang84898e82010-02-04 14:16:14 +010013745static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
13746{
13747 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013748 spec->autocfg.hp_pins[0] = 0x15;
13749 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang84898e82010-02-04 14:16:14 +010013750 spec->ext_mic.pin = 0x18;
13751 spec->ext_mic.mux_idx = 0;
13752 spec->int_mic.pin = 0x12;
13753 spec->int_mic.mux_idx = 6;
13754 spec->auto_mic = 1;
13755}
13756
13757static void alc269_laptop_amic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013758{
13759 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013760 spec->autocfg.hp_pins[0] = 0x15;
13761 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013762 spec->ext_mic.pin = 0x18;
13763 spec->ext_mic.mux_idx = 0;
13764 spec->int_mic.pin = 0x19;
13765 spec->int_mic.mux_idx = 1;
13766 spec->auto_mic = 1;
13767}
13768
Kailang Yang84898e82010-02-04 14:16:14 +010013769static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013770{
13771 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013772 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013773}
13774
Kailang Yangf6a92242007-12-13 16:52:54 +010013775/*
13776 * generic initialization of ADC, input mixers and output mixers
13777 */
13778static struct hda_verb alc269_init_verbs[] = {
13779 /*
13780 * Unmute ADC0 and set the default input to mic-in
13781 */
Kailang Yang84898e82010-02-04 14:16:14 +010013782 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013783
13784 /*
Kailang Yang84898e82010-02-04 14:16:14 +010013785 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010013786 */
13787 /* set vol=0 to output mixers */
13788 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13789 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13790
13791 /* set up input amps for analog loopback */
13792 /* Amp Indices: DAC = 0, mixer = 1 */
13793 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13794 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13795 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13796 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13797 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13798 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13799
13800 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13801 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13802 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13803 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13804 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13805 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13806 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13807
13808 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13809 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010013810
Kailang Yang84898e82010-02-04 14:16:14 +010013811 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010013812 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13813 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010013814 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010013815
13816 /* set EAPD */
13817 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010013818 { }
13819};
13820
13821static struct hda_verb alc269vb_init_verbs[] = {
13822 /*
13823 * Unmute ADC0 and set the default input to mic-in
13824 */
13825 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13826
13827 /*
13828 * Set up output mixers (0x02 - 0x03)
13829 */
13830 /* set vol=0 to output mixers */
13831 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13832 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13833
13834 /* set up input amps for analog loopback */
13835 /* Amp Indices: DAC = 0, mixer = 1 */
13836 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13837 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13838 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13839 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13840 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13841 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13842
13843 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13844 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13845 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13846 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13847 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13848 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13849 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13850
13851 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13852 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13853
13854 /* FIXME: use Mux-type input source selection */
13855 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13856 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
13857 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
13858
13859 /* set EAPD */
13860 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010013861 { }
13862};
13863
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013864#define alc269_auto_create_multi_out_ctls \
13865 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013866#define alc269_auto_create_input_ctls \
13867 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013868
13869#ifdef CONFIG_SND_HDA_POWER_SAVE
13870#define alc269_loopbacks alc880_loopbacks
13871#endif
13872
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013873/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013874#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13875#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13876#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13877#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13878
Takashi Iwaif03d3112009-03-05 14:18:16 +010013879static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13880 .substreams = 1,
13881 .channels_min = 2,
13882 .channels_max = 8,
13883 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13884 /* NID is set in alc_build_pcms */
13885 .ops = {
13886 .open = alc880_playback_pcm_open,
13887 .prepare = alc880_playback_pcm_prepare,
13888 .cleanup = alc880_playback_pcm_cleanup
13889 },
13890};
13891
13892static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13893 .substreams = 1,
13894 .channels_min = 2,
13895 .channels_max = 2,
13896 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13897 /* NID is set in alc_build_pcms */
13898};
13899
Kailang Yangf6a92242007-12-13 16:52:54 +010013900/*
13901 * BIOS auto configuration
13902 */
13903static int alc269_parse_auto_config(struct hda_codec *codec)
13904{
13905 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013906 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013907 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13908
13909 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13910 alc269_ignore);
13911 if (err < 0)
13912 return err;
13913
13914 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13915 if (err < 0)
13916 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013917 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013918 if (err < 0)
13919 return err;
13920
13921 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13922
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013923 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013924 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13925
Takashi Iwai603c4012008-07-30 15:01:44 +020013926 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013927 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013928
Kailang Yang84898e82010-02-04 14:16:14 +010013929 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
13930 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010013931 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010013932 } else {
13933 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010013934 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010013935 }
13936
Kailang Yangf6a92242007-12-13 16:52:54 +010013937 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013938 spec->input_mux = &spec->private_imux[0];
Takashi Iwai66946352010-03-29 17:21:45 +020013939 fillup_priv_adc_nids(codec, alc269_adc_candidates,
13940 sizeof(alc269_adc_candidates));
13941
Takashi Iwaie01bf502008-08-21 16:25:07 +020013942 /* set default input source */
Takashi Iwai66946352010-03-29 17:21:45 +020013943 snd_hda_codec_write_cache(codec, spec->capsrc_nids[0],
Takashi Iwaie01bf502008-08-21 16:25:07 +020013944 0, AC_VERB_SET_CONNECT_SEL,
13945 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013946
13947 err = alc_auto_add_mic_boost(codec);
13948 if (err < 0)
13949 return err;
13950
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013951 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013952 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013953
Kailang Yangf6a92242007-12-13 16:52:54 +010013954 return 1;
13955}
13956
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013957#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13958#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013959#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13960
13961
13962/* init callback for auto-configuration model -- overriding the default init */
13963static void alc269_auto_init(struct hda_codec *codec)
13964{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013965 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013966 alc269_auto_init_multi_out(codec);
13967 alc269_auto_init_hp_out(codec);
13968 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013969 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013970 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013971}
13972
13973/*
13974 * configuration and preset
13975 */
13976static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013977 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013978 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010013979 [ALC269_AMIC] = "laptop-amic",
13980 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000013981 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020013982 [ALC269_LIFEBOOK] = "lifebook",
13983 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010013984};
13985
13986static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013987 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013988 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010013989 ALC269_AMIC),
13990 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
13991 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
13992 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
13993 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
13994 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
13995 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
13996 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
13997 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
13998 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
13999 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14000 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14001 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14002 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14003 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14004 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14005 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14006 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14007 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14008 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14009 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14010 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14011 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14012 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14013 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14014 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14015 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14016 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14017 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14018 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14019 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14020 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14021 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14022 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14023 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14024 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14025 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014026 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014027 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014028 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014029 ALC269_DMIC),
14030 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14031 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014032 SND_PCI_QUIRK(0x104d, 0x9071, "SONY XTB", ALC269_DMIC),
Tony Vroon64154832008-11-06 15:08:49 +000014033 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014034 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14035 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14036 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14037 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14038 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14039 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014040 {}
14041};
14042
14043static struct alc_config_preset alc269_presets[] = {
14044 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014045 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014046 .init_verbs = { alc269_init_verbs },
14047 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14048 .dac_nids = alc269_dac_nids,
14049 .hp_nid = 0x03,
14050 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14051 .channel_mode = alc269_modes,
14052 .input_mux = &alc269_capture_source,
14053 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014054 [ALC269_QUANTA_FL1] = {
14055 .mixers = { alc269_quanta_fl1_mixer },
14056 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14057 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14058 .dac_nids = alc269_dac_nids,
14059 .hp_nid = 0x03,
14060 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14061 .channel_mode = alc269_modes,
14062 .input_mux = &alc269_capture_source,
14063 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014064 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014065 .init_hook = alc269_quanta_fl1_init_hook,
14066 },
Kailang Yang84898e82010-02-04 14:16:14 +010014067 [ALC269_AMIC] = {
14068 .mixers = { alc269_laptop_mixer },
14069 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014070 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014071 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014072 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14073 .dac_nids = alc269_dac_nids,
14074 .hp_nid = 0x03,
14075 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14076 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014077 .unsol_event = alc269_laptop_unsol_event,
14078 .setup = alc269_laptop_amic_setup,
14079 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014080 },
Kailang Yang84898e82010-02-04 14:16:14 +010014081 [ALC269_DMIC] = {
14082 .mixers = { alc269_laptop_mixer },
14083 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014084 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014085 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014086 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14087 .dac_nids = alc269_dac_nids,
14088 .hp_nid = 0x03,
14089 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14090 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014091 .unsol_event = alc269_laptop_unsol_event,
14092 .setup = alc269_laptop_dmic_setup,
14093 .init_hook = alc269_laptop_inithook,
14094 },
14095 [ALC269VB_AMIC] = {
14096 .mixers = { alc269vb_laptop_mixer },
14097 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14098 .init_verbs = { alc269vb_init_verbs,
14099 alc269vb_laptop_amic_init_verbs },
14100 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14101 .dac_nids = alc269_dac_nids,
14102 .hp_nid = 0x03,
14103 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14104 .channel_mode = alc269_modes,
14105 .unsol_event = alc269_laptop_unsol_event,
14106 .setup = alc269_laptop_amic_setup,
14107 .init_hook = alc269_laptop_inithook,
14108 },
14109 [ALC269VB_DMIC] = {
14110 .mixers = { alc269vb_laptop_mixer },
14111 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14112 .init_verbs = { alc269vb_init_verbs,
14113 alc269vb_laptop_dmic_init_verbs },
14114 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14115 .dac_nids = alc269_dac_nids,
14116 .hp_nid = 0x03,
14117 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14118 .channel_mode = alc269_modes,
14119 .unsol_event = alc269_laptop_unsol_event,
14120 .setup = alc269vb_laptop_dmic_setup,
14121 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014122 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014123 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014124 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014125 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014126 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014127 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014128 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14129 .dac_nids = alc269_dac_nids,
14130 .hp_nid = 0x03,
14131 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14132 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014133 .unsol_event = alc269_laptop_unsol_event,
14134 .setup = alc269_laptop_dmic_setup,
14135 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014136 },
Tony Vroon64154832008-11-06 15:08:49 +000014137 [ALC269_LIFEBOOK] = {
14138 .mixers = { alc269_lifebook_mixer },
14139 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14140 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14141 .dac_nids = alc269_dac_nids,
14142 .hp_nid = 0x03,
14143 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14144 .channel_mode = alc269_modes,
14145 .input_mux = &alc269_capture_source,
14146 .unsol_event = alc269_lifebook_unsol_event,
14147 .init_hook = alc269_lifebook_init_hook,
14148 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014149};
14150
14151static int patch_alc269(struct hda_codec *codec)
14152{
14153 struct alc_spec *spec;
14154 int board_config;
14155 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014156 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014157
14158 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14159 if (spec == NULL)
14160 return -ENOMEM;
14161
14162 codec->spec = spec;
14163
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020014164 alc_fix_pll_init(codec, 0x20, 0x04, 15);
14165
Kailang Yang274693f2009-12-03 10:07:50 +010014166 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
14167 kfree(codec->chip_name);
14168 codec->chip_name = kstrdup("ALC259", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010014169 if (!codec->chip_name) {
14170 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010014171 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010014172 }
Kailang Yang84898e82010-02-04 14:16:14 +010014173 is_alc269vb = 1;
Kailang Yang274693f2009-12-03 10:07:50 +010014174 }
14175
Kailang Yangf6a92242007-12-13 16:52:54 +010014176 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14177 alc269_models,
14178 alc269_cfg_tbl);
14179
14180 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014181 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14182 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014183 board_config = ALC269_AUTO;
14184 }
14185
14186 if (board_config == ALC269_AUTO) {
14187 /* automatic parse from the BIOS config */
14188 err = alc269_parse_auto_config(codec);
14189 if (err < 0) {
14190 alc_free(codec);
14191 return err;
14192 } else if (!err) {
14193 printk(KERN_INFO
14194 "hda_codec: Cannot set up configuration "
14195 "from BIOS. Using base mode...\n");
14196 board_config = ALC269_BASIC;
14197 }
14198 }
14199
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014200 err = snd_hda_attach_beep_device(codec, 0x1);
14201 if (err < 0) {
14202 alc_free(codec);
14203 return err;
14204 }
14205
Kailang Yangf6a92242007-12-13 16:52:54 +010014206 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014207 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014208
Kailang Yang84898e82010-02-04 14:16:14 +010014209 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014210 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14211 * fix the sample rate of analog I/O to 44.1kHz
14212 */
14213 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14214 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
14215 } else {
14216 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14217 spec->stream_analog_capture = &alc269_pcm_analog_capture;
14218 }
Kailang Yangf6a92242007-12-13 16:52:54 +010014219 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14220 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14221
Takashi Iwai66946352010-03-29 17:21:45 +020014222 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
14223 if (!is_alc269vb) {
14224 spec->adc_nids = alc269_adc_nids;
14225 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14226 spec->capsrc_nids = alc269_capsrc_nids;
14227 } else {
14228 spec->adc_nids = alc269vb_adc_nids;
14229 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14230 spec->capsrc_nids = alc269vb_capsrc_nids;
14231 }
Kailang Yang84898e82010-02-04 14:16:14 +010014232 }
14233
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014234 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014235 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014236 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010014237
Takashi Iwai100d5eb2009-08-10 11:55:51 +020014238 spec->vmaster_nid = 0x02;
14239
Kailang Yangf6a92242007-12-13 16:52:54 +010014240 codec->patch_ops = alc_patch_ops;
14241 if (board_config == ALC269_AUTO)
14242 spec->init_hook = alc269_auto_init;
14243#ifdef CONFIG_SND_HDA_POWER_SAVE
14244 if (!spec->loopback.amplist)
14245 spec->loopback.amplist = alc269_loopbacks;
14246#endif
14247
14248 return 0;
14249}
14250
14251/*
Kailang Yangdf694da2005-12-05 19:42:22 +010014252 * ALC861 channel source setting (2/6 channel selection for 3-stack)
14253 */
14254
14255/*
14256 * set the path ways for 2 channel output
14257 * need to set the codec line out and mic 1 pin widgets to inputs
14258 */
14259static struct hda_verb alc861_threestack_ch2_init[] = {
14260 /* set pin widget 1Ah (line in) for input */
14261 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014262 /* set pin widget 18h (mic1/2) for input, for mic also enable
14263 * the vref
14264 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014265 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14266
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014267 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14268#if 0
14269 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14270 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14271#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014272 { } /* end */
14273};
14274/*
14275 * 6ch mode
14276 * need to set the codec line out and mic 1 pin widgets to outputs
14277 */
14278static struct hda_verb alc861_threestack_ch6_init[] = {
14279 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14280 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14281 /* set pin widget 18h (mic1) for output (CLFE)*/
14282 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14283
14284 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014285 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014286
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014287 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14288#if 0
14289 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14290 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14291#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014292 { } /* end */
14293};
14294
14295static struct hda_channel_mode alc861_threestack_modes[2] = {
14296 { 2, alc861_threestack_ch2_init },
14297 { 6, alc861_threestack_ch6_init },
14298};
Takashi Iwai22309c32006-08-09 16:57:28 +020014299/* Set mic1 as input and unmute the mixer */
14300static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
14301 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14302 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14303 { } /* end */
14304};
14305/* Set mic1 as output and mute mixer */
14306static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
14307 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14308 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14309 { } /* end */
14310};
14311
14312static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
14313 { 2, alc861_uniwill_m31_ch2_init },
14314 { 4, alc861_uniwill_m31_ch4_init },
14315};
Kailang Yangdf694da2005-12-05 19:42:22 +010014316
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014317/* Set mic1 and line-in as input and unmute the mixer */
14318static struct hda_verb alc861_asus_ch2_init[] = {
14319 /* set pin widget 1Ah (line in) for input */
14320 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014321 /* set pin widget 18h (mic1/2) for input, for mic also enable
14322 * the vref
14323 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014324 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14325
14326 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14327#if 0
14328 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14329 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14330#endif
14331 { } /* end */
14332};
14333/* Set mic1 nad line-in as output and mute mixer */
14334static struct hda_verb alc861_asus_ch6_init[] = {
14335 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14336 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14337 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14338 /* set pin widget 18h (mic1) for output (CLFE)*/
14339 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14340 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14341 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
14342 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
14343
14344 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14345#if 0
14346 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14347 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14348#endif
14349 { } /* end */
14350};
14351
14352static struct hda_channel_mode alc861_asus_modes[2] = {
14353 { 2, alc861_asus_ch2_init },
14354 { 6, alc861_asus_ch6_init },
14355};
14356
Kailang Yangdf694da2005-12-05 19:42:22 +010014357/* patch-ALC861 */
14358
14359static struct snd_kcontrol_new alc861_base_mixer[] = {
14360 /* output mixer control */
14361 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14362 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14363 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14364 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14365 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14366
14367 /*Input mixer control */
14368 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14369 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14370 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14371 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14372 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14373 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14374 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14375 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14376 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14377 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014378
Kailang Yangdf694da2005-12-05 19:42:22 +010014379 { } /* end */
14380};
14381
14382static struct snd_kcontrol_new alc861_3ST_mixer[] = {
14383 /* output mixer control */
14384 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14385 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14386 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14387 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14388 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14389
14390 /* Input mixer control */
14391 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14392 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14393 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14394 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14395 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14396 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14397 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14398 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14399 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14400 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014401
Kailang Yangdf694da2005-12-05 19:42:22 +010014402 {
14403 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14404 .name = "Channel Mode",
14405 .info = alc_ch_mode_info,
14406 .get = alc_ch_mode_get,
14407 .put = alc_ch_mode_put,
14408 .private_value = ARRAY_SIZE(alc861_threestack_modes),
14409 },
14410 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014411};
14412
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014413static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014414 /* output mixer control */
14415 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14416 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14417 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014418
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014419 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014420};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014421
Takashi Iwai22309c32006-08-09 16:57:28 +020014422static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
14423 /* output mixer control */
14424 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14425 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14426 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14427 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14428 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14429
14430 /* Input mixer control */
14431 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14432 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14433 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14434 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14435 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14436 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14437 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14438 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14439 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14440 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014441
Takashi Iwai22309c32006-08-09 16:57:28 +020014442 {
14443 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14444 .name = "Channel Mode",
14445 .info = alc_ch_mode_info,
14446 .get = alc_ch_mode_get,
14447 .put = alc_ch_mode_put,
14448 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
14449 },
14450 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014451};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014452
14453static struct snd_kcontrol_new alc861_asus_mixer[] = {
14454 /* output mixer control */
14455 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14456 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14457 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14458 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14459 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14460
14461 /* Input mixer control */
14462 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14463 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14464 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14465 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14466 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14467 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14468 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14469 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14470 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014471 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
14472
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014473 {
14474 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14475 .name = "Channel Mode",
14476 .info = alc_ch_mode_info,
14477 .get = alc_ch_mode_get,
14478 .put = alc_ch_mode_put,
14479 .private_value = ARRAY_SIZE(alc861_asus_modes),
14480 },
14481 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014482};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014483
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014484/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014485static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014486 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14487 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014488 { }
14489};
14490
Kailang Yangdf694da2005-12-05 19:42:22 +010014491/*
14492 * generic initialization of ADC, input mixers and output mixers
14493 */
14494static struct hda_verb alc861_base_init_verbs[] = {
14495 /*
14496 * Unmute ADC0 and set the default input to mic-in
14497 */
14498 /* port-A for surround (rear panel) */
14499 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14500 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
14501 /* port-B for mic-in (rear panel) with vref */
14502 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14503 /* port-C for line-in (rear panel) */
14504 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14505 /* port-D for Front */
14506 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14507 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14508 /* port-E for HP out (front panel) */
14509 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14510 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014511 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014512 /* port-F for mic-in (front panel) with vref */
14513 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14514 /* port-G for CLFE (rear panel) */
14515 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14516 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14517 /* port-H for side (rear panel) */
14518 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14519 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
14520 /* CD-in */
14521 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14522 /* route front mic to ADC1*/
14523 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14524 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014525
Kailang Yangdf694da2005-12-05 19:42:22 +010014526 /* Unmute DAC0~3 & spdif out*/
14527 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14528 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14529 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14530 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14531 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014532
Kailang Yangdf694da2005-12-05 19:42:22 +010014533 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14534 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14535 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14536 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14537 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014538
Kailang Yangdf694da2005-12-05 19:42:22 +010014539 /* Unmute Stereo Mixer 15 */
14540 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14541 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14542 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014543 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014544
14545 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14546 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14547 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14548 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14549 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14550 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14551 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14552 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014553 /* hp used DAC 3 (Front) */
14554 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014555 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14556
14557 { }
14558};
14559
14560static struct hda_verb alc861_threestack_init_verbs[] = {
14561 /*
14562 * Unmute ADC0 and set the default input to mic-in
14563 */
14564 /* port-A for surround (rear panel) */
14565 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14566 /* port-B for mic-in (rear panel) with vref */
14567 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14568 /* port-C for line-in (rear panel) */
14569 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14570 /* port-D for Front */
14571 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14572 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14573 /* port-E for HP out (front panel) */
14574 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14575 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014576 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014577 /* port-F for mic-in (front panel) with vref */
14578 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14579 /* port-G for CLFE (rear panel) */
14580 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14581 /* port-H for side (rear panel) */
14582 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14583 /* CD-in */
14584 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14585 /* route front mic to ADC1*/
14586 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14587 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14588 /* Unmute DAC0~3 & spdif out*/
14589 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14590 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14591 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14592 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14593 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014594
Kailang Yangdf694da2005-12-05 19:42:22 +010014595 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14596 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14597 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14598 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14599 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014600
Kailang Yangdf694da2005-12-05 19:42:22 +010014601 /* Unmute Stereo Mixer 15 */
14602 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14603 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14604 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014605 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014606
14607 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14608 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14609 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14610 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14611 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14612 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14613 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14614 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014615 /* hp used DAC 3 (Front) */
14616 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014617 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14618 { }
14619};
Takashi Iwai22309c32006-08-09 16:57:28 +020014620
14621static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14622 /*
14623 * Unmute ADC0 and set the default input to mic-in
14624 */
14625 /* port-A for surround (rear panel) */
14626 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14627 /* port-B for mic-in (rear panel) with vref */
14628 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14629 /* port-C for line-in (rear panel) */
14630 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14631 /* port-D for Front */
14632 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14633 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14634 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014635 /* this has to be set to VREF80 */
14636 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014637 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014638 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014639 /* port-F for mic-in (front panel) with vref */
14640 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14641 /* port-G for CLFE (rear panel) */
14642 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14643 /* port-H for side (rear panel) */
14644 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14645 /* CD-in */
14646 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14647 /* route front mic to ADC1*/
14648 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14649 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14650 /* Unmute DAC0~3 & spdif out*/
14651 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14652 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14653 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14654 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14655 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014656
Takashi Iwai22309c32006-08-09 16:57:28 +020014657 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14658 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14659 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14660 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14661 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014662
Takashi Iwai22309c32006-08-09 16:57:28 +020014663 /* Unmute Stereo Mixer 15 */
14664 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14665 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14666 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014667 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014668
14669 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14670 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14671 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14672 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14673 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14674 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14675 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14676 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014677 /* hp used DAC 3 (Front) */
14678 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014679 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14680 { }
14681};
14682
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014683static struct hda_verb alc861_asus_init_verbs[] = {
14684 /*
14685 * Unmute ADC0 and set the default input to mic-in
14686 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014687 /* port-A for surround (rear panel)
14688 * according to codec#0 this is the HP jack
14689 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014690 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14691 /* route front PCM to HP */
14692 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14693 /* port-B for mic-in (rear panel) with vref */
14694 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14695 /* port-C for line-in (rear panel) */
14696 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14697 /* port-D for Front */
14698 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14699 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14700 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014701 /* this has to be set to VREF80 */
14702 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014703 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014704 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014705 /* port-F for mic-in (front panel) with vref */
14706 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14707 /* port-G for CLFE (rear panel) */
14708 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14709 /* port-H for side (rear panel) */
14710 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14711 /* CD-in */
14712 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14713 /* route front mic to ADC1*/
14714 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14715 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14716 /* Unmute DAC0~3 & spdif out*/
14717 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14718 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14719 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14720 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14721 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14722 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14723 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14724 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14725 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14726 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014727
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014728 /* Unmute Stereo Mixer 15 */
14729 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14730 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14731 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014732 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014733
14734 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14735 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14736 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14737 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14738 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14739 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14740 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14741 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014742 /* hp used DAC 3 (Front) */
14743 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014744 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14745 { }
14746};
14747
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014748/* additional init verbs for ASUS laptops */
14749static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14750 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14751 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14752 { }
14753};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014754
Kailang Yangdf694da2005-12-05 19:42:22 +010014755/*
14756 * generic initialization of ADC, input mixers and output mixers
14757 */
14758static struct hda_verb alc861_auto_init_verbs[] = {
14759 /*
14760 * Unmute ADC0 and set the default input to mic-in
14761 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014762 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014763 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014764
Kailang Yangdf694da2005-12-05 19:42:22 +010014765 /* Unmute DAC0~3 & spdif out*/
14766 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14767 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14768 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14769 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14770 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014771
Kailang Yangdf694da2005-12-05 19:42:22 +010014772 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14773 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14774 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14775 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14776 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014777
Kailang Yangdf694da2005-12-05 19:42:22 +010014778 /* Unmute Stereo Mixer 15 */
14779 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14780 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14781 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14782 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14783
Takashi Iwai1c209302009-07-22 15:17:45 +020014784 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14785 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14786 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14787 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14788 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14789 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14790 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14791 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014792
14793 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14794 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014795 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14796 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014797 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14798 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014799 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14800 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014801
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014802 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014803
14804 { }
14805};
14806
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014807static struct hda_verb alc861_toshiba_init_verbs[] = {
14808 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014809
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014810 { }
14811};
14812
14813/* toggle speaker-output according to the hp-jack state */
14814static void alc861_toshiba_automute(struct hda_codec *codec)
14815{
Wu Fengguang864f92b2009-11-18 12:38:02 +080014816 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014817
Takashi Iwai47fd8302007-08-10 17:11:07 +020014818 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14819 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14820 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14821 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014822}
14823
14824static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14825 unsigned int res)
14826{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014827 if ((res >> 26) == ALC880_HP_EVENT)
14828 alc861_toshiba_automute(codec);
14829}
14830
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014831/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014832#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14833#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14834#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14835#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14836
14837
14838#define ALC861_DIGOUT_NID 0x07
14839
14840static struct hda_channel_mode alc861_8ch_modes[1] = {
14841 { 8, NULL }
14842};
14843
14844static hda_nid_t alc861_dac_nids[4] = {
14845 /* front, surround, clfe, side */
14846 0x03, 0x06, 0x05, 0x04
14847};
14848
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014849static hda_nid_t alc660_dac_nids[3] = {
14850 /* front, clfe, surround */
14851 0x03, 0x05, 0x06
14852};
14853
Kailang Yangdf694da2005-12-05 19:42:22 +010014854static hda_nid_t alc861_adc_nids[1] = {
14855 /* ADC0-2 */
14856 0x08,
14857};
14858
14859static struct hda_input_mux alc861_capture_source = {
14860 .num_items = 5,
14861 .items = {
14862 { "Mic", 0x0 },
14863 { "Front Mic", 0x3 },
14864 { "Line", 0x1 },
14865 { "CD", 0x4 },
14866 { "Mixer", 0x5 },
14867 },
14868};
14869
Takashi Iwai1c209302009-07-22 15:17:45 +020014870static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14871{
14872 struct alc_spec *spec = codec->spec;
14873 hda_nid_t mix, srcs[5];
14874 int i, j, num;
14875
14876 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14877 return 0;
14878 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14879 if (num < 0)
14880 return 0;
14881 for (i = 0; i < num; i++) {
14882 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014883 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014884 if (type != AC_WID_AUD_OUT)
14885 continue;
14886 for (j = 0; j < spec->multiout.num_dacs; j++)
14887 if (spec->multiout.dac_nids[j] == srcs[i])
14888 break;
14889 if (j >= spec->multiout.num_dacs)
14890 return srcs[i];
14891 }
14892 return 0;
14893}
14894
Kailang Yangdf694da2005-12-05 19:42:22 +010014895/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014896static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014897 const struct auto_pin_cfg *cfg)
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 i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014901 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014902
14903 spec->multiout.dac_nids = spec->private_dac_nids;
14904 for (i = 0; i < cfg->line_outs; i++) {
14905 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014906 dac = alc861_look_for_dac(codec, nid);
14907 if (!dac)
14908 continue;
14909 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014910 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014911 return 0;
14912}
14913
Takashi Iwai1c209302009-07-22 15:17:45 +020014914static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14915 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014916{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020014917 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020014918 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14919}
14920
14921/* add playback controls from the parsed DAC table */
14922static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14923 const struct auto_pin_cfg *cfg)
14924{
14925 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014926 static const char *chname[4] = {
14927 "Front", "Surround", NULL /*CLFE*/, "Side"
14928 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014929 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014930 int i, err;
14931
14932 if (cfg->line_outs == 1) {
14933 const char *pfx = NULL;
14934 if (!cfg->hp_outs)
14935 pfx = "Master";
14936 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14937 pfx = "Speaker";
14938 if (pfx) {
14939 nid = spec->multiout.dac_nids[0];
14940 return alc861_create_out_sw(codec, pfx, nid, 3);
14941 }
14942 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014943
14944 for (i = 0; i < cfg->line_outs; i++) {
14945 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014946 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014947 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014948 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014949 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014950 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014951 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014952 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014953 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014954 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014955 return err;
14956 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014957 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014958 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014959 return err;
14960 }
14961 }
14962 return 0;
14963}
14964
Takashi Iwai1c209302009-07-22 15:17:45 +020014965static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014966{
Takashi Iwai1c209302009-07-22 15:17:45 +020014967 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014968 int err;
14969 hda_nid_t nid;
14970
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014971 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014972 return 0;
14973
14974 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014975 nid = alc861_look_for_dac(codec, pin);
14976 if (nid) {
14977 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14978 if (err < 0)
14979 return err;
14980 spec->multiout.hp_nid = nid;
14981 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014982 }
14983 return 0;
14984}
14985
14986/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014987static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014988 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014989{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014990 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014991}
14992
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014993static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14994 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014995 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014996{
Takashi Iwai1c209302009-07-22 15:17:45 +020014997 hda_nid_t mix, srcs[5];
14998 int i, num;
14999
Jacek Luczak564c5be2008-05-03 18:41:23 +020015000 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15001 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015002 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015003 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015004 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15005 return;
15006 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15007 if (num < 0)
15008 return;
15009 for (i = 0; i < num; i++) {
15010 unsigned int mute;
15011 if (srcs[i] == dac || srcs[i] == 0x15)
15012 mute = AMP_IN_UNMUTE(i);
15013 else
15014 mute = AMP_IN_MUTE(i);
15015 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15016 mute);
15017 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015018}
15019
15020static void alc861_auto_init_multi_out(struct hda_codec *codec)
15021{
15022 struct alc_spec *spec = codec->spec;
15023 int i;
15024
15025 for (i = 0; i < spec->autocfg.line_outs; i++) {
15026 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015027 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015028 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015029 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015030 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015031 }
15032}
15033
15034static void alc861_auto_init_hp_out(struct hda_codec *codec)
15035{
15036 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015037
Takashi Iwai15870f02009-10-05 08:25:13 +020015038 if (spec->autocfg.hp_outs)
15039 alc861_auto_set_output_and_unmute(codec,
15040 spec->autocfg.hp_pins[0],
15041 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015042 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015043 if (spec->autocfg.speaker_outs)
15044 alc861_auto_set_output_and_unmute(codec,
15045 spec->autocfg.speaker_pins[0],
15046 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015047 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015048}
15049
15050static void alc861_auto_init_analog_input(struct hda_codec *codec)
15051{
15052 struct alc_spec *spec = codec->spec;
15053 int i;
15054
15055 for (i = 0; i < AUTO_PIN_LAST; i++) {
15056 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010015057 if (nid >= 0x0c && nid <= 0x11)
15058 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010015059 }
15060}
15061
15062/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015063/* return 1 if successful, 0 if the proper config is not found,
15064 * or a negative error code
15065 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015066static int alc861_parse_auto_config(struct hda_codec *codec)
15067{
15068 struct alc_spec *spec = codec->spec;
15069 int err;
15070 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15071
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015072 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15073 alc861_ignore);
15074 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015075 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015076 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015077 return 0; /* can't find valid BIOS pin config */
15078
Takashi Iwai1c209302009-07-22 15:17:45 +020015079 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015080 if (err < 0)
15081 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015082 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015083 if (err < 0)
15084 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015085 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015086 if (err < 0)
15087 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015088 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015089 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015090 return err;
15091
15092 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15093
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015094 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015095 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
15096
Takashi Iwai603c4012008-07-30 15:01:44 +020015097 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015098 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015099
Takashi Iwaid88897e2008-10-31 15:01:37 +010015100 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015101
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015102 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015103 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015104
15105 spec->adc_nids = alc861_adc_nids;
15106 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015107 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015108
Kailang Yang6227cdc2010-02-25 08:36:52 +010015109 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015110
Kailang Yangdf694da2005-12-05 19:42:22 +010015111 return 1;
15112}
15113
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015114/* additional initialization for auto-configuration model */
15115static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015116{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015117 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015118 alc861_auto_init_multi_out(codec);
15119 alc861_auto_init_hp_out(codec);
15120 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015121 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015122 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015123}
15124
Takashi Iwaicb53c622007-08-10 17:21:45 +020015125#ifdef CONFIG_SND_HDA_POWER_SAVE
15126static struct hda_amp_list alc861_loopbacks[] = {
15127 { 0x15, HDA_INPUT, 0 },
15128 { 0x15, HDA_INPUT, 1 },
15129 { 0x15, HDA_INPUT, 2 },
15130 { 0x15, HDA_INPUT, 3 },
15131 { } /* end */
15132};
15133#endif
15134
Kailang Yangdf694da2005-12-05 19:42:22 +010015135
15136/*
15137 * configuration and preset
15138 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015139static const char *alc861_models[ALC861_MODEL_LAST] = {
15140 [ALC861_3ST] = "3stack",
15141 [ALC660_3ST] = "3stack-660",
15142 [ALC861_3ST_DIG] = "3stack-dig",
15143 [ALC861_6ST_DIG] = "6stack-dig",
15144 [ALC861_UNIWILL_M31] = "uniwill-m31",
15145 [ALC861_TOSHIBA] = "toshiba",
15146 [ALC861_ASUS] = "asus",
15147 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15148 [ALC861_AUTO] = "auto",
15149};
15150
15151static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015152 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015153 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15154 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15155 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015156 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015157 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015158 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015159 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15160 * Any other models that need this preset?
15161 */
15162 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015163 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15164 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015165 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15166 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15167 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15168 /* FIXME: the below seems conflict */
15169 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15170 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15171 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015172 {}
15173};
15174
15175static struct alc_config_preset alc861_presets[] = {
15176 [ALC861_3ST] = {
15177 .mixers = { alc861_3ST_mixer },
15178 .init_verbs = { alc861_threestack_init_verbs },
15179 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15180 .dac_nids = alc861_dac_nids,
15181 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15182 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015183 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015184 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15185 .adc_nids = alc861_adc_nids,
15186 .input_mux = &alc861_capture_source,
15187 },
15188 [ALC861_3ST_DIG] = {
15189 .mixers = { alc861_base_mixer },
15190 .init_verbs = { alc861_threestack_init_verbs },
15191 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15192 .dac_nids = alc861_dac_nids,
15193 .dig_out_nid = ALC861_DIGOUT_NID,
15194 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15195 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015196 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015197 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15198 .adc_nids = alc861_adc_nids,
15199 .input_mux = &alc861_capture_source,
15200 },
15201 [ALC861_6ST_DIG] = {
15202 .mixers = { alc861_base_mixer },
15203 .init_verbs = { alc861_base_init_verbs },
15204 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15205 .dac_nids = alc861_dac_nids,
15206 .dig_out_nid = ALC861_DIGOUT_NID,
15207 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
15208 .channel_mode = alc861_8ch_modes,
15209 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15210 .adc_nids = alc861_adc_nids,
15211 .input_mux = &alc861_capture_source,
15212 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015213 [ALC660_3ST] = {
15214 .mixers = { alc861_3ST_mixer },
15215 .init_verbs = { alc861_threestack_init_verbs },
15216 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
15217 .dac_nids = alc660_dac_nids,
15218 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15219 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015220 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015221 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15222 .adc_nids = alc861_adc_nids,
15223 .input_mux = &alc861_capture_source,
15224 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015225 [ALC861_UNIWILL_M31] = {
15226 .mixers = { alc861_uniwill_m31_mixer },
15227 .init_verbs = { alc861_uniwill_m31_init_verbs },
15228 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15229 .dac_nids = alc861_dac_nids,
15230 .dig_out_nid = ALC861_DIGOUT_NID,
15231 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
15232 .channel_mode = alc861_uniwill_m31_modes,
15233 .need_dac_fix = 1,
15234 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15235 .adc_nids = alc861_adc_nids,
15236 .input_mux = &alc861_capture_source,
15237 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015238 [ALC861_TOSHIBA] = {
15239 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015240 .init_verbs = { alc861_base_init_verbs,
15241 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015242 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15243 .dac_nids = alc861_dac_nids,
15244 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15245 .channel_mode = alc883_3ST_2ch_modes,
15246 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15247 .adc_nids = alc861_adc_nids,
15248 .input_mux = &alc861_capture_source,
15249 .unsol_event = alc861_toshiba_unsol_event,
15250 .init_hook = alc861_toshiba_automute,
15251 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015252 [ALC861_ASUS] = {
15253 .mixers = { alc861_asus_mixer },
15254 .init_verbs = { alc861_asus_init_verbs },
15255 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15256 .dac_nids = alc861_dac_nids,
15257 .dig_out_nid = ALC861_DIGOUT_NID,
15258 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
15259 .channel_mode = alc861_asus_modes,
15260 .need_dac_fix = 1,
15261 .hp_nid = 0x06,
15262 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15263 .adc_nids = alc861_adc_nids,
15264 .input_mux = &alc861_capture_source,
15265 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015266 [ALC861_ASUS_LAPTOP] = {
15267 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
15268 .init_verbs = { alc861_asus_init_verbs,
15269 alc861_asus_laptop_init_verbs },
15270 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15271 .dac_nids = alc861_dac_nids,
15272 .dig_out_nid = ALC861_DIGOUT_NID,
15273 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15274 .channel_mode = alc883_3ST_2ch_modes,
15275 .need_dac_fix = 1,
15276 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15277 .adc_nids = alc861_adc_nids,
15278 .input_mux = &alc861_capture_source,
15279 },
15280};
Kailang Yangdf694da2005-12-05 19:42:22 +010015281
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015282/* Pin config fixes */
15283enum {
15284 PINFIX_FSC_AMILO_PI1505,
15285};
15286
15287static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
15288 { 0x0b, 0x0221101f }, /* HP */
15289 { 0x0f, 0x90170310 }, /* speaker */
15290 { }
15291};
15292
15293static const struct alc_fixup alc861_fixups[] = {
15294 [PINFIX_FSC_AMILO_PI1505] = {
15295 .pins = alc861_fsc_amilo_pi1505_pinfix
15296 },
15297};
15298
15299static struct snd_pci_quirk alc861_fixup_tbl[] = {
15300 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
15301 {}
15302};
Kailang Yangdf694da2005-12-05 19:42:22 +010015303
15304static int patch_alc861(struct hda_codec *codec)
15305{
15306 struct alc_spec *spec;
15307 int board_config;
15308 int err;
15309
Robert P. J. Daydc041e02006-12-19 14:44:15 +010015310 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010015311 if (spec == NULL)
15312 return -ENOMEM;
15313
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015314 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015315
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015316 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
15317 alc861_models,
15318 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015319
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015320 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015321 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15322 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010015323 board_config = ALC861_AUTO;
15324 }
15325
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015326 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups);
15327
Kailang Yangdf694da2005-12-05 19:42:22 +010015328 if (board_config == ALC861_AUTO) {
15329 /* automatic parse from the BIOS config */
15330 err = alc861_parse_auto_config(codec);
15331 if (err < 0) {
15332 alc_free(codec);
15333 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015334 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015335 printk(KERN_INFO
15336 "hda_codec: Cannot set up configuration "
15337 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010015338 board_config = ALC861_3ST_DIG;
15339 }
15340 }
15341
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015342 err = snd_hda_attach_beep_device(codec, 0x23);
15343 if (err < 0) {
15344 alc_free(codec);
15345 return err;
15346 }
15347
Kailang Yangdf694da2005-12-05 19:42:22 +010015348 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015349 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015350
Kailang Yangdf694da2005-12-05 19:42:22 +010015351 spec->stream_analog_playback = &alc861_pcm_analog_playback;
15352 spec->stream_analog_capture = &alc861_pcm_analog_capture;
15353
Kailang Yangdf694da2005-12-05 19:42:22 +010015354 spec->stream_digital_playback = &alc861_pcm_digital_playback;
15355 spec->stream_digital_capture = &alc861_pcm_digital_capture;
15356
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010015357 if (!spec->cap_mixer)
15358 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015359 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
15360
Takashi Iwai2134ea42008-01-10 16:53:55 +010015361 spec->vmaster_nid = 0x03;
15362
Kailang Yangdf694da2005-12-05 19:42:22 +010015363 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050015364 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015365 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015366#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015367 spec->power_hook = alc_power_eapd;
15368#endif
15369 }
15370#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015371 if (!spec->loopback.amplist)
15372 spec->loopback.amplist = alc861_loopbacks;
15373#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015374
Kailang Yangdf694da2005-12-05 19:42:22 +010015375 return 0;
15376}
15377
15378/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015379 * ALC861-VD support
15380 *
15381 * Based on ALC882
15382 *
15383 * In addition, an independent DAC
15384 */
15385#define ALC861VD_DIGOUT_NID 0x06
15386
15387static hda_nid_t alc861vd_dac_nids[4] = {
15388 /* front, surr, clfe, side surr */
15389 0x02, 0x03, 0x04, 0x05
15390};
15391
15392/* dac_nids for ALC660vd are in a different order - according to
15393 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015394 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015395 * of ALC660vd codecs, but for now there is only 3stack mixer
15396 * - and it is the same as in 861vd.
15397 * adc_nids in ALC660vd are (is) the same as in 861vd
15398 */
15399static hda_nid_t alc660vd_dac_nids[3] = {
15400 /* front, rear, clfe, rear_surr */
15401 0x02, 0x04, 0x03
15402};
15403
15404static hda_nid_t alc861vd_adc_nids[1] = {
15405 /* ADC0 */
15406 0x09,
15407};
15408
Takashi Iwaie1406342008-02-11 18:32:32 +010015409static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
15410
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015411/* input MUX */
15412/* FIXME: should be a matrix-type input source selection */
15413static struct hda_input_mux alc861vd_capture_source = {
15414 .num_items = 4,
15415 .items = {
15416 { "Mic", 0x0 },
15417 { "Front Mic", 0x1 },
15418 { "Line", 0x2 },
15419 { "CD", 0x4 },
15420 },
15421};
15422
Kailang Yang272a5272007-05-14 11:00:38 +020015423static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010015424 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020015425 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010015426 { "Ext Mic", 0x0 },
15427 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020015428 },
15429};
15430
Kailang Yangd1a991a2007-08-15 16:21:59 +020015431static struct hda_input_mux alc861vd_hp_capture_source = {
15432 .num_items = 2,
15433 .items = {
15434 { "Front Mic", 0x0 },
15435 { "ATAPI Mic", 0x1 },
15436 },
15437};
15438
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015439/*
15440 * 2ch mode
15441 */
15442static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
15443 { 2, NULL }
15444};
15445
15446/*
15447 * 6ch mode
15448 */
15449static struct hda_verb alc861vd_6stack_ch6_init[] = {
15450 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15451 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15452 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15453 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15454 { } /* end */
15455};
15456
15457/*
15458 * 8ch mode
15459 */
15460static struct hda_verb alc861vd_6stack_ch8_init[] = {
15461 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15462 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15463 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15464 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15465 { } /* end */
15466};
15467
15468static struct hda_channel_mode alc861vd_6stack_modes[2] = {
15469 { 6, alc861vd_6stack_ch6_init },
15470 { 8, alc861vd_6stack_ch8_init },
15471};
15472
15473static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
15474 {
15475 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15476 .name = "Channel Mode",
15477 .info = alc_ch_mode_info,
15478 .get = alc_ch_mode_get,
15479 .put = alc_ch_mode_put,
15480 },
15481 { } /* end */
15482};
15483
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015484/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15485 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15486 */
15487static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
15488 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15489 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15490
15491 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15492 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
15493
15494 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
15495 HDA_OUTPUT),
15496 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
15497 HDA_OUTPUT),
15498 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
15499 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
15500
15501 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
15502 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
15503
15504 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15505
15506 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15507 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15508 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15509
15510 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15511 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15512 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15513
15514 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15515 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15516
15517 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15518 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15519
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015520 { } /* end */
15521};
15522
15523static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
15524 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15525 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15526
15527 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15528
15529 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15530 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15531 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15532
15533 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15534 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15535 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15536
15537 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15538 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15539
15540 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15541 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15542
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015543 { } /* end */
15544};
15545
Kailang Yangbdd148a2007-05-08 15:19:08 +020015546static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
15547 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15548 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
15549 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15550
15551 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15552
15553 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15554 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15555 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15556
15557 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15558 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15559 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15560
15561 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15562 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15563
15564 { } /* end */
15565};
15566
Tobin Davisb419f342008-03-07 11:57:51 +010015567/* Pin assignment: Speaker=0x14, HP = 0x15,
15568 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015569 */
15570static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015571 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15572 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015573 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15574 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015575 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15576 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15577 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15578 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15579 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15580 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015581 { } /* end */
15582};
15583
Kailang Yangd1a991a2007-08-15 16:21:59 +020015584/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15585 * Front Mic=0x18, ATAPI Mic = 0x19,
15586 */
15587static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15588 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15589 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15590 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15591 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15592 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15593 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15594 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15595 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015596
Kailang Yangd1a991a2007-08-15 16:21:59 +020015597 { } /* end */
15598};
15599
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015600/*
15601 * generic initialization of ADC, input mixers and output mixers
15602 */
15603static struct hda_verb alc861vd_volume_init_verbs[] = {
15604 /*
15605 * Unmute ADC0 and set the default input to mic-in
15606 */
15607 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15608 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15609
15610 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15611 * the analog-loopback mixer widget
15612 */
15613 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015614 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15615 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15616 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15617 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15618 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015619
15620 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015621 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015625
15626 /*
15627 * Set up output mixers (0x02 - 0x05)
15628 */
15629 /* set vol=0 to output mixers */
15630 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15631 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15632 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15633 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15634
15635 /* set up input amps for analog loopback */
15636 /* Amp Indices: DAC = 0, mixer = 1 */
15637 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15638 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15639 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15640 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15641 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15642 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15643 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15644 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15645
15646 { }
15647};
15648
15649/*
15650 * 3-stack pin configuration:
15651 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15652 */
15653static struct hda_verb alc861vd_3stack_init_verbs[] = {
15654 /*
15655 * Set pin mode and muting
15656 */
15657 /* set front pin widgets 0x14 for output */
15658 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15659 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15660 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15661
15662 /* Mic (rear) pin: input vref at 80% */
15663 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15664 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15665 /* Front Mic pin: input vref at 80% */
15666 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15667 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15668 /* Line In pin: input */
15669 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15670 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15671 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15672 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15673 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15674 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15675 /* CD pin widget for input */
15676 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15677
15678 { }
15679};
15680
15681/*
15682 * 6-stack pin configuration:
15683 */
15684static struct hda_verb alc861vd_6stack_init_verbs[] = {
15685 /*
15686 * Set pin mode and muting
15687 */
15688 /* set front pin widgets 0x14 for output */
15689 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15690 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15691 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15692
15693 /* Rear Pin: output 1 (0x0d) */
15694 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15695 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15696 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15697 /* CLFE Pin: output 2 (0x0e) */
15698 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15699 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15700 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15701 /* Side Pin: output 3 (0x0f) */
15702 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15703 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15704 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15705
15706 /* Mic (rear) pin: input vref at 80% */
15707 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15708 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15709 /* Front Mic pin: input vref at 80% */
15710 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15711 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15712 /* Line In pin: input */
15713 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15714 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15715 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15716 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15717 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15718 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15719 /* CD pin widget for input */
15720 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15721
15722 { }
15723};
15724
Kailang Yangbdd148a2007-05-08 15:19:08 +020015725static struct hda_verb alc861vd_eapd_verbs[] = {
15726 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15727 { }
15728};
15729
Kailang Yangf9423e72008-05-27 12:32:25 +020015730static struct hda_verb alc660vd_eapd_verbs[] = {
15731 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15732 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15733 { }
15734};
15735
Kailang Yangbdd148a2007-05-08 15:19:08 +020015736static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15737 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15738 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15739 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15740 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015741 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015742 {}
15743};
15744
Kailang Yangbdd148a2007-05-08 15:19:08 +020015745static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15746{
15747 unsigned int present;
15748 unsigned char bits;
15749
Wu Fengguang864f92b2009-11-18 12:38:02 +080015750 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020015751 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080015752
Takashi Iwai47fd8302007-08-10 17:11:07 +020015753 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15754 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015755}
15756
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015757static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015758{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015759 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015760 spec->autocfg.hp_pins[0] = 0x1b;
15761 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015762}
15763
15764static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15765{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015766 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015767 alc861vd_lenovo_mic_automute(codec);
15768}
15769
15770static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15771 unsigned int res)
15772{
15773 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015774 case ALC880_MIC_EVENT:
15775 alc861vd_lenovo_mic_automute(codec);
15776 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015777 default:
15778 alc_automute_amp_unsol_event(codec, res);
15779 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015780 }
15781}
15782
Kailang Yang272a5272007-05-14 11:00:38 +020015783static struct hda_verb alc861vd_dallas_verbs[] = {
15784 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15785 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15786 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15787 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15788
15789 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15790 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15791 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15792 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15793 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15794 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15795 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15796 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015797
Kailang Yang272a5272007-05-14 11:00:38 +020015798 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15799 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15800 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15801 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15802 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15803 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15804 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15805 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15806
15807 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15808 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15809 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15810 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15811 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15812 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15813 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15814 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15815
15816 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15817 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15818 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15819 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15820
15821 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015822 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015823 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15824
15825 { } /* end */
15826};
15827
15828/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015829static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015830{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015831 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015832
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015833 spec->autocfg.hp_pins[0] = 0x15;
15834 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015835}
15836
Takashi Iwaicb53c622007-08-10 17:21:45 +020015837#ifdef CONFIG_SND_HDA_POWER_SAVE
15838#define alc861vd_loopbacks alc880_loopbacks
15839#endif
15840
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015841/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015842#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15843#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15844#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15845#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15846
15847/*
15848 * configuration and preset
15849 */
15850static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15851 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015852 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015853 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015854 [ALC861VD_3ST] = "3stack",
15855 [ALC861VD_3ST_DIG] = "3stack-digout",
15856 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015857 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015858 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015859 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015860 [ALC861VD_AUTO] = "auto",
15861};
15862
15863static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015864 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15865 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015866 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015867 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015868 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015869 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015870 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015871 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015872 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015873 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015874 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015875 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015876 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015877 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015878 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015879 {}
15880};
15881
15882static struct alc_config_preset alc861vd_presets[] = {
15883 [ALC660VD_3ST] = {
15884 .mixers = { alc861vd_3st_mixer },
15885 .init_verbs = { alc861vd_volume_init_verbs,
15886 alc861vd_3stack_init_verbs },
15887 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15888 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015889 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15890 .channel_mode = alc861vd_3stack_2ch_modes,
15891 .input_mux = &alc861vd_capture_source,
15892 },
Mike Crash6963f842007-06-25 12:12:51 +020015893 [ALC660VD_3ST_DIG] = {
15894 .mixers = { alc861vd_3st_mixer },
15895 .init_verbs = { alc861vd_volume_init_verbs,
15896 alc861vd_3stack_init_verbs },
15897 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15898 .dac_nids = alc660vd_dac_nids,
15899 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015900 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15901 .channel_mode = alc861vd_3stack_2ch_modes,
15902 .input_mux = &alc861vd_capture_source,
15903 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015904 [ALC861VD_3ST] = {
15905 .mixers = { alc861vd_3st_mixer },
15906 .init_verbs = { alc861vd_volume_init_verbs,
15907 alc861vd_3stack_init_verbs },
15908 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15909 .dac_nids = alc861vd_dac_nids,
15910 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15911 .channel_mode = alc861vd_3stack_2ch_modes,
15912 .input_mux = &alc861vd_capture_source,
15913 },
15914 [ALC861VD_3ST_DIG] = {
15915 .mixers = { alc861vd_3st_mixer },
15916 .init_verbs = { alc861vd_volume_init_verbs,
15917 alc861vd_3stack_init_verbs },
15918 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15919 .dac_nids = alc861vd_dac_nids,
15920 .dig_out_nid = ALC861VD_DIGOUT_NID,
15921 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15922 .channel_mode = alc861vd_3stack_2ch_modes,
15923 .input_mux = &alc861vd_capture_source,
15924 },
15925 [ALC861VD_6ST_DIG] = {
15926 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15927 .init_verbs = { alc861vd_volume_init_verbs,
15928 alc861vd_6stack_init_verbs },
15929 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15930 .dac_nids = alc861vd_dac_nids,
15931 .dig_out_nid = ALC861VD_DIGOUT_NID,
15932 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15933 .channel_mode = alc861vd_6stack_modes,
15934 .input_mux = &alc861vd_capture_source,
15935 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015936 [ALC861VD_LENOVO] = {
15937 .mixers = { alc861vd_lenovo_mixer },
15938 .init_verbs = { alc861vd_volume_init_verbs,
15939 alc861vd_3stack_init_verbs,
15940 alc861vd_eapd_verbs,
15941 alc861vd_lenovo_unsol_verbs },
15942 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15943 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015944 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15945 .channel_mode = alc861vd_3stack_2ch_modes,
15946 .input_mux = &alc861vd_capture_source,
15947 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015948 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015949 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015950 },
Kailang Yang272a5272007-05-14 11:00:38 +020015951 [ALC861VD_DALLAS] = {
15952 .mixers = { alc861vd_dallas_mixer },
15953 .init_verbs = { alc861vd_dallas_verbs },
15954 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15955 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015956 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15957 .channel_mode = alc861vd_3stack_2ch_modes,
15958 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015959 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015960 .setup = alc861vd_dallas_setup,
15961 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015962 },
15963 [ALC861VD_HP] = {
15964 .mixers = { alc861vd_hp_mixer },
15965 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15966 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15967 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015968 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015969 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15970 .channel_mode = alc861vd_3stack_2ch_modes,
15971 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015972 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015973 .setup = alc861vd_dallas_setup,
15974 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015975 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015976 [ALC660VD_ASUS_V1S] = {
15977 .mixers = { alc861vd_lenovo_mixer },
15978 .init_verbs = { alc861vd_volume_init_verbs,
15979 alc861vd_3stack_init_verbs,
15980 alc861vd_eapd_verbs,
15981 alc861vd_lenovo_unsol_verbs },
15982 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15983 .dac_nids = alc660vd_dac_nids,
15984 .dig_out_nid = ALC861VD_DIGOUT_NID,
15985 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15986 .channel_mode = alc861vd_3stack_2ch_modes,
15987 .input_mux = &alc861vd_capture_source,
15988 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015989 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015990 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015991 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015992};
15993
15994/*
15995 * BIOS auto configuration
15996 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015997static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15998 const struct auto_pin_cfg *cfg)
15999{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016000 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016001}
16002
16003
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016004static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16005 hda_nid_t nid, int pin_type, int dac_idx)
16006{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016007 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016008}
16009
16010static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16011{
16012 struct alc_spec *spec = codec->spec;
16013 int i;
16014
16015 for (i = 0; i <= HDA_SIDE; i++) {
16016 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016017 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016018 if (nid)
16019 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016020 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016021 }
16022}
16023
16024
16025static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16026{
16027 struct alc_spec *spec = codec->spec;
16028 hda_nid_t pin;
16029
16030 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016031 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016032 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016033 pin = spec->autocfg.speaker_pins[0];
16034 if (pin)
16035 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016036}
16037
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016038#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16039
16040static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16041{
16042 struct alc_spec *spec = codec->spec;
16043 int i;
16044
16045 for (i = 0; i < AUTO_PIN_LAST; i++) {
16046 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020016047 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016048 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016049 if (nid != ALC861VD_PIN_CD_NID &&
16050 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016051 snd_hda_codec_write(codec, nid, 0,
16052 AC_VERB_SET_AMP_GAIN_MUTE,
16053 AMP_OUT_MUTE);
16054 }
16055 }
16056}
16057
Takashi Iwaif511b012008-08-15 16:46:42 +020016058#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16059
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016060#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16061#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16062
16063/* add playback controls from the parsed DAC table */
16064/* Based on ALC880 version. But ALC861VD has separate,
16065 * different NIDs for mute/unmute switch and volume control */
16066static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16067 const struct auto_pin_cfg *cfg)
16068{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016069 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16070 hda_nid_t nid_v, nid_s;
16071 int i, err;
16072
16073 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016074 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016075 continue;
16076 nid_v = alc861vd_idx_to_mixer_vol(
16077 alc880_dac_to_idx(
16078 spec->multiout.dac_nids[i]));
16079 nid_s = alc861vd_idx_to_mixer_switch(
16080 alc880_dac_to_idx(
16081 spec->multiout.dac_nids[i]));
16082
16083 if (i == 2) {
16084 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016085 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16086 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016087 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16088 HDA_OUTPUT));
16089 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016090 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016091 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16092 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016093 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16094 HDA_OUTPUT));
16095 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016096 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016097 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16098 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016099 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16100 HDA_INPUT));
16101 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016102 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016103 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16104 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016105 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16106 HDA_INPUT));
16107 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016108 return err;
16109 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016110 const char *pfx;
16111 if (cfg->line_outs == 1 &&
16112 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16113 if (!cfg->hp_pins)
16114 pfx = "Speaker";
16115 else
16116 pfx = "PCM";
16117 } else
16118 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016119 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016120 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16121 HDA_OUTPUT));
16122 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016123 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016124 if (cfg->line_outs == 1 &&
16125 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16126 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016127 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016128 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016129 HDA_INPUT));
16130 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016131 return err;
16132 }
16133 }
16134 return 0;
16135}
16136
16137/* add playback controls for speaker and HP outputs */
16138/* Based on ALC880 version. But ALC861VD has separate,
16139 * different NIDs for mute/unmute switch and volume control */
16140static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16141 hda_nid_t pin, const char *pfx)
16142{
16143 hda_nid_t nid_v, nid_s;
16144 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016145
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016146 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016147 return 0;
16148
16149 if (alc880_is_fixed_pin(pin)) {
16150 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16151 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016152 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016153 spec->multiout.hp_nid = nid_v;
16154 else
16155 spec->multiout.extra_out_nid[0] = nid_v;
16156 /* control HP volume/switch on the output mixer amp */
16157 nid_v = alc861vd_idx_to_mixer_vol(
16158 alc880_fixed_pin_idx(pin));
16159 nid_s = alc861vd_idx_to_mixer_switch(
16160 alc880_fixed_pin_idx(pin));
16161
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016162 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016163 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16164 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016165 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016166 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016167 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16168 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016169 return err;
16170 } else if (alc880_is_multi_pin(pin)) {
16171 /* set manual connection */
16172 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016173 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016174 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16175 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016176 return err;
16177 }
16178 return 0;
16179}
16180
16181/* parse the BIOS configuration and set up the alc_spec
16182 * return 1 if successful, 0 if the proper config is not found,
16183 * or a negative error code
16184 * Based on ALC880 version - had to change it to override
16185 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16186static int alc861vd_parse_auto_config(struct hda_codec *codec)
16187{
16188 struct alc_spec *spec = codec->spec;
16189 int err;
16190 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16191
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016192 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16193 alc861vd_ignore);
16194 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016195 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016196 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016197 return 0; /* can't find valid BIOS pin config */
16198
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016199 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16200 if (err < 0)
16201 return err;
16202 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
16203 if (err < 0)
16204 return err;
16205 err = alc861vd_auto_create_extra_out(spec,
16206 spec->autocfg.speaker_pins[0],
16207 "Speaker");
16208 if (err < 0)
16209 return err;
16210 err = alc861vd_auto_create_extra_out(spec,
16211 spec->autocfg.hp_pins[0],
16212 "Headphone");
16213 if (err < 0)
16214 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016215 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016216 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016217 return err;
16218
16219 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16220
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016221 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016222 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
16223
Takashi Iwai603c4012008-07-30 15:01:44 +020016224 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016225 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016226
Takashi Iwaid88897e2008-10-31 15:01:37 +010016227 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016228
16229 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016230 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016231
Takashi Iwai776e1842007-08-29 15:07:11 +020016232 err = alc_auto_add_mic_boost(codec);
16233 if (err < 0)
16234 return err;
16235
Kailang Yang6227cdc2010-02-25 08:36:52 +010016236 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016237
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016238 return 1;
16239}
16240
16241/* additional initialization for auto-configuration model */
16242static void alc861vd_auto_init(struct hda_codec *codec)
16243{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016244 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016245 alc861vd_auto_init_multi_out(codec);
16246 alc861vd_auto_init_hp_out(codec);
16247 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016248 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016249 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016250 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016251}
16252
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016253enum {
16254 ALC660VD_FIX_ASUS_GPIO1
16255};
16256
16257/* reset GPIO1 */
16258static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
16259 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
16260 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
16261 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
16262 { }
16263};
16264
16265static const struct alc_fixup alc861vd_fixups[] = {
16266 [ALC660VD_FIX_ASUS_GPIO1] = {
16267 .verbs = alc660vd_fix_asus_gpio1_verbs,
16268 },
16269};
16270
16271static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
16272 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
16273 {}
16274};
16275
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016276static int patch_alc861vd(struct hda_codec *codec)
16277{
16278 struct alc_spec *spec;
16279 int err, board_config;
16280
16281 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16282 if (spec == NULL)
16283 return -ENOMEM;
16284
16285 codec->spec = spec;
16286
16287 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
16288 alc861vd_models,
16289 alc861vd_cfg_tbl);
16290
16291 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016292 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16293 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016294 board_config = ALC861VD_AUTO;
16295 }
16296
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016297 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
16298
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016299 if (board_config == ALC861VD_AUTO) {
16300 /* automatic parse from the BIOS config */
16301 err = alc861vd_parse_auto_config(codec);
16302 if (err < 0) {
16303 alc_free(codec);
16304 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016305 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016306 printk(KERN_INFO
16307 "hda_codec: Cannot set up configuration "
16308 "from BIOS. Using base mode...\n");
16309 board_config = ALC861VD_3ST;
16310 }
16311 }
16312
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016313 err = snd_hda_attach_beep_device(codec, 0x23);
16314 if (err < 0) {
16315 alc_free(codec);
16316 return err;
16317 }
16318
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016319 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016320 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016321
Kailang Yang2f893282008-05-27 12:14:47 +020016322 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020016323 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010016324 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020016325 }
16326
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016327 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
16328 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
16329
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016330 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
16331 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16332
Takashi Iwaidd704692009-08-11 08:45:11 +020016333 if (!spec->adc_nids) {
16334 spec->adc_nids = alc861vd_adc_nids;
16335 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
16336 }
16337 if (!spec->capsrc_nids)
16338 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016339
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016340 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016341 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016342
Takashi Iwai2134ea42008-01-10 16:53:55 +010016343 spec->vmaster_nid = 0x02;
16344
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016345 codec->patch_ops = alc_patch_ops;
16346
16347 if (board_config == ALC861VD_AUTO)
16348 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016349#ifdef CONFIG_SND_HDA_POWER_SAVE
16350 if (!spec->loopback.amplist)
16351 spec->loopback.amplist = alc861vd_loopbacks;
16352#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016353
16354 return 0;
16355}
16356
16357/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016358 * ALC662 support
16359 *
16360 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
16361 * configuration. Each pin widget can choose any input DACs and a mixer.
16362 * Each ADC is connected from a mixer of all inputs. This makes possible
16363 * 6-channel independent captures.
16364 *
16365 * In addition, an independent DAC for the multi-playback (not used in this
16366 * driver yet).
16367 */
16368#define ALC662_DIGOUT_NID 0x06
16369#define ALC662_DIGIN_NID 0x0a
16370
16371static hda_nid_t alc662_dac_nids[4] = {
16372 /* front, rear, clfe, rear_surr */
16373 0x02, 0x03, 0x04
16374};
16375
Kailang Yang622e84c2009-04-21 07:39:04 +020016376static hda_nid_t alc272_dac_nids[2] = {
16377 0x02, 0x03
16378};
16379
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016380static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016381 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016382 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016383};
Takashi Iwaie1406342008-02-11 18:32:32 +010016384
Kailang Yang622e84c2009-04-21 07:39:04 +020016385static hda_nid_t alc272_adc_nids[1] = {
16386 /* ADC1-2 */
16387 0x08,
16388};
16389
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016390static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016391static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
16392
Takashi Iwaie1406342008-02-11 18:32:32 +010016393
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016394/* input MUX */
16395/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016396static struct hda_input_mux alc662_capture_source = {
16397 .num_items = 4,
16398 .items = {
16399 { "Mic", 0x0 },
16400 { "Front Mic", 0x1 },
16401 { "Line", 0x2 },
16402 { "CD", 0x4 },
16403 },
16404};
16405
16406static struct hda_input_mux alc662_lenovo_101e_capture_source = {
16407 .num_items = 2,
16408 .items = {
16409 { "Mic", 0x1 },
16410 { "Line", 0x2 },
16411 },
16412};
Kailang Yang291702f2007-10-16 14:28:03 +020016413
Kailang Yang6dda9f42008-05-27 12:05:31 +020016414static struct hda_input_mux alc663_capture_source = {
16415 .num_items = 3,
16416 .items = {
16417 { "Mic", 0x0 },
16418 { "Front Mic", 0x1 },
16419 { "Line", 0x2 },
16420 },
16421};
16422
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016423#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020016424static struct hda_input_mux alc272_nc10_capture_source = {
16425 .num_items = 16,
16426 .items = {
16427 { "Autoselect Mic", 0x0 },
16428 { "Internal Mic", 0x1 },
16429 { "In-0x02", 0x2 },
16430 { "In-0x03", 0x3 },
16431 { "In-0x04", 0x4 },
16432 { "In-0x05", 0x5 },
16433 { "In-0x06", 0x6 },
16434 { "In-0x07", 0x7 },
16435 { "In-0x08", 0x8 },
16436 { "In-0x09", 0x9 },
16437 { "In-0x0a", 0x0a },
16438 { "In-0x0b", 0x0b },
16439 { "In-0x0c", 0x0c },
16440 { "In-0x0d", 0x0d },
16441 { "In-0x0e", 0x0e },
16442 { "In-0x0f", 0x0f },
16443 },
16444};
16445#endif
16446
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016447/*
16448 * 2ch mode
16449 */
16450static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
16451 { 2, NULL }
16452};
16453
16454/*
16455 * 2ch mode
16456 */
16457static struct hda_verb alc662_3ST_ch2_init[] = {
16458 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
16459 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16460 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
16461 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16462 { } /* end */
16463};
16464
16465/*
16466 * 6ch mode
16467 */
16468static struct hda_verb alc662_3ST_ch6_init[] = {
16469 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16470 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16471 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
16472 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16473 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16474 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
16475 { } /* end */
16476};
16477
16478static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
16479 { 2, alc662_3ST_ch2_init },
16480 { 6, alc662_3ST_ch6_init },
16481};
16482
16483/*
16484 * 2ch mode
16485 */
16486static struct hda_verb alc662_sixstack_ch6_init[] = {
16487 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16488 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16489 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16490 { } /* end */
16491};
16492
16493/*
16494 * 6ch mode
16495 */
16496static struct hda_verb alc662_sixstack_ch8_init[] = {
16497 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16498 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16499 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16500 { } /* end */
16501};
16502
16503static struct hda_channel_mode alc662_5stack_modes[2] = {
16504 { 2, alc662_sixstack_ch6_init },
16505 { 6, alc662_sixstack_ch8_init },
16506};
16507
16508/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16509 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16510 */
16511
16512static struct snd_kcontrol_new alc662_base_mixer[] = {
16513 /* output mixer control */
16514 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016515 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016516 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016517 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016518 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16519 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016520 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16521 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016522 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16523
16524 /*Input mixer control */
16525 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
16526 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
16527 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
16528 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
16529 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
16530 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
16531 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
16532 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016533 { } /* end */
16534};
16535
16536static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
16537 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016538 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016539 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16540 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16541 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16542 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16543 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16544 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16545 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16546 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16547 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016548 { } /* end */
16549};
16550
16551static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
16552 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016553 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016554 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016555 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016556 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16557 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016558 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16559 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016560 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16561 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16562 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16563 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16564 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16565 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16566 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16567 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16568 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016569 { } /* end */
16570};
16571
16572static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16573 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16574 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016575 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16576 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016577 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16578 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16579 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16580 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16581 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016582 { } /* end */
16583};
16584
Kailang Yang291702f2007-10-16 14:28:03 +020016585static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016586 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16587 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016588
16589 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16590 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16591 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16592
16593 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16594 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16595 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16596 { } /* end */
16597};
16598
Kailang Yang8c427222008-01-10 13:03:59 +010016599static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016600 ALC262_HIPPO_MASTER_SWITCH,
16601 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016602 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016603 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16604 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016605 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16606 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16607 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16608 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16609 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16610 { } /* end */
16611};
16612
Kailang Yangf1d4e282008-08-26 14:03:29 +020016613static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16614 .ops = &snd_hda_bind_vol,
16615 .values = {
16616 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16617 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16618 0
16619 },
16620};
16621
16622static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16623 .ops = &snd_hda_bind_sw,
16624 .values = {
16625 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16626 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16627 0
16628 },
16629};
16630
Kailang Yang6dda9f42008-05-27 12:05:31 +020016631static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016632 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16633 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16634 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16635 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16636 { } /* end */
16637};
16638
16639static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16640 .ops = &snd_hda_bind_sw,
16641 .values = {
16642 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16643 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16644 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16645 0
16646 },
16647};
16648
16649static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16650 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16651 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16652 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16653 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16654 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16655 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16656
16657 { } /* end */
16658};
16659
16660static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16661 .ops = &snd_hda_bind_sw,
16662 .values = {
16663 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16664 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16665 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16666 0
16667 },
16668};
16669
16670static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16671 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16672 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16673 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16674 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16675 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16676 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16677 { } /* end */
16678};
16679
16680static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016681 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16682 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016683 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16684 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16685 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16686 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16687 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16688 { } /* end */
16689};
16690
16691static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16692 .ops = &snd_hda_bind_vol,
16693 .values = {
16694 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16695 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16696 0
16697 },
16698};
16699
16700static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16701 .ops = &snd_hda_bind_sw,
16702 .values = {
16703 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16704 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16705 0
16706 },
16707};
16708
16709static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16710 HDA_BIND_VOL("Master Playback Volume",
16711 &alc663_asus_two_bind_master_vol),
16712 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16713 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016714 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16715 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16716 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016717 { } /* end */
16718};
16719
16720static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16721 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16722 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16723 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16724 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16725 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16726 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016727 { } /* end */
16728};
16729
16730static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16731 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16732 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16733 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16734 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16735 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16736
16737 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16738 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16739 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16740 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16741 { } /* end */
16742};
16743
16744static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16745 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16746 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16747 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16748
16749 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16750 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16751 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16752 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16753 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16754 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16755 { } /* end */
16756};
16757
Kailang Yangebb83ee2009-12-17 12:23:00 +010016758static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
16759 .ops = &snd_hda_bind_sw,
16760 .values = {
16761 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16762 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16763 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16764 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16765 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16766 0
16767 },
16768};
16769
16770static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
16771 .ops = &snd_hda_bind_sw,
16772 .values = {
16773 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16774 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16775 0
16776 },
16777};
16778
16779static struct snd_kcontrol_new alc663_mode7_mixer[] = {
16780 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16781 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16782 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16783 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16784 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16785 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16786 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16787 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16788 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16789 { } /* end */
16790};
16791
16792static struct snd_kcontrol_new alc663_mode8_mixer[] = {
16793 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16794 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16795 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16796 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16797 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16798 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16799 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16800 { } /* end */
16801};
16802
16803
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016804static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16805 {
16806 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16807 .name = "Channel Mode",
16808 .info = alc_ch_mode_info,
16809 .get = alc_ch_mode_get,
16810 .put = alc_ch_mode_put,
16811 },
16812 { } /* end */
16813};
16814
16815static struct hda_verb alc662_init_verbs[] = {
16816 /* ADC: mute amp left and right */
16817 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16818 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016819
Kailang Yangb60dd392007-09-20 12:50:29 +020016820 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16821 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16822 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16823 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16824 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16825 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016826
16827 /* Front Pin: output 0 (0x0c) */
16828 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16829 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16830
16831 /* Rear Pin: output 1 (0x0d) */
16832 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16833 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16834
16835 /* CLFE Pin: output 2 (0x0e) */
16836 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16837 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16838
16839 /* Mic (rear) pin: input vref at 80% */
16840 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16841 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16842 /* Front Mic pin: input vref at 80% */
16843 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16844 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16845 /* Line In pin: input */
16846 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16847 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16848 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16849 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16850 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16851 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16852 /* CD pin widget for input */
16853 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16854
16855 /* FIXME: use matrix-type input source selection */
16856 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16857 /* Input mixer */
16858 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016859 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016860
16861 /* always trun on EAPD */
16862 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16863 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16864
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016865 { }
16866};
16867
Kailang Yangcec27c82010-02-04 14:18:18 +010016868static struct hda_verb alc663_init_verbs[] = {
16869 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16870 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16871 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16872 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16873 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16874 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16875 { }
16876};
16877
16878static struct hda_verb alc272_init_verbs[] = {
16879 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16880 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16881 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16882 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16883 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16884 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16885 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16886 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16887 { }
16888};
16889
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016890static struct hda_verb alc662_sue_init_verbs[] = {
16891 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16892 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016893 {}
16894};
16895
16896static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16897 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16898 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16899 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016900};
16901
Kailang Yang8c427222008-01-10 13:03:59 +010016902/* Set Unsolicited Event*/
16903static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16904 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16905 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16906 {}
16907};
16908
Kailang Yang6dda9f42008-05-27 12:05:31 +020016909static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016910 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16911 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016912 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16913 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016914 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16915 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16916 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016917 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16918 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16919 {}
16920};
16921
Kailang Yangf1d4e282008-08-26 14:03:29 +020016922static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16923 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16924 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16925 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16926 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16927 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16928 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16929 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16930 {}
16931};
16932
16933static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16934 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16935 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16936 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16937 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16938 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16939 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16940 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16941 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16942 {}
16943};
16944
16945static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16946 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16947 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16948 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16949 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16950 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16951 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16952 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16953 {}
16954};
16955
16956static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
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, 0x0}, /* Headphone */
16961 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16962 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16963 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16964 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16965 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16966 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16967 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16968 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16969 {}
16970};
16971
16972static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16973 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16974 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16975 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16976 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16977 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16978 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16979 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16980 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16981 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16982 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16983 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16984 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16985 {}
16986};
16987
Kailang Yang6dda9f42008-05-27 12:05:31 +020016988static struct hda_verb alc663_g71v_init_verbs[] = {
16989 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16990 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16991 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16992
16993 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16994 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16995 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16996
16997 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16998 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16999 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17000 {}
17001};
17002
17003static struct hda_verb alc663_g50v_init_verbs[] = {
17004 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17005 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17006 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17007
17008 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17009 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17010 {}
17011};
17012
Kailang Yangf1d4e282008-08-26 14:03:29 +020017013static struct hda_verb alc662_ecs_init_verbs[] = {
17014 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17015 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17016 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17017 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17018 {}
17019};
17020
Kailang Yang622e84c2009-04-21 07:39:04 +020017021static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17022 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17023 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17024 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17025 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17026 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17027 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17028 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17029 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17030 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17031 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17032 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17033 {}
17034};
17035
17036static struct hda_verb alc272_dell_init_verbs[] = {
17037 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17038 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17039 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17040 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17041 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17042 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17043 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17044 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17045 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17046 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17047 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17048 {}
17049};
17050
Kailang Yangebb83ee2009-12-17 12:23:00 +010017051static struct hda_verb alc663_mode7_init_verbs[] = {
17052 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17053 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17054 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17055 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17056 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17057 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17058 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17059 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17060 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17061 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17062 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17063 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17064 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17065 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17066 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17067 {}
17068};
17069
17070static struct hda_verb alc663_mode8_init_verbs[] = {
17071 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17072 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17073 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17074 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17075 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17076 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17077 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17078 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17079 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17080 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17081 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17082 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17083 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17084 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17085 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17086 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17087 {}
17088};
17089
Kailang Yangf1d4e282008-08-26 14:03:29 +020017090static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17091 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17092 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17093 { } /* end */
17094};
17095
Kailang Yang622e84c2009-04-21 07:39:04 +020017096static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17097 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17098 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17099 { } /* end */
17100};
17101
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017102static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17103{
17104 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017105 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017106
Wu Fengguang864f92b2009-11-18 12:38:02 +080017107 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017108 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017109
Takashi Iwai47fd8302007-08-10 17:11:07 +020017110 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17111 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017112}
17113
17114static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17115{
17116 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017117 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017118
Wu Fengguang864f92b2009-11-18 12:38:02 +080017119 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017120 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017121
Takashi Iwai47fd8302007-08-10 17:11:07 +020017122 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17123 HDA_AMP_MUTE, bits);
17124 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17125 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017126}
17127
17128static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17129 unsigned int res)
17130{
17131 if ((res >> 26) == ALC880_HP_EVENT)
17132 alc662_lenovo_101e_all_automute(codec);
17133 if ((res >> 26) == ALC880_FRONT_EVENT)
17134 alc662_lenovo_101e_ispeaker_automute(codec);
17135}
17136
Kailang Yang291702f2007-10-16 14:28:03 +020017137/* unsolicited event for HP jack sensing */
17138static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17139 unsigned int res)
17140{
Kailang Yang291702f2007-10-16 14:28:03 +020017141 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017142 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017143 else
17144 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017145}
17146
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017147static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017148{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017149 struct alc_spec *spec = codec->spec;
17150
17151 alc262_hippo1_setup(codec);
17152 spec->ext_mic.pin = 0x18;
17153 spec->ext_mic.mux_idx = 0;
17154 spec->int_mic.pin = 0x19;
17155 spec->int_mic.mux_idx = 1;
17156 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017157}
17158
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017159static void alc662_eeepc_inithook(struct hda_codec *codec)
17160{
17161 alc262_hippo_automute(codec);
17162 alc_mic_automute(codec);
17163}
17164
17165static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017166{
Takashi Iwai42171c12009-05-08 14:11:43 +020017167 struct alc_spec *spec = codec->spec;
17168
17169 spec->autocfg.hp_pins[0] = 0x14;
17170 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017171}
17172
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017173#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17174
Kailang Yang6dda9f42008-05-27 12:05:31 +020017175static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17176{
17177 unsigned int present;
17178 unsigned char bits;
17179
Wu Fengguang864f92b2009-11-18 12:38:02 +080017180 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017181 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017182 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017183 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017184 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017185 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017186}
17187
17188static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17189{
17190 unsigned int present;
17191 unsigned char bits;
17192
Wu Fengguang864f92b2009-11-18 12:38:02 +080017193 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017194 bits = present ? HDA_AMP_MUTE : 0;
17195 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017196 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017197 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017198 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017199 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017200 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017201 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017202 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017203}
17204
17205static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
17206{
17207 unsigned int present;
17208 unsigned char bits;
17209
Wu Fengguang864f92b2009-11-18 12:38:02 +080017210 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017211 bits = present ? HDA_AMP_MUTE : 0;
17212 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017213 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017214 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017215 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017216 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017217 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017218 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017219 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017220}
17221
17222static void alc662_f5z_speaker_automute(struct hda_codec *codec)
17223{
17224 unsigned int present;
17225 unsigned char bits;
17226
Wu Fengguang864f92b2009-11-18 12:38:02 +080017227 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017228 bits = present ? 0 : PIN_OUT;
17229 snd_hda_codec_write(codec, 0x14, 0,
17230 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
17231}
17232
17233static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
17234{
17235 unsigned int present1, present2;
17236
Wu Fengguang864f92b2009-11-18 12:38:02 +080017237 present1 = snd_hda_jack_detect(codec, 0x21);
17238 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017239
17240 if (present1 || present2) {
17241 snd_hda_codec_write_cache(codec, 0x14, 0,
17242 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17243 } else {
17244 snd_hda_codec_write_cache(codec, 0x14, 0,
17245 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17246 }
17247}
17248
17249static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
17250{
17251 unsigned int present1, present2;
17252
Wu Fengguang864f92b2009-11-18 12:38:02 +080017253 present1 = snd_hda_jack_detect(codec, 0x1b);
17254 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017255
17256 if (present1 || present2) {
17257 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017258 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017259 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017260 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017261 } else {
17262 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017263 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017264 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017265 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017266 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020017267}
17268
Kailang Yangebb83ee2009-12-17 12:23:00 +010017269static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
17270{
17271 unsigned int present1, present2;
17272
17273 present1 = snd_hda_codec_read(codec, 0x1b, 0,
17274 AC_VERB_GET_PIN_SENSE, 0)
17275 & AC_PINSENSE_PRESENCE;
17276 present2 = snd_hda_codec_read(codec, 0x21, 0,
17277 AC_VERB_GET_PIN_SENSE, 0)
17278 & AC_PINSENSE_PRESENCE;
17279
17280 if (present1 || present2) {
17281 snd_hda_codec_write_cache(codec, 0x14, 0,
17282 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17283 snd_hda_codec_write_cache(codec, 0x17, 0,
17284 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17285 } else {
17286 snd_hda_codec_write_cache(codec, 0x14, 0,
17287 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17288 snd_hda_codec_write_cache(codec, 0x17, 0,
17289 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17290 }
17291}
17292
17293static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
17294{
17295 unsigned int present1, present2;
17296
17297 present1 = snd_hda_codec_read(codec, 0x21, 0,
17298 AC_VERB_GET_PIN_SENSE, 0)
17299 & AC_PINSENSE_PRESENCE;
17300 present2 = snd_hda_codec_read(codec, 0x15, 0,
17301 AC_VERB_GET_PIN_SENSE, 0)
17302 & AC_PINSENSE_PRESENCE;
17303
17304 if (present1 || present2) {
17305 snd_hda_codec_write_cache(codec, 0x14, 0,
17306 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17307 snd_hda_codec_write_cache(codec, 0x17, 0,
17308 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17309 } else {
17310 snd_hda_codec_write_cache(codec, 0x14, 0,
17311 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17312 snd_hda_codec_write_cache(codec, 0x17, 0,
17313 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17314 }
17315}
17316
Kailang Yang6dda9f42008-05-27 12:05:31 +020017317static void alc663_m51va_unsol_event(struct hda_codec *codec,
17318 unsigned int res)
17319{
17320 switch (res >> 26) {
17321 case ALC880_HP_EVENT:
17322 alc663_m51va_speaker_automute(codec);
17323 break;
17324 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017325 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017326 break;
17327 }
17328}
17329
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017330static void alc663_m51va_setup(struct hda_codec *codec)
17331{
17332 struct alc_spec *spec = codec->spec;
17333 spec->ext_mic.pin = 0x18;
17334 spec->ext_mic.mux_idx = 0;
17335 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017336 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017337 spec->auto_mic = 1;
17338}
17339
Kailang Yang6dda9f42008-05-27 12:05:31 +020017340static void alc663_m51va_inithook(struct hda_codec *codec)
17341{
17342 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017343 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017344}
17345
Kailang Yangf1d4e282008-08-26 14:03:29 +020017346/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017347#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010017348
17349static void alc663_mode1_setup(struct hda_codec *codec)
17350{
17351 struct alc_spec *spec = codec->spec;
17352 spec->ext_mic.pin = 0x18;
17353 spec->ext_mic.mux_idx = 0;
17354 spec->int_mic.pin = 0x19;
17355 spec->int_mic.mux_idx = 1;
17356 spec->auto_mic = 1;
17357}
17358
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017359#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020017360
Kailang Yangf1d4e282008-08-26 14:03:29 +020017361/* ***************** Mode2 ******************************/
17362static void alc662_mode2_unsol_event(struct hda_codec *codec,
17363 unsigned int res)
17364{
17365 switch (res >> 26) {
17366 case ALC880_HP_EVENT:
17367 alc662_f5z_speaker_automute(codec);
17368 break;
17369 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017370 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017371 break;
17372 }
17373}
17374
Kailang Yangebb83ee2009-12-17 12:23:00 +010017375#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017376
Kailang Yangf1d4e282008-08-26 14:03:29 +020017377static void alc662_mode2_inithook(struct hda_codec *codec)
17378{
17379 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017380 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017381}
17382/* ***************** Mode3 ******************************/
17383static void alc663_mode3_unsol_event(struct hda_codec *codec,
17384 unsigned int res)
17385{
17386 switch (res >> 26) {
17387 case ALC880_HP_EVENT:
17388 alc663_two_hp_m1_speaker_automute(codec);
17389 break;
17390 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017391 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017392 break;
17393 }
17394}
17395
Kailang Yangebb83ee2009-12-17 12:23:00 +010017396#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017397
Kailang Yangf1d4e282008-08-26 14:03:29 +020017398static void alc663_mode3_inithook(struct hda_codec *codec)
17399{
17400 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017401 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017402}
17403/* ***************** Mode4 ******************************/
17404static void alc663_mode4_unsol_event(struct hda_codec *codec,
17405 unsigned int res)
17406{
17407 switch (res >> 26) {
17408 case ALC880_HP_EVENT:
17409 alc663_21jd_two_speaker_automute(codec);
17410 break;
17411 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017412 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017413 break;
17414 }
17415}
17416
Kailang Yangebb83ee2009-12-17 12:23:00 +010017417#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017418
Kailang Yangf1d4e282008-08-26 14:03:29 +020017419static void alc663_mode4_inithook(struct hda_codec *codec)
17420{
17421 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017422 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017423}
17424/* ***************** Mode5 ******************************/
17425static void alc663_mode5_unsol_event(struct hda_codec *codec,
17426 unsigned int res)
17427{
17428 switch (res >> 26) {
17429 case ALC880_HP_EVENT:
17430 alc663_15jd_two_speaker_automute(codec);
17431 break;
17432 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017433 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017434 break;
17435 }
17436}
17437
Kailang Yangebb83ee2009-12-17 12:23:00 +010017438#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017439
Kailang Yangf1d4e282008-08-26 14:03:29 +020017440static void alc663_mode5_inithook(struct hda_codec *codec)
17441{
17442 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017443 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017444}
17445/* ***************** Mode6 ******************************/
17446static void alc663_mode6_unsol_event(struct hda_codec *codec,
17447 unsigned int res)
17448{
17449 switch (res >> 26) {
17450 case ALC880_HP_EVENT:
17451 alc663_two_hp_m2_speaker_automute(codec);
17452 break;
17453 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017454 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017455 break;
17456 }
17457}
17458
Kailang Yangebb83ee2009-12-17 12:23:00 +010017459#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017460
Kailang Yangf1d4e282008-08-26 14:03:29 +020017461static void alc663_mode6_inithook(struct hda_codec *codec)
17462{
17463 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017464 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017465}
17466
Kailang Yangebb83ee2009-12-17 12:23:00 +010017467/* ***************** Mode7 ******************************/
17468static void alc663_mode7_unsol_event(struct hda_codec *codec,
17469 unsigned int res)
17470{
17471 switch (res >> 26) {
17472 case ALC880_HP_EVENT:
17473 alc663_two_hp_m7_speaker_automute(codec);
17474 break;
17475 case ALC880_MIC_EVENT:
17476 alc_mic_automute(codec);
17477 break;
17478 }
17479}
17480
17481#define alc663_mode7_setup alc663_mode1_setup
17482
17483static void alc663_mode7_inithook(struct hda_codec *codec)
17484{
17485 alc663_two_hp_m7_speaker_automute(codec);
17486 alc_mic_automute(codec);
17487}
17488
17489/* ***************** Mode8 ******************************/
17490static void alc663_mode8_unsol_event(struct hda_codec *codec,
17491 unsigned int res)
17492{
17493 switch (res >> 26) {
17494 case ALC880_HP_EVENT:
17495 alc663_two_hp_m8_speaker_automute(codec);
17496 break;
17497 case ALC880_MIC_EVENT:
17498 alc_mic_automute(codec);
17499 break;
17500 }
17501}
17502
17503#define alc663_mode8_setup alc663_m51va_setup
17504
17505static void alc663_mode8_inithook(struct hda_codec *codec)
17506{
17507 alc663_two_hp_m8_speaker_automute(codec);
17508 alc_mic_automute(codec);
17509}
17510
Kailang Yang6dda9f42008-05-27 12:05:31 +020017511static void alc663_g71v_hp_automute(struct hda_codec *codec)
17512{
17513 unsigned int present;
17514 unsigned char bits;
17515
Wu Fengguang864f92b2009-11-18 12:38:02 +080017516 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017517 bits = present ? HDA_AMP_MUTE : 0;
17518 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17519 HDA_AMP_MUTE, bits);
17520 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17521 HDA_AMP_MUTE, bits);
17522}
17523
17524static void alc663_g71v_front_automute(struct hda_codec *codec)
17525{
17526 unsigned int present;
17527 unsigned char bits;
17528
Wu Fengguang864f92b2009-11-18 12:38:02 +080017529 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017530 bits = present ? HDA_AMP_MUTE : 0;
17531 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17532 HDA_AMP_MUTE, bits);
17533}
17534
17535static void alc663_g71v_unsol_event(struct hda_codec *codec,
17536 unsigned int res)
17537{
17538 switch (res >> 26) {
17539 case ALC880_HP_EVENT:
17540 alc663_g71v_hp_automute(codec);
17541 break;
17542 case ALC880_FRONT_EVENT:
17543 alc663_g71v_front_automute(codec);
17544 break;
17545 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017546 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017547 break;
17548 }
17549}
17550
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017551#define alc663_g71v_setup alc663_m51va_setup
17552
Kailang Yang6dda9f42008-05-27 12:05:31 +020017553static void alc663_g71v_inithook(struct hda_codec *codec)
17554{
17555 alc663_g71v_front_automute(codec);
17556 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017557 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017558}
17559
17560static void alc663_g50v_unsol_event(struct hda_codec *codec,
17561 unsigned int res)
17562{
17563 switch (res >> 26) {
17564 case ALC880_HP_EVENT:
17565 alc663_m51va_speaker_automute(codec);
17566 break;
17567 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017568 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017569 break;
17570 }
17571}
17572
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017573#define alc663_g50v_setup alc663_m51va_setup
17574
Kailang Yang6dda9f42008-05-27 12:05:31 +020017575static void alc663_g50v_inithook(struct hda_codec *codec)
17576{
17577 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017578 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017579}
17580
Kailang Yangf1d4e282008-08-26 14:03:29 +020017581static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17582 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017583 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017584
17585 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17586 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17587 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17588
17589 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17590 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17591 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17592 { } /* end */
17593};
17594
Chris Pockelé9541ba12009-05-12 08:08:53 +020017595static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17596 /* Master Playback automatically created from Speaker and Headphone */
17597 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17598 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17599 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17600 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17601
17602 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17603 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17604 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17605
17606 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17607 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17608 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17609 { } /* end */
17610};
17611
Takashi Iwaicb53c622007-08-10 17:21:45 +020017612#ifdef CONFIG_SND_HDA_POWER_SAVE
17613#define alc662_loopbacks alc880_loopbacks
17614#endif
17615
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017616
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017617/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017618#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17619#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17620#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17621#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17622
17623/*
17624 * configuration and preset
17625 */
17626static const char *alc662_models[ALC662_MODEL_LAST] = {
17627 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17628 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17629 [ALC662_3ST_6ch] = "3stack-6ch",
17630 [ALC662_5ST_DIG] = "6stack-dig",
17631 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017632 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017633 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017634 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017635 [ALC663_ASUS_M51VA] = "m51va",
17636 [ALC663_ASUS_G71V] = "g71v",
17637 [ALC663_ASUS_H13] = "h13",
17638 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017639 [ALC663_ASUS_MODE1] = "asus-mode1",
17640 [ALC662_ASUS_MODE2] = "asus-mode2",
17641 [ALC663_ASUS_MODE3] = "asus-mode3",
17642 [ALC663_ASUS_MODE4] = "asus-mode4",
17643 [ALC663_ASUS_MODE5] = "asus-mode5",
17644 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017645 [ALC663_ASUS_MODE7] = "asus-mode7",
17646 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017647 [ALC272_DELL] = "dell",
17648 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017649 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017650 [ALC662_AUTO] = "auto",
17651};
17652
17653static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017654 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017655 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17656 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017657 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17658 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010017659 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017660 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17661 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17662 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17663 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017664 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17665 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017666 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017667 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17668 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17669 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17670 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17671 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017672 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017673 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17674 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017675 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17676 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17677 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17678 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017679 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017680 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17681 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17682 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017683 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17684 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17685 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17686 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017687 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017688 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17689 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017690 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017691 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17692 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17693 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017694 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010017695 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017696 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17697 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017698 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17699 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17700 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017701 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017702 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17703 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017704 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017705 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017706 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017707 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17708 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17709 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017710 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017711 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17712 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017713 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017714 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017715 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017716 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017717 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17718 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010017719 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017720 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030017721 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17722 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010017723 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017724 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017725 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017726 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020017727 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020017728 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017729 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17730 ALC663_ASUS_H13),
David Santinoli7aee6742009-12-09 12:34:26 +010017731 SND_PCI_QUIRK(0x8086, 0xd604, "Intel mobo", ALC662_3ST_2ch_DIG),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017732 {}
17733};
17734
17735static struct alc_config_preset alc662_presets[] = {
17736 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017737 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017738 .init_verbs = { alc662_init_verbs },
17739 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17740 .dac_nids = alc662_dac_nids,
17741 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017742 .dig_in_nid = ALC662_DIGIN_NID,
17743 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17744 .channel_mode = alc662_3ST_2ch_modes,
17745 .input_mux = &alc662_capture_source,
17746 },
17747 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017748 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017749 .init_verbs = { alc662_init_verbs },
17750 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17751 .dac_nids = alc662_dac_nids,
17752 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017753 .dig_in_nid = ALC662_DIGIN_NID,
17754 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17755 .channel_mode = alc662_3ST_6ch_modes,
17756 .need_dac_fix = 1,
17757 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017758 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017759 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017760 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017761 .init_verbs = { alc662_init_verbs },
17762 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17763 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017764 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17765 .channel_mode = alc662_3ST_6ch_modes,
17766 .need_dac_fix = 1,
17767 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017768 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017769 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017770 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017771 .init_verbs = { alc662_init_verbs },
17772 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17773 .dac_nids = alc662_dac_nids,
17774 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017775 .dig_in_nid = ALC662_DIGIN_NID,
17776 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
17777 .channel_mode = alc662_5stack_modes,
17778 .input_mux = &alc662_capture_source,
17779 },
17780 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017781 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017782 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
17783 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17784 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017785 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17786 .channel_mode = alc662_3ST_2ch_modes,
17787 .input_mux = &alc662_lenovo_101e_capture_source,
17788 .unsol_event = alc662_lenovo_101e_unsol_event,
17789 .init_hook = alc662_lenovo_101e_all_automute,
17790 },
Kailang Yang291702f2007-10-16 14:28:03 +020017791 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017792 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020017793 .init_verbs = { alc662_init_verbs,
17794 alc662_eeepc_sue_init_verbs },
17795 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17796 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020017797 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17798 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020017799 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017800 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020017801 .init_hook = alc662_eeepc_inithook,
17802 },
Kailang Yang8c427222008-01-10 13:03:59 +010017803 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017804 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010017805 alc662_chmode_mixer },
17806 .init_verbs = { alc662_init_verbs,
17807 alc662_eeepc_ep20_sue_init_verbs },
17808 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17809 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010017810 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17811 .channel_mode = alc662_3ST_6ch_modes,
17812 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020017813 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017814 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010017815 .init_hook = alc662_eeepc_ep20_inithook,
17816 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017817 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017818 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017819 .init_verbs = { alc662_init_verbs,
17820 alc662_ecs_init_verbs },
17821 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17822 .dac_nids = alc662_dac_nids,
17823 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17824 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017825 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017826 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017827 .init_hook = alc662_eeepc_inithook,
17828 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017829 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017830 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017831 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17832 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17833 .dac_nids = alc662_dac_nids,
17834 .dig_out_nid = ALC662_DIGOUT_NID,
17835 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17836 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017837 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017838 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017839 .init_hook = alc663_m51va_inithook,
17840 },
17841 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017842 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017843 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17844 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17845 .dac_nids = alc662_dac_nids,
17846 .dig_out_nid = ALC662_DIGOUT_NID,
17847 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17848 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017849 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017850 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017851 .init_hook = alc663_g71v_inithook,
17852 },
17853 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017854 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017855 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17856 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17857 .dac_nids = alc662_dac_nids,
17858 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17859 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017860 .unsol_event = alc663_m51va_unsol_event,
17861 .init_hook = alc663_m51va_inithook,
17862 },
17863 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017864 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017865 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17866 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17867 .dac_nids = alc662_dac_nids,
17868 .dig_out_nid = ALC662_DIGOUT_NID,
17869 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17870 .channel_mode = alc662_3ST_6ch_modes,
17871 .input_mux = &alc663_capture_source,
17872 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017873 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017874 .init_hook = alc663_g50v_inithook,
17875 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017876 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017877 .mixers = { alc663_m51va_mixer },
17878 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017879 .init_verbs = { alc662_init_verbs,
17880 alc663_21jd_amic_init_verbs },
17881 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17882 .hp_nid = 0x03,
17883 .dac_nids = alc662_dac_nids,
17884 .dig_out_nid = ALC662_DIGOUT_NID,
17885 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17886 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017887 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017888 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017889 .init_hook = alc663_mode1_inithook,
17890 },
17891 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017892 .mixers = { alc662_1bjd_mixer },
17893 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017894 .init_verbs = { alc662_init_verbs,
17895 alc662_1bjd_amic_init_verbs },
17896 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17897 .dac_nids = alc662_dac_nids,
17898 .dig_out_nid = ALC662_DIGOUT_NID,
17899 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17900 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017901 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017902 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017903 .init_hook = alc662_mode2_inithook,
17904 },
17905 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017906 .mixers = { alc663_two_hp_m1_mixer },
17907 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017908 .init_verbs = { alc662_init_verbs,
17909 alc663_two_hp_amic_m1_init_verbs },
17910 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17911 .hp_nid = 0x03,
17912 .dac_nids = alc662_dac_nids,
17913 .dig_out_nid = ALC662_DIGOUT_NID,
17914 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17915 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017916 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017917 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017918 .init_hook = alc663_mode3_inithook,
17919 },
17920 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017921 .mixers = { alc663_asus_21jd_clfe_mixer },
17922 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017923 .init_verbs = { alc662_init_verbs,
17924 alc663_21jd_amic_init_verbs},
17925 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17926 .hp_nid = 0x03,
17927 .dac_nids = alc662_dac_nids,
17928 .dig_out_nid = ALC662_DIGOUT_NID,
17929 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17930 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017931 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017932 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017933 .init_hook = alc663_mode4_inithook,
17934 },
17935 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017936 .mixers = { alc663_asus_15jd_clfe_mixer },
17937 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017938 .init_verbs = { alc662_init_verbs,
17939 alc663_15jd_amic_init_verbs },
17940 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17941 .hp_nid = 0x03,
17942 .dac_nids = alc662_dac_nids,
17943 .dig_out_nid = ALC662_DIGOUT_NID,
17944 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17945 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017946 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017947 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017948 .init_hook = alc663_mode5_inithook,
17949 },
17950 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017951 .mixers = { alc663_two_hp_m2_mixer },
17952 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017953 .init_verbs = { alc662_init_verbs,
17954 alc663_two_hp_amic_m2_init_verbs },
17955 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17956 .hp_nid = 0x03,
17957 .dac_nids = alc662_dac_nids,
17958 .dig_out_nid = ALC662_DIGOUT_NID,
17959 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17960 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017961 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017962 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017963 .init_hook = alc663_mode6_inithook,
17964 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017965 [ALC663_ASUS_MODE7] = {
17966 .mixers = { alc663_mode7_mixer },
17967 .cap_mixer = alc662_auto_capture_mixer,
17968 .init_verbs = { alc662_init_verbs,
17969 alc663_mode7_init_verbs },
17970 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17971 .hp_nid = 0x03,
17972 .dac_nids = alc662_dac_nids,
17973 .dig_out_nid = ALC662_DIGOUT_NID,
17974 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17975 .channel_mode = alc662_3ST_2ch_modes,
17976 .unsol_event = alc663_mode7_unsol_event,
17977 .setup = alc663_mode7_setup,
17978 .init_hook = alc663_mode7_inithook,
17979 },
17980 [ALC663_ASUS_MODE8] = {
17981 .mixers = { alc663_mode8_mixer },
17982 .cap_mixer = alc662_auto_capture_mixer,
17983 .init_verbs = { alc662_init_verbs,
17984 alc663_mode8_init_verbs },
17985 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17986 .hp_nid = 0x03,
17987 .dac_nids = alc662_dac_nids,
17988 .dig_out_nid = ALC662_DIGOUT_NID,
17989 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17990 .channel_mode = alc662_3ST_2ch_modes,
17991 .unsol_event = alc663_mode8_unsol_event,
17992 .setup = alc663_mode8_setup,
17993 .init_hook = alc663_mode8_inithook,
17994 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017995 [ALC272_DELL] = {
17996 .mixers = { alc663_m51va_mixer },
17997 .cap_mixer = alc272_auto_capture_mixer,
17998 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17999 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18000 .dac_nids = alc662_dac_nids,
18001 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18002 .adc_nids = alc272_adc_nids,
18003 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18004 .capsrc_nids = alc272_capsrc_nids,
18005 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018006 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018007 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018008 .init_hook = alc663_m51va_inithook,
18009 },
18010 [ALC272_DELL_ZM1] = {
18011 .mixers = { alc663_m51va_mixer },
18012 .cap_mixer = alc662_auto_capture_mixer,
18013 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18014 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18015 .dac_nids = alc662_dac_nids,
18016 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18017 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018018 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018019 .capsrc_nids = alc662_capsrc_nids,
18020 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018021 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018022 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018023 .init_hook = alc663_m51va_inithook,
18024 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018025 [ALC272_SAMSUNG_NC10] = {
18026 .mixers = { alc272_nc10_mixer },
18027 .init_verbs = { alc662_init_verbs,
18028 alc663_21jd_amic_init_verbs },
18029 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18030 .dac_nids = alc272_dac_nids,
18031 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18032 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018033 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018034 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018035 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018036 .init_hook = alc663_mode4_inithook,
18037 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018038};
18039
18040
18041/*
18042 * BIOS auto configuration
18043 */
18044
Takashi Iwai7085ec12009-10-02 09:03:58 +020018045/* convert from MIX nid to DAC */
18046static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18047{
18048 if (nid == 0x0f)
18049 return 0x02;
18050 else if (nid >= 0x0c && nid <= 0x0e)
18051 return nid - 0x0c + 0x02;
18052 else
18053 return 0;
18054}
18055
18056/* get MIX nid connected to the given pin targeted to DAC */
18057static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18058 hda_nid_t dac)
18059{
18060 hda_nid_t mix[4];
18061 int i, num;
18062
18063 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18064 for (i = 0; i < num; i++) {
18065 if (alc662_mix_to_dac(mix[i]) == dac)
18066 return mix[i];
18067 }
18068 return 0;
18069}
18070
18071/* look for an empty DAC slot */
18072static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18073{
18074 struct alc_spec *spec = codec->spec;
18075 hda_nid_t srcs[5];
18076 int i, j, num;
18077
18078 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18079 if (num < 0)
18080 return 0;
18081 for (i = 0; i < num; i++) {
18082 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18083 if (!nid)
18084 continue;
18085 for (j = 0; j < spec->multiout.num_dacs; j++)
18086 if (spec->multiout.dac_nids[j] == nid)
18087 break;
18088 if (j >= spec->multiout.num_dacs)
18089 return nid;
18090 }
18091 return 0;
18092}
18093
18094/* fill in the dac_nids table from the parsed pin configuration */
18095static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18096 const struct auto_pin_cfg *cfg)
18097{
18098 struct alc_spec *spec = codec->spec;
18099 int i;
18100 hda_nid_t dac;
18101
18102 spec->multiout.dac_nids = spec->private_dac_nids;
18103 for (i = 0; i < cfg->line_outs; i++) {
18104 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18105 if (!dac)
18106 continue;
18107 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18108 }
18109 return 0;
18110}
18111
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018112static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018113 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018114{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018115 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018116 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18117}
18118
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018119static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018120 hda_nid_t nid, unsigned int chs)
18121{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018122 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018123 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18124}
18125
18126#define alc662_add_stereo_vol(spec, pfx, nid) \
18127 alc662_add_vol_ctl(spec, pfx, nid, 3)
18128#define alc662_add_stereo_sw(spec, pfx, nid) \
18129 alc662_add_sw_ctl(spec, pfx, nid, 3)
18130
18131/* add playback controls from the parsed DAC table */
18132static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18133 const struct auto_pin_cfg *cfg)
18134{
18135 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018136 static const char *chname[4] = {
18137 "Front", "Surround", NULL /*CLFE*/, "Side"
18138 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018139 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018140 int i, err;
18141
18142 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018143 nid = spec->multiout.dac_nids[i];
18144 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018145 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018146 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18147 if (!mix)
18148 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018149 if (i == 2) {
18150 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018151 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018152 if (err < 0)
18153 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018154 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018155 if (err < 0)
18156 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018157 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018158 if (err < 0)
18159 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018160 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018161 if (err < 0)
18162 return err;
18163 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018164 const char *pfx;
18165 if (cfg->line_outs == 1 &&
18166 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018167 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018168 pfx = "Speaker";
18169 else
18170 pfx = "PCM";
18171 } else
18172 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018173 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018174 if (err < 0)
18175 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018176 if (cfg->line_outs == 1 &&
18177 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18178 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018179 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018180 if (err < 0)
18181 return err;
18182 }
18183 }
18184 return 0;
18185}
18186
18187/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018188/* return DAC nid if any new DAC is assigned */
18189static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018190 const char *pfx)
18191{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018192 struct alc_spec *spec = codec->spec;
18193 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018194 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018195
18196 if (!pin)
18197 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018198 nid = alc662_look_for_dac(codec, pin);
18199 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018200 /* the corresponding DAC is already occupied */
18201 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
18202 return 0; /* no way */
18203 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018204 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018205 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
18206 }
18207
18208 mix = alc662_dac_to_mix(codec, pin, nid);
18209 if (!mix)
18210 return 0;
18211 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
18212 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020018213 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018214 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
18215 if (err < 0)
18216 return err;
18217 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018218}
18219
18220/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020018221#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020018222 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018223
18224static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
18225 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018226 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018227{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018228 int i, num;
18229 hda_nid_t srcs[4];
18230
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018231 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018232 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018233 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
18234 if (num <= 1)
18235 return;
18236 for (i = 0; i < num; i++) {
18237 if (alc662_mix_to_dac(srcs[i]) != dac)
18238 continue;
18239 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
18240 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018241 }
18242}
18243
18244static void alc662_auto_init_multi_out(struct hda_codec *codec)
18245{
18246 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018247 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018248 int i;
18249
18250 for (i = 0; i <= HDA_SIDE; i++) {
18251 hda_nid_t nid = spec->autocfg.line_out_pins[i];
18252 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020018253 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018254 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018255 }
18256}
18257
18258static void alc662_auto_init_hp_out(struct hda_codec *codec)
18259{
18260 struct alc_spec *spec = codec->spec;
18261 hda_nid_t pin;
18262
18263 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018264 if (pin)
18265 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
18266 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018267 pin = spec->autocfg.speaker_pins[0];
18268 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018269 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
18270 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018271}
18272
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018273#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
18274
18275static void alc662_auto_init_analog_input(struct hda_codec *codec)
18276{
18277 struct alc_spec *spec = codec->spec;
18278 int i;
18279
18280 for (i = 0; i < AUTO_PIN_LAST; i++) {
18281 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020018282 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010018283 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010018284 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010018285 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018286 snd_hda_codec_write(codec, nid, 0,
18287 AC_VERB_SET_AMP_GAIN_MUTE,
18288 AMP_OUT_MUTE);
18289 }
18290 }
18291}
18292
Takashi Iwaif511b012008-08-15 16:46:42 +020018293#define alc662_auto_init_input_src alc882_auto_init_input_src
18294
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018295static int alc662_parse_auto_config(struct hda_codec *codec)
18296{
18297 struct alc_spec *spec = codec->spec;
18298 int err;
18299 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
18300
18301 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
18302 alc662_ignore);
18303 if (err < 0)
18304 return err;
18305 if (!spec->autocfg.line_outs)
18306 return 0; /* can't find valid BIOS pin config */
18307
Takashi Iwai7085ec12009-10-02 09:03:58 +020018308 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018309 if (err < 0)
18310 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018311 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018312 if (err < 0)
18313 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018314 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018315 spec->autocfg.speaker_pins[0],
18316 "Speaker");
18317 if (err < 0)
18318 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018319 if (err)
18320 spec->multiout.extra_out_nid[0] = err;
18321 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018322 "Headphone");
18323 if (err < 0)
18324 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018325 if (err)
18326 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018327 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018328 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018329 return err;
18330
18331 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18332
Takashi Iwai0852d7a2009-02-11 11:35:15 +010018333 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018334 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
18335
Takashi Iwai603c4012008-07-30 15:01:44 +020018336 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018337 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018338
18339 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018340 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018341
Kailang Yangcec27c82010-02-04 14:18:18 +010018342 add_verb(spec, alc662_init_verbs);
18343 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18344 codec->vendor_id == 0x10ec0665)
18345 add_verb(spec, alc663_init_verbs);
18346
18347 if (codec->vendor_id == 0x10ec0272)
18348 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020018349
18350 err = alc_auto_add_mic_boost(codec);
18351 if (err < 0)
18352 return err;
18353
Kailang Yang6227cdc2010-02-25 08:36:52 +010018354 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18355 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
18356 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
18357 else
18358 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018359
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018360 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018361}
18362
18363/* additional initialization for auto-configuration model */
18364static void alc662_auto_init(struct hda_codec *codec)
18365{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018366 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018367 alc662_auto_init_multi_out(codec);
18368 alc662_auto_init_hp_out(codec);
18369 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020018370 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018371 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018372 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018373}
18374
18375static int patch_alc662(struct hda_codec *codec)
18376{
18377 struct alc_spec *spec;
18378 int err, board_config;
18379
18380 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18381 if (!spec)
18382 return -ENOMEM;
18383
18384 codec->spec = spec;
18385
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018386 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18387
Kailang Yang274693f2009-12-03 10:07:50 +010018388 if (alc_read_coef_idx(codec, 0)==0x8020){
18389 kfree(codec->chip_name);
18390 codec->chip_name = kstrdup("ALC661", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018391 if (!codec->chip_name) {
18392 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018393 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018394 }
Kailang Yang274693f2009-12-03 10:07:50 +010018395 }
18396
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018397 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18398 alc662_models,
18399 alc662_cfg_tbl);
18400 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020018401 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18402 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018403 board_config = ALC662_AUTO;
18404 }
18405
18406 if (board_config == ALC662_AUTO) {
18407 /* automatic parse from the BIOS config */
18408 err = alc662_parse_auto_config(codec);
18409 if (err < 0) {
18410 alc_free(codec);
18411 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018412 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018413 printk(KERN_INFO
18414 "hda_codec: Cannot set up configuration "
18415 "from BIOS. Using base mode...\n");
18416 board_config = ALC662_3ST_2ch_DIG;
18417 }
18418 }
18419
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018420 err = snd_hda_attach_beep_device(codec, 0x1);
18421 if (err < 0) {
18422 alc_free(codec);
18423 return err;
18424 }
18425
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018426 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018427 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018428
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018429 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18430 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18431
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018432 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18433 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18434
Takashi Iwaidd704692009-08-11 08:45:11 +020018435 if (!spec->adc_nids) {
18436 spec->adc_nids = alc662_adc_nids;
18437 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
18438 }
18439 if (!spec->capsrc_nids)
18440 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018441
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018442 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018443 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018444
Kailang Yangcec27c82010-02-04 14:18:18 +010018445 switch (codec->vendor_id) {
18446 case 0x10ec0662:
18447 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18448 break;
18449 case 0x10ec0272:
18450 case 0x10ec0663:
18451 case 0x10ec0665:
18452 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
18453 break;
18454 case 0x10ec0273:
18455 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
18456 break;
18457 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010018458 spec->vmaster_nid = 0x02;
18459
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018460 codec->patch_ops = alc_patch_ops;
18461 if (board_config == ALC662_AUTO)
18462 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020018463#ifdef CONFIG_SND_HDA_POWER_SAVE
18464 if (!spec->loopback.amplist)
18465 spec->loopback.amplist = alc662_loopbacks;
18466#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018467
18468 return 0;
18469}
18470
Kailang Yang274693f2009-12-03 10:07:50 +010018471static int patch_alc888(struct hda_codec *codec)
18472{
18473 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
18474 kfree(codec->chip_name);
18475 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018476 if (!codec->chip_name) {
18477 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018478 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018479 }
18480 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018481 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018482 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018483}
18484
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018485/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070018486 * patch entries
18487 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018488static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070018489 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018490 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018491 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020018492 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018493 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018494 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020018495 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018496 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018497 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018498 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018499 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
18500 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
18501 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018502 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018503 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018504 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
18505 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018506 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010018507 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010018508 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018509 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018510 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018511 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020018512 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018513 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020018514 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018515 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018516 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018517 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020018518 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018519 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018520 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018521 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018522 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018523 {} /* terminator */
18524};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018525
18526MODULE_ALIAS("snd-hda-codec-id:10ec*");
18527
18528MODULE_LICENSE("GPL");
18529MODULE_DESCRIPTION("Realtek HD-audio codec");
18530
18531static struct hda_codec_preset_list realtek_list = {
18532 .preset = snd_hda_preset_realtek,
18533 .owner = THIS_MODULE,
18534};
18535
18536static int __init patch_realtek_init(void)
18537{
18538 return snd_hda_add_codec_preset(&realtek_list);
18539}
18540
18541static void __exit patch_realtek_exit(void)
18542{
18543 snd_hda_delete_codec_preset(&realtek_list);
18544}
18545
18546module_init(patch_realtek_init)
18547module_exit(patch_realtek_exit)