blob: 5382872eba1f3745f8b0f0bbf69098fb5226e326 [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;
414 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415}
416
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200417static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
418 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419{
420 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
421 struct alc_spec *spec = codec->spec;
422 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
423
424 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
425 return 0;
426}
427
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200428static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
429 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430{
431 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
432 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100433 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100435 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100436 hda_nid_t nid = spec->capsrc_nids ?
437 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200438 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439
Takashi Iwaicd896c32008-11-18 12:36:33 +0100440 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
441 imux = &spec->input_mux[mux_idx];
442
Takashi Iwaia22d5432009-07-27 12:54:26 +0200443 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200444 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100445 /* Matrix-mixer style (e.g. ALC882) */
446 unsigned int *cur_val = &spec->cur_mux[adc_idx];
447 unsigned int i, idx;
448
449 idx = ucontrol->value.enumerated.item[0];
450 if (idx >= imux->num_items)
451 idx = imux->num_items - 1;
452 if (*cur_val == idx)
453 return 0;
454 for (i = 0; i < imux->num_items; i++) {
455 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
456 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
457 imux->items[i].index,
458 HDA_AMP_MUTE, v);
459 }
460 *cur_val = idx;
461 return 1;
462 } else {
463 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100464 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100465 &spec->cur_mux[adc_idx]);
466 }
467}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200468
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469/*
470 * channel mode setting
471 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200472static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
473 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474{
475 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
476 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100477 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
478 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479}
480
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200481static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
482 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483{
484 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
485 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100486 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200487 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200488 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489}
490
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200491static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
492 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493{
494 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
495 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200496 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
497 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200498 &spec->ext_channel_count);
499 if (err >= 0 && !spec->const_channel_count) {
500 spec->multiout.max_channels = spec->ext_channel_count;
501 if (spec->need_dac_fix)
502 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
503 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200504 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505}
506
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100508 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200509 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100510 * being part of a format specifier. Maximum allowed length of a value is
511 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100512 *
513 * Note: some retasking pin complexes seem to ignore requests for input
514 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
515 * are requested. Therefore order this list so that this behaviour will not
516 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200517 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
518 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200519 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100520static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100521 "Mic 50pc bias", "Mic 80pc bias",
522 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100523};
524static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100525 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100526};
527/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200528 * in the pin being assumed to be exclusively an input or an output pin. In
529 * addition, "input" pins may or may not process the mic bias option
530 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
531 * accept requests for bias as of chip versions up to March 2006) and/or
532 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100533 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200534#define ALC_PIN_DIR_IN 0x00
535#define ALC_PIN_DIR_OUT 0x01
536#define ALC_PIN_DIR_INOUT 0x02
537#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
538#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100539
Kailang Yangea1fb292008-08-26 12:58:38 +0200540/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100541 * For each direction the minimum and maximum values are given.
542 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200543static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100544 { 0, 2 }, /* ALC_PIN_DIR_IN */
545 { 3, 4 }, /* ALC_PIN_DIR_OUT */
546 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200547 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
548 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100549};
550#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
551#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
552#define alc_pin_mode_n_items(_dir) \
553 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
554
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200555static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
556 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200557{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100558 unsigned int item_num = uinfo->value.enumerated.item;
559 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
560
561 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200562 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100563 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
564
565 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
566 item_num = alc_pin_mode_min(dir);
567 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200568 return 0;
569}
570
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200571static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
572 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200573{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100574 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200575 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
576 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100577 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200578 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200579 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
580 AC_VERB_GET_PIN_WIDGET_CONTROL,
581 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200582
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100583 /* Find enumerated value for current pinctl setting */
584 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200585 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100586 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200587 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100588 return 0;
589}
590
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200591static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
592 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100593{
594 signed int change;
595 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
596 hda_nid_t nid = kcontrol->private_value & 0xffff;
597 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
598 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200599 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
600 AC_VERB_GET_PIN_WIDGET_CONTROL,
601 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100602
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200603 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100604 val = alc_pin_mode_min(dir);
605
606 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100607 if (change) {
608 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200609 snd_hda_codec_write_cache(codec, nid, 0,
610 AC_VERB_SET_PIN_WIDGET_CONTROL,
611 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100612
Kailang Yangea1fb292008-08-26 12:58:38 +0200613 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100614 * for the requested pin mode. Enum values of 2 or less are
615 * input modes.
616 *
617 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200618 * reduces noise slightly (particularly on input) so we'll
619 * do it. However, having both input and output buffers
620 * enabled simultaneously doesn't seem to be problematic if
621 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100622 */
623 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200624 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
625 HDA_AMP_MUTE, HDA_AMP_MUTE);
626 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
627 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100628 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200629 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
630 HDA_AMP_MUTE, HDA_AMP_MUTE);
631 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
632 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100633 }
634 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200635 return change;
636}
637
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100638#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200639 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100640 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100641 .info = alc_pin_mode_info, \
642 .get = alc_pin_mode_get, \
643 .put = alc_pin_mode_put, \
644 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100645
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100646/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
647 * together using a mask with more than one bit set. This control is
648 * currently used only by the ALC260 test model. At this stage they are not
649 * needed for any "production" models.
650 */
651#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200652#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200653
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200654static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
655 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100656{
657 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
658 hda_nid_t nid = kcontrol->private_value & 0xffff;
659 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
660 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200661 unsigned int val = snd_hda_codec_read(codec, nid, 0,
662 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100663
664 *valp = (val & mask) != 0;
665 return 0;
666}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200667static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
668 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100669{
670 signed int change;
671 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
672 hda_nid_t nid = kcontrol->private_value & 0xffff;
673 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
674 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200675 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
676 AC_VERB_GET_GPIO_DATA,
677 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100678
679 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200680 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
681 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100682 gpio_data &= ~mask;
683 else
684 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200685 snd_hda_codec_write_cache(codec, nid, 0,
686 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100687
688 return change;
689}
690#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
691 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100692 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100693 .info = alc_gpio_data_info, \
694 .get = alc_gpio_data_get, \
695 .put = alc_gpio_data_put, \
696 .private_value = nid | (mask<<16) }
697#endif /* CONFIG_SND_DEBUG */
698
Jonathan Woithe92621f12006-02-28 11:47:47 +0100699/* A switch control to allow the enabling of the digital IO pins on the
700 * ALC260. This is incredibly simplistic; the intention of this control is
701 * to provide something in the test model allowing digital outputs to be
702 * identified if present. If models are found which can utilise these
703 * outputs a more complete mixer control can be devised for those models if
704 * necessary.
705 */
706#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200707#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200708
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200709static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
710 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100711{
712 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
713 hda_nid_t nid = kcontrol->private_value & 0xffff;
714 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
715 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200716 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100717 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100718
719 *valp = (val & mask) != 0;
720 return 0;
721}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200722static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
723 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100724{
725 signed int change;
726 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
727 hda_nid_t nid = kcontrol->private_value & 0xffff;
728 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
729 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200730 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100731 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200732 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100733
734 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200735 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100736 if (val==0)
737 ctrl_data &= ~mask;
738 else
739 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200740 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
741 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100742
743 return change;
744}
745#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
746 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100747 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100748 .info = alc_spdif_ctrl_info, \
749 .get = alc_spdif_ctrl_get, \
750 .put = alc_spdif_ctrl_put, \
751 .private_value = nid | (mask<<16) }
752#endif /* CONFIG_SND_DEBUG */
753
Jonathan Woithef8225f62008-01-08 12:16:54 +0100754/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
755 * Again, this is only used in the ALC26x test models to help identify when
756 * the EAPD line must be asserted for features to work.
757 */
758#ifdef CONFIG_SND_DEBUG
759#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
760
761static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
762 struct snd_ctl_elem_value *ucontrol)
763{
764 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
765 hda_nid_t nid = kcontrol->private_value & 0xffff;
766 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
767 long *valp = ucontrol->value.integer.value;
768 unsigned int val = snd_hda_codec_read(codec, nid, 0,
769 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
770
771 *valp = (val & mask) != 0;
772 return 0;
773}
774
775static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
776 struct snd_ctl_elem_value *ucontrol)
777{
778 int change;
779 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
780 hda_nid_t nid = kcontrol->private_value & 0xffff;
781 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
782 long val = *ucontrol->value.integer.value;
783 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
784 AC_VERB_GET_EAPD_BTLENABLE,
785 0x00);
786
787 /* Set/unset the masked control bit(s) as needed */
788 change = (!val ? 0 : mask) != (ctrl_data & mask);
789 if (!val)
790 ctrl_data &= ~mask;
791 else
792 ctrl_data |= mask;
793 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
794 ctrl_data);
795
796 return change;
797}
798
799#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
800 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100801 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100802 .info = alc_eapd_ctrl_info, \
803 .get = alc_eapd_ctrl_get, \
804 .put = alc_eapd_ctrl_put, \
805 .private_value = nid | (mask<<16) }
806#endif /* CONFIG_SND_DEBUG */
807
Kailang Yangdf694da2005-12-05 19:42:22 +0100808/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100809 * set up the input pin config (depending on the given auto-pin type)
810 */
811static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
812 int auto_pin_type)
813{
814 unsigned int val = PIN_IN;
815
816 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
817 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100818 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100819 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
820 if (pincap & AC_PINCAP_VREF_80)
821 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200822 else if (pincap & AC_PINCAP_VREF_50)
823 val = PIN_VREF50;
824 else if (pincap & AC_PINCAP_VREF_100)
825 val = PIN_VREF100;
826 else if (pincap & AC_PINCAP_VREF_GRD)
827 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100828 }
829 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
830}
831
832/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100833 */
834static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
835{
836 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
837 return;
838 spec->mixers[spec->num_mixers++] = mix;
839}
840
841static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
842{
843 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
844 return;
845 spec->init_verbs[spec->num_init_verbs++] = verb;
846}
847
848/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100849 * set up from the preset table
850 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200851static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200852 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100853{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200854 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100855 int i;
856
857 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100858 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100859 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200860 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
861 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100862 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200863
Kailang Yangdf694da2005-12-05 19:42:22 +0100864 spec->channel_mode = preset->channel_mode;
865 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200866 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200867 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100868
Hector Martin3b315d72009-06-02 10:54:19 +0200869 if (preset->const_channel_count)
870 spec->multiout.max_channels = preset->const_channel_count;
871 else
872 spec->multiout.max_channels = spec->channel_mode[0].channels;
873 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100874
875 spec->multiout.num_dacs = preset->num_dacs;
876 spec->multiout.dac_nids = preset->dac_nids;
877 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800878 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100879 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200880
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200881 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200882 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200883 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100884 spec->input_mux = preset->input_mux;
885
886 spec->num_adc_nids = preset->num_adc_nids;
887 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100888 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100889 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100890
891 spec->unsol_event = preset->unsol_event;
892 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200893#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100894 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200895 spec->loopback.amplist = preset->loopbacks;
896#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200897
898 if (preset->setup)
899 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100900}
901
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200902/* Enable GPIO mask and set output */
903static struct hda_verb alc_gpio1_init_verbs[] = {
904 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
905 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
906 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
907 { }
908};
909
910static struct hda_verb alc_gpio2_init_verbs[] = {
911 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
912 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
913 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
914 { }
915};
916
Kailang Yangbdd148a2007-05-08 15:19:08 +0200917static struct hda_verb alc_gpio3_init_verbs[] = {
918 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
919 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
920 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
921 { }
922};
923
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200924/*
925 * Fix hardware PLL issue
926 * On some codecs, the analog PLL gating control must be off while
927 * the default value is 1.
928 */
929static void alc_fix_pll(struct hda_codec *codec)
930{
931 struct alc_spec *spec = codec->spec;
932 unsigned int val;
933
934 if (!spec->pll_nid)
935 return;
936 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
937 spec->pll_coef_idx);
938 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
939 AC_VERB_GET_PROC_COEF, 0);
940 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
941 spec->pll_coef_idx);
942 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
943 val & ~(1 << spec->pll_coef_bit));
944}
945
946static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
947 unsigned int coef_idx, unsigned int coef_bit)
948{
949 struct alc_spec *spec = codec->spec;
950 spec->pll_nid = nid;
951 spec->pll_coef_idx = coef_idx;
952 spec->pll_coef_bit = coef_bit;
953 alc_fix_pll(codec);
954}
955
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200956static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200957{
958 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200959 unsigned int nid = spec->autocfg.hp_pins[0];
960 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200961
Takashi Iwaiad87c642009-11-02 14:23:15 +0100962 if (!nid)
963 return;
Wu Fengguang864f92b2009-11-18 12:38:02 +0800964 spec->jack_present = snd_hda_jack_detect(codec, nid);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200965 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
966 nid = spec->autocfg.speaker_pins[i];
967 if (!nid)
968 break;
969 snd_hda_codec_write(codec, nid, 0,
970 AC_VERB_SET_PIN_WIDGET_CONTROL,
971 spec->jack_present ? 0 : PIN_OUT);
972 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200973}
974
Takashi Iwai6c819492009-08-10 18:47:44 +0200975static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
976 hda_nid_t nid)
977{
978 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
979 int i, nums;
980
981 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
982 for (i = 0; i < nums; i++)
983 if (conn[i] == nid)
984 return i;
985 return -1;
986}
987
Kailang Yang7fb0d782008-10-15 11:12:35 +0200988static void alc_mic_automute(struct hda_codec *codec)
989{
990 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +0200991 struct alc_mic_route *dead, *alive;
992 unsigned int present, type;
993 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200994
Takashi Iwaib59bdf32009-08-11 09:47:30 +0200995 if (!spec->auto_mic)
996 return;
Takashi Iwai6c819492009-08-10 18:47:44 +0200997 if (!spec->int_mic.pin || !spec->ext_mic.pin)
998 return;
999 if (snd_BUG_ON(!spec->adc_nids))
1000 return;
1001
1002 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1003
Wu Fengguang864f92b2009-11-18 12:38:02 +08001004 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001005 if (present) {
1006 alive = &spec->ext_mic;
1007 dead = &spec->int_mic;
1008 } else {
1009 alive = &spec->int_mic;
1010 dead = &spec->ext_mic;
1011 }
1012
Takashi Iwai6c819492009-08-10 18:47:44 +02001013 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1014 if (type == AC_WID_AUD_MIX) {
1015 /* Matrix-mixer style (e.g. ALC882) */
1016 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1017 alive->mux_idx,
1018 HDA_AMP_MUTE, 0);
1019 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1020 dead->mux_idx,
1021 HDA_AMP_MUTE, HDA_AMP_MUTE);
1022 } else {
1023 /* MUX style (e.g. ALC880) */
1024 snd_hda_codec_write_cache(codec, cap_nid, 0,
1025 AC_VERB_SET_CONNECT_SEL,
1026 alive->mux_idx);
1027 }
1028
1029 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001030}
1031
Kailang Yangc9b58002007-10-16 14:30:01 +02001032/* unsolicited event for HP jack sensing */
1033static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1034{
1035 if (codec->vendor_id == 0x10ec0880)
1036 res >>= 28;
1037 else
1038 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001039 switch (res) {
1040 case ALC880_HP_EVENT:
1041 alc_automute_pin(codec);
1042 break;
1043 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001044 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001045 break;
1046 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001047}
1048
1049static void alc_inithook(struct hda_codec *codec)
1050{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001051 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001052 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001053}
1054
Kailang Yangf9423e72008-05-27 12:32:25 +02001055/* additional initialization for ALC888 variants */
1056static void alc888_coef_init(struct hda_codec *codec)
1057{
1058 unsigned int tmp;
1059
1060 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1061 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1062 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001063 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001064 /* alc888S-VC */
1065 snd_hda_codec_read(codec, 0x20, 0,
1066 AC_VERB_SET_PROC_COEF, 0x830);
1067 else
1068 /* alc888-VB */
1069 snd_hda_codec_read(codec, 0x20, 0,
1070 AC_VERB_SET_PROC_COEF, 0x3030);
1071}
1072
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001073static void alc889_coef_init(struct hda_codec *codec)
1074{
1075 unsigned int tmp;
1076
1077 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1078 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1079 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1080 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1081}
1082
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001083/* turn on/off EAPD control (only if available) */
1084static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1085{
1086 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1087 return;
1088 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1089 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1090 on ? 2 : 0);
1091}
1092
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001093static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001094{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001095 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001096
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001097 switch (type) {
1098 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001099 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1100 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001101 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001102 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1103 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001104 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001105 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1106 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001107 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001108 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001109 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001110 set_eapd(codec, 0x0f, 1);
1111 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001112 break;
1113 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001114 case 0x10ec0267:
1115 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001116 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001117 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001118 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001119 case 0x10ec0660:
1120 case 0x10ec0662:
1121 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001122 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001123 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001124 set_eapd(codec, 0x14, 1);
1125 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001126 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001127 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001128 switch (codec->vendor_id) {
1129 case 0x10ec0260:
1130 snd_hda_codec_write(codec, 0x1a, 0,
1131 AC_VERB_SET_COEF_INDEX, 7);
1132 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1133 AC_VERB_GET_PROC_COEF, 0);
1134 snd_hda_codec_write(codec, 0x1a, 0,
1135 AC_VERB_SET_COEF_INDEX, 7);
1136 snd_hda_codec_write(codec, 0x1a, 0,
1137 AC_VERB_SET_PROC_COEF,
1138 tmp | 0x2010);
1139 break;
1140 case 0x10ec0262:
1141 case 0x10ec0880:
1142 case 0x10ec0882:
1143 case 0x10ec0883:
1144 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001145 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001146 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001147 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001148 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001149 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001150 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001151 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001152#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001153 case 0x10ec0267:
1154 case 0x10ec0268:
1155 snd_hda_codec_write(codec, 0x20, 0,
1156 AC_VERB_SET_COEF_INDEX, 7);
1157 tmp = snd_hda_codec_read(codec, 0x20, 0,
1158 AC_VERB_GET_PROC_COEF, 0);
1159 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001160 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001161 snd_hda_codec_write(codec, 0x20, 0,
1162 AC_VERB_SET_PROC_COEF,
1163 tmp | 0x3000);
1164 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001165#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001166 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001167 break;
1168 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001169}
Kailang Yangea1fb292008-08-26 12:58:38 +02001170
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001171static void alc_init_auto_hp(struct hda_codec *codec)
1172{
1173 struct alc_spec *spec = codec->spec;
1174
1175 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001176 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001177
Kailang Yangc9b58002007-10-16 14:30:01 +02001178 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001179 if (spec->autocfg.line_out_pins[0] &&
1180 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001181 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001182 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001183 else
1184 return;
1185 }
1186
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001187 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1188 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001189 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1190 AC_VERB_SET_UNSOLICITED_ENABLE,
1191 AC_USRSP_EN | ALC880_HP_EVENT);
1192 spec->unsol_event = alc_sku_unsol_event;
1193}
1194
Takashi Iwai6c819492009-08-10 18:47:44 +02001195static void alc_init_auto_mic(struct hda_codec *codec)
1196{
1197 struct alc_spec *spec = codec->spec;
1198 struct auto_pin_cfg *cfg = &spec->autocfg;
1199 hda_nid_t fixed, ext;
1200 int i;
1201
1202 /* there must be only two mic inputs exclusively */
1203 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1204 if (cfg->input_pins[i])
1205 return;
1206
1207 fixed = ext = 0;
1208 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1209 hda_nid_t nid = cfg->input_pins[i];
1210 unsigned int defcfg;
1211 if (!nid)
1212 return;
1213 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1214 switch (get_defcfg_connect(defcfg)) {
1215 case AC_JACK_PORT_FIXED:
1216 if (fixed)
1217 return; /* already occupied */
1218 fixed = nid;
1219 break;
1220 case AC_JACK_PORT_COMPLEX:
1221 if (ext)
1222 return; /* already occupied */
1223 ext = nid;
1224 break;
1225 default:
1226 return; /* invalid entry */
1227 }
1228 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001229 if (!ext || !fixed)
1230 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001231 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1232 return; /* no unsol support */
1233 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1234 ext, fixed);
1235 spec->ext_mic.pin = ext;
1236 spec->int_mic.pin = fixed;
1237 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1238 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1239 spec->auto_mic = 1;
1240 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1241 AC_VERB_SET_UNSOLICITED_ENABLE,
1242 AC_USRSP_EN | ALC880_MIC_EVENT);
1243 spec->unsol_event = alc_sku_unsol_event;
1244}
1245
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001246/* check subsystem ID and set up device-specific initialization;
1247 * return 1 if initialized, 0 if invalid SSID
1248 */
1249/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1250 * 31 ~ 16 : Manufacture ID
1251 * 15 ~ 8 : SKU ID
1252 * 7 ~ 0 : Assembly ID
1253 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1254 */
1255static int alc_subsystem_id(struct hda_codec *codec,
1256 hda_nid_t porta, hda_nid_t porte,
1257 hda_nid_t portd)
1258{
1259 unsigned int ass, tmp, i;
1260 unsigned nid;
1261 struct alc_spec *spec = codec->spec;
1262
1263 ass = codec->subsystem_id & 0xffff;
1264 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1265 goto do_sku;
1266
1267 /* invalid SSID, check the special NID pin defcfg instead */
1268 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001269 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001270 * 29~21 : reserve
1271 * 20 : PCBEEP input
1272 * 19~16 : Check sum (15:1)
1273 * 15~1 : Custom
1274 * 0 : override
1275 */
1276 nid = 0x1d;
1277 if (codec->vendor_id == 0x10ec0260)
1278 nid = 0x17;
1279 ass = snd_hda_codec_get_pincfg(codec, nid);
1280 snd_printd("realtek: No valid SSID, "
1281 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001282 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001283 if (!(ass & 1) && !(ass & 0x100000))
1284 return 0;
1285 if ((ass >> 30) != 1) /* no physical connection */
1286 return 0;
1287
1288 /* check sum */
1289 tmp = 0;
1290 for (i = 1; i < 16; i++) {
1291 if ((ass >> i) & 1)
1292 tmp++;
1293 }
1294 if (((ass >> 16) & 0xf) != tmp)
1295 return 0;
1296do_sku:
1297 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1298 ass & 0xffff, codec->vendor_id);
1299 /*
1300 * 0 : override
1301 * 1 : Swap Jack
1302 * 2 : 0 --> Desktop, 1 --> Laptop
1303 * 3~5 : External Amplifier control
1304 * 7~6 : Reserved
1305 */
1306 tmp = (ass & 0x38) >> 3; /* external Amp control */
1307 switch (tmp) {
1308 case 1:
1309 spec->init_amp = ALC_INIT_GPIO1;
1310 break;
1311 case 3:
1312 spec->init_amp = ALC_INIT_GPIO2;
1313 break;
1314 case 7:
1315 spec->init_amp = ALC_INIT_GPIO3;
1316 break;
1317 case 5:
1318 spec->init_amp = ALC_INIT_DEFAULT;
1319 break;
1320 }
1321
1322 /* is laptop or Desktop and enable the function "Mute internal speaker
1323 * when the external headphone out jack is plugged"
1324 */
1325 if (!(ass & 0x8000))
1326 return 1;
1327 /*
1328 * 10~8 : Jack location
1329 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1330 * 14~13: Resvered
1331 * 15 : 1 --> enable the function "Mute internal speaker
1332 * when the external headphone out jack is plugged"
1333 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001334 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001335 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001336 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1337 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001338 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001339 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001340 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001341 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001342 nid = portd;
Kailang Yangc9b58002007-10-16 14:30:01 +02001343 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001344 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001345 for (i = 0; i < spec->autocfg.line_outs; i++)
1346 if (spec->autocfg.line_out_pins[i] == nid)
1347 return 1;
1348 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001349 }
1350
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001351 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001352 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001353 return 1;
1354}
Kailang Yangea1fb292008-08-26 12:58:38 +02001355
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001356static void alc_ssid_check(struct hda_codec *codec,
1357 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1358{
1359 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1360 struct alc_spec *spec = codec->spec;
1361 snd_printd("realtek: "
1362 "Enable default setup for auto mode as fallback\n");
1363 spec->init_amp = ALC_INIT_DEFAULT;
1364 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001365 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001366 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001367}
1368
Takashi Iwai41e41f12005-06-08 14:48:49 +02001369/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001370 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001371 */
1372
1373struct alc_pincfg {
1374 hda_nid_t nid;
1375 u32 val;
1376};
1377
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001378struct alc_fixup {
1379 const struct alc_pincfg *pins;
1380 const struct hda_verb *verbs;
1381};
1382
1383static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001384 const struct snd_pci_quirk *quirk,
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001385 const struct alc_fixup *fix)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001386{
1387 const struct alc_pincfg *cfg;
1388
1389 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1390 if (!quirk)
1391 return;
1392
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001393 fix += quirk->value;
1394 cfg = fix->pins;
1395 if (cfg) {
1396 for (; cfg->nid; cfg++)
1397 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1398 }
1399 if (fix->verbs)
1400 add_verb(codec->spec, fix->verbs);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001401}
1402
Kailang Yang274693f2009-12-03 10:07:50 +01001403static int alc_read_coef_idx(struct hda_codec *codec,
1404 unsigned int coef_idx)
1405{
1406 unsigned int val;
1407 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1408 coef_idx);
1409 val = snd_hda_codec_read(codec, 0x20, 0,
1410 AC_VERB_GET_PROC_COEF, 0);
1411 return val;
1412}
1413
Takashi Iwaif95474e2007-07-10 00:47:43 +02001414/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001415 * ALC888
1416 */
1417
1418/*
1419 * 2ch mode
1420 */
1421static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1422/* Mic-in jack as mic in */
1423 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1424 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1425/* Line-in jack as Line in */
1426 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1427 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1428/* Line-Out as Front */
1429 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1430 { } /* end */
1431};
1432
1433/*
1434 * 4ch mode
1435 */
1436static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1437/* Mic-in jack as mic in */
1438 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1439 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1440/* Line-in jack as Surround */
1441 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1442 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1443/* Line-Out as Front */
1444 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1445 { } /* end */
1446};
1447
1448/*
1449 * 6ch mode
1450 */
1451static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1452/* Mic-in jack as CLFE */
1453 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1454 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1455/* Line-in jack as Surround */
1456 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1457 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1458/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1459 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1460 { } /* end */
1461};
1462
1463/*
1464 * 8ch mode
1465 */
1466static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1467/* Mic-in jack as CLFE */
1468 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1469 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1470/* Line-in jack as Surround */
1471 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1472 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1473/* Line-Out as Side */
1474 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1475 { } /* end */
1476};
1477
1478static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1479 { 2, alc888_4ST_ch2_intel_init },
1480 { 4, alc888_4ST_ch4_intel_init },
1481 { 6, alc888_4ST_ch6_intel_init },
1482 { 8, alc888_4ST_ch8_intel_init },
1483};
1484
1485/*
1486 * ALC888 Fujitsu Siemens Amillo xa3530
1487 */
1488
1489static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1490/* Front Mic: set to PIN_IN (empty by default) */
1491 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1492/* Connect Internal HP to Front */
1493 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1494 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1495 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1496/* Connect Bass HP to Front */
1497 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1498 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1499 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1500/* Connect Line-Out side jack (SPDIF) to Side */
1501 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1502 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1503 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1504/* Connect Mic jack to CLFE */
1505 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1506 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1507 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1508/* Connect Line-in jack to Surround */
1509 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1510 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1511 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1512/* Connect HP out jack to Front */
1513 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1514 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1515 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1516/* Enable unsolicited event for HP jack and Line-out jack */
1517 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1518 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1519 {}
1520};
1521
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001522static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001523{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001524 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001525 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001526 hda_nid_t nid;
1527 int i;
1528
1529 spec->jack_present = 0;
1530 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1531 nid = spec->autocfg.hp_pins[i];
1532 if (!nid)
1533 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001534 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001535 spec->jack_present = 1;
1536 break;
1537 }
1538 }
1539
1540 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001541 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001542 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1543 nid = spec->autocfg.speaker_pins[i];
1544 if (!nid)
1545 break;
1546 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1547 HDA_AMP_MUTE, mute);
1548 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001549}
1550
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001551static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1552 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001553{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001554 if (codec->vendor_id == 0x10ec0880)
1555 res >>= 28;
1556 else
1557 res >>= 26;
1558 if (res == ALC880_HP_EVENT)
1559 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001560}
1561
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001562static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001563{
1564 struct alc_spec *spec = codec->spec;
1565
1566 spec->autocfg.hp_pins[0] = 0x15;
1567 spec->autocfg.speaker_pins[0] = 0x14;
1568 spec->autocfg.speaker_pins[1] = 0x16;
1569 spec->autocfg.speaker_pins[2] = 0x17;
1570 spec->autocfg.speaker_pins[3] = 0x19;
1571 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001572}
1573
1574static void alc889_intel_init_hook(struct hda_codec *codec)
1575{
1576 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001577 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001578}
1579
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001580static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001581{
1582 struct alc_spec *spec = codec->spec;
1583
1584 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1585 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1586 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1587 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001588}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001589
1590/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001591 * ALC888 Acer Aspire 4930G model
1592 */
1593
1594static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1595/* Front Mic: set to PIN_IN (empty by default) */
1596 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1597/* Unselect Front Mic by default in input mixer 3 */
1598 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001599/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001600 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1601/* Connect Internal HP to front */
1602 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1603 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1604 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1605/* Connect HP out to front */
1606 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1607 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1608 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1609 { }
1610};
1611
Hector Martin3b315d72009-06-02 10:54:19 +02001612/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001613 * ALC888 Acer Aspire 6530G model
1614 */
1615
1616static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1617/* Bias voltage on for external mic port */
1618 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001619/* Front Mic: set to PIN_IN (empty by default) */
1620 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1621/* Unselect Front Mic by default in input mixer 3 */
1622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001623/* Enable unsolicited event for HP jack */
1624 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1625/* Enable speaker output */
1626 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1627 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1628/* Enable headphone output */
1629 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1630 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1631 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1632 { }
1633};
1634
1635/*
Hector Martin018df412009-06-04 00:13:40 +02001636 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001637 */
1638
Hector Martin018df412009-06-04 00:13:40 +02001639static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001640/* Front Mic: set to PIN_IN (empty by default) */
1641 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1642/* Unselect Front Mic by default in input mixer 3 */
1643 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1644/* Enable unsolicited event for HP jack */
1645 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1646/* Connect Internal Front to Front */
1647 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1648 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1649 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1650/* Connect Internal Rear to Rear */
1651 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1652 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1653 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1654/* Connect Internal CLFE to CLFE */
1655 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1656 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1657 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1658/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001659 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001660 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1661 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1662/* Enable all DACs */
1663/* DAC DISABLE/MUTE 1? */
1664/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1665 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1666 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1667/* DAC DISABLE/MUTE 2? */
1668/* some bit here disables the other DACs. Init=0x4900 */
1669 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1670 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02001671/* DMIC fix
1672 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1673 * which makes the stereo useless. However, either the mic or the ALC889
1674 * makes the signal become a difference/sum signal instead of standard
1675 * stereo, which is annoying. So instead we flip this bit which makes the
1676 * codec replicate the sum signal to both channels, turning it into a
1677 * normal mono mic.
1678 */
1679/* DMIC_CONTROL? Init value = 0x0001 */
1680 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1681 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001682 { }
1683};
1684
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001685static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001686 /* Front mic only available on one ADC */
1687 {
1688 .num_items = 4,
1689 .items = {
1690 { "Mic", 0x0 },
1691 { "Line", 0x2 },
1692 { "CD", 0x4 },
1693 { "Front Mic", 0xb },
1694 },
1695 },
1696 {
1697 .num_items = 3,
1698 .items = {
1699 { "Mic", 0x0 },
1700 { "Line", 0x2 },
1701 { "CD", 0x4 },
1702 },
1703 }
1704};
1705
Tony Vroond2fd4b02009-06-21 00:40:10 +01001706static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1707 /* Interal mic only available on one ADC */
1708 {
Tony Vroon684a8842009-06-26 09:27:50 +01001709 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001710 .items = {
1711 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001712 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001713 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001714 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001715 { "Int Mic", 0xb },
1716 },
1717 },
1718 {
Tony Vroon684a8842009-06-26 09:27:50 +01001719 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001720 .items = {
1721 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001722 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001723 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001724 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001725 },
1726 }
1727};
1728
Hector Martin018df412009-06-04 00:13:40 +02001729static struct hda_input_mux alc889_capture_sources[3] = {
1730 /* Digital mic only available on first "ADC" */
1731 {
1732 .num_items = 5,
1733 .items = {
1734 { "Mic", 0x0 },
1735 { "Line", 0x2 },
1736 { "CD", 0x4 },
1737 { "Front Mic", 0xb },
1738 { "Input Mix", 0xa },
1739 },
1740 },
1741 {
1742 .num_items = 4,
1743 .items = {
1744 { "Mic", 0x0 },
1745 { "Line", 0x2 },
1746 { "CD", 0x4 },
1747 { "Input Mix", 0xa },
1748 },
1749 },
1750 {
1751 .num_items = 4,
1752 .items = {
1753 { "Mic", 0x0 },
1754 { "Line", 0x2 },
1755 { "CD", 0x4 },
1756 { "Input Mix", 0xa },
1757 },
1758 }
1759};
1760
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001761static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001762 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1763 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1764 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1765 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1766 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1767 HDA_OUTPUT),
1768 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1769 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1770 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1771 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1772 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1773 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1774 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1775 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1776 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1777 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1778 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1779 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001780 { } /* end */
1781};
1782
Hector Martin556eea92009-12-20 22:51:23 +01001783static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1784 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1785 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1786 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1787 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1788 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1789 HDA_OUTPUT),
1790 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1791 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1792 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1793 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1794 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1795 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1796 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1797 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1798 { } /* end */
1799};
1800
1801
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001802static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001803{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001804 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001805
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001806 spec->autocfg.hp_pins[0] = 0x15;
1807 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01001808 spec->autocfg.speaker_pins[1] = 0x16;
1809 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001810}
1811
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001812static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001813{
1814 struct alc_spec *spec = codec->spec;
1815
1816 spec->autocfg.hp_pins[0] = 0x15;
1817 spec->autocfg.speaker_pins[0] = 0x14;
1818 spec->autocfg.speaker_pins[1] = 0x16;
1819 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001820}
1821
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001822static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001823{
1824 struct alc_spec *spec = codec->spec;
1825
1826 spec->autocfg.hp_pins[0] = 0x15;
1827 spec->autocfg.speaker_pins[0] = 0x14;
1828 spec->autocfg.speaker_pins[1] = 0x16;
1829 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001830}
1831
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001832/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001833 * ALC880 3-stack model
1834 *
1835 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001836 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1837 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001838 */
1839
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001840static hda_nid_t alc880_dac_nids[4] = {
1841 /* front, rear, clfe, rear_surr */
1842 0x02, 0x05, 0x04, 0x03
1843};
1844
1845static hda_nid_t alc880_adc_nids[3] = {
1846 /* ADC0-2 */
1847 0x07, 0x08, 0x09,
1848};
1849
1850/* The datasheet says the node 0x07 is connected from inputs,
1851 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001852 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001853 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001854static hda_nid_t alc880_adc_nids_alt[2] = {
1855 /* ADC1-2 */
1856 0x08, 0x09,
1857};
1858
1859#define ALC880_DIGOUT_NID 0x06
1860#define ALC880_DIGIN_NID 0x0a
1861
1862static struct hda_input_mux alc880_capture_source = {
1863 .num_items = 4,
1864 .items = {
1865 { "Mic", 0x0 },
1866 { "Front Mic", 0x3 },
1867 { "Line", 0x2 },
1868 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001869 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001870};
1871
1872/* channel source setting (2/6 channel selection for 3-stack) */
1873/* 2ch mode */
1874static struct hda_verb alc880_threestack_ch2_init[] = {
1875 /* set line-in to input, mute it */
1876 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1877 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1878 /* set mic-in to input vref 80%, mute it */
1879 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1880 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001881 { } /* end */
1882};
1883
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001884/* 6ch mode */
1885static struct hda_verb alc880_threestack_ch6_init[] = {
1886 /* set line-in to output, unmute it */
1887 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1888 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1889 /* set mic-in to output, unmute it */
1890 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1891 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1892 { } /* end */
1893};
1894
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001895static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001896 { 2, alc880_threestack_ch2_init },
1897 { 6, alc880_threestack_ch6_init },
1898};
1899
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001900static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001901 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001902 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001903 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001904 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001905 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1906 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001907 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1908 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001909 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1910 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1911 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1912 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1913 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1914 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1915 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1916 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001917 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001918 {
1919 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1920 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001921 .info = alc_ch_mode_info,
1922 .get = alc_ch_mode_get,
1923 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001924 },
1925 { } /* end */
1926};
1927
1928/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001929static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1930 struct snd_ctl_elem_info *uinfo)
1931{
1932 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1933 struct alc_spec *spec = codec->spec;
1934 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001935
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001936 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001937 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1938 HDA_INPUT);
1939 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001940 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001941 return err;
1942}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001943
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001944static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1945 unsigned int size, unsigned int __user *tlv)
1946{
1947 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1948 struct alc_spec *spec = codec->spec;
1949 int err;
1950
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001951 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001952 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1953 HDA_INPUT);
1954 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001955 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001956 return err;
1957}
1958
1959typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1960 struct snd_ctl_elem_value *ucontrol);
1961
1962static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1963 struct snd_ctl_elem_value *ucontrol,
1964 getput_call_t func)
1965{
1966 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1967 struct alc_spec *spec = codec->spec;
1968 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1969 int err;
1970
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001971 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001972 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1973 3, 0, HDA_INPUT);
1974 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001975 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001976 return err;
1977}
1978
1979static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1980 struct snd_ctl_elem_value *ucontrol)
1981{
1982 return alc_cap_getput_caller(kcontrol, ucontrol,
1983 snd_hda_mixer_amp_volume_get);
1984}
1985
1986static int alc_cap_vol_put(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_put);
1991}
1992
1993/* capture mixer elements */
1994#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1995
1996static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1997 struct snd_ctl_elem_value *ucontrol)
1998{
1999 return alc_cap_getput_caller(kcontrol, ucontrol,
2000 snd_hda_mixer_amp_switch_get);
2001}
2002
2003static int alc_cap_sw_put(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_put);
2008}
2009
Takashi Iwaia23b6882009-03-23 15:21:36 +01002010#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002011 { \
2012 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2013 .name = "Capture Switch", \
2014 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2015 .count = num, \
2016 .info = alc_cap_sw_info, \
2017 .get = alc_cap_sw_get, \
2018 .put = alc_cap_sw_put, \
2019 }, \
2020 { \
2021 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2022 .name = "Capture Volume", \
2023 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2024 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2025 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2026 .count = num, \
2027 .info = alc_cap_vol_info, \
2028 .get = alc_cap_vol_get, \
2029 .put = alc_cap_vol_put, \
2030 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002031 }
2032
2033#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002034 { \
2035 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2036 /* .name = "Capture Source", */ \
2037 .name = "Input Source", \
2038 .count = num, \
2039 .info = alc_mux_enum_info, \
2040 .get = alc_mux_enum_get, \
2041 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002042 }
2043
2044#define DEFINE_CAPMIX(num) \
2045static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2046 _DEFINE_CAPMIX(num), \
2047 _DEFINE_CAPSRC(num), \
2048 { } /* end */ \
2049}
2050
2051#define DEFINE_CAPMIX_NOSRC(num) \
2052static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2053 _DEFINE_CAPMIX(num), \
2054 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002055}
2056
2057/* up to three ADCs */
2058DEFINE_CAPMIX(1);
2059DEFINE_CAPMIX(2);
2060DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002061DEFINE_CAPMIX_NOSRC(1);
2062DEFINE_CAPMIX_NOSRC(2);
2063DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002064
2065/*
2066 * ALC880 5-stack model
2067 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002068 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2069 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002070 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2071 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2072 */
2073
2074/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002075static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002076 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002077 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002078 { } /* end */
2079};
2080
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002081/* channel source setting (6/8 channel selection for 5-stack) */
2082/* 6ch mode */
2083static struct hda_verb alc880_fivestack_ch6_init[] = {
2084 /* set line-in to input, mute it */
2085 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2086 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002087 { } /* end */
2088};
2089
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002090/* 8ch mode */
2091static struct hda_verb alc880_fivestack_ch8_init[] = {
2092 /* set line-in to output, unmute it */
2093 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2094 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2095 { } /* end */
2096};
2097
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002098static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002099 { 6, alc880_fivestack_ch6_init },
2100 { 8, alc880_fivestack_ch8_init },
2101};
2102
2103
2104/*
2105 * ALC880 6-stack model
2106 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002107 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2108 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002109 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2110 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2111 */
2112
2113static hda_nid_t alc880_6st_dac_nids[4] = {
2114 /* front, rear, clfe, rear_surr */
2115 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002116};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002117
2118static struct hda_input_mux alc880_6stack_capture_source = {
2119 .num_items = 4,
2120 .items = {
2121 { "Mic", 0x0 },
2122 { "Front Mic", 0x1 },
2123 { "Line", 0x2 },
2124 { "CD", 0x4 },
2125 },
2126};
2127
2128/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002129static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002130 { 8, NULL },
2131};
2132
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002133static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002134 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002135 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002136 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002137 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002138 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2139 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002140 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2141 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002142 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002143 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002144 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2145 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2146 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2147 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2148 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2149 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2150 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2151 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002152 {
2153 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2154 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002155 .info = alc_ch_mode_info,
2156 .get = alc_ch_mode_get,
2157 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002158 },
2159 { } /* end */
2160};
2161
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002162
2163/*
2164 * ALC880 W810 model
2165 *
2166 * W810 has rear IO for:
2167 * Front (DAC 02)
2168 * Surround (DAC 03)
2169 * Center/LFE (DAC 04)
2170 * Digital out (06)
2171 *
2172 * The system also has a pair of internal speakers, and a headphone jack.
2173 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002174 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002175 * There is a variable resistor to control the speaker or headphone
2176 * volume. This is a hardware-only device without a software API.
2177 *
2178 * Plugging headphones in will disable the internal speakers. This is
2179 * implemented in hardware, not via the driver using jack sense. In
2180 * a similar fashion, plugging into the rear socket marked "front" will
2181 * disable both the speakers and headphones.
2182 *
2183 * For input, there's a microphone jack, and an "audio in" jack.
2184 * These may not do anything useful with this driver yet, because I
2185 * haven't setup any initialization verbs for these yet...
2186 */
2187
2188static hda_nid_t alc880_w810_dac_nids[3] = {
2189 /* front, rear/surround, clfe */
2190 0x02, 0x03, 0x04
2191};
2192
2193/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002194static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002195 { 6, NULL }
2196};
2197
2198/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002199static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002200 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002201 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002202 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002203 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002204 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2205 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002206 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2207 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002208 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2209 { } /* end */
2210};
2211
2212
2213/*
2214 * Z710V model
2215 *
2216 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002217 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2218 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002219 */
2220
2221static hda_nid_t alc880_z71v_dac_nids[1] = {
2222 0x02
2223};
2224#define ALC880_Z71V_HP_DAC 0x03
2225
2226/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002227static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002228 { 2, NULL }
2229};
2230
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002231static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002232 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002233 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002234 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002235 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002236 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2237 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2238 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2239 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2240 { } /* end */
2241};
2242
2243
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002244/*
2245 * ALC880 F1734 model
2246 *
2247 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2248 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2249 */
2250
2251static hda_nid_t alc880_f1734_dac_nids[1] = {
2252 0x03
2253};
2254#define ALC880_F1734_HP_DAC 0x02
2255
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002256static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002257 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002258 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002259 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2260 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002261 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2262 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002263 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2264 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002265 { } /* end */
2266};
2267
Takashi Iwai937b4162008-02-11 14:52:36 +01002268static struct hda_input_mux alc880_f1734_capture_source = {
2269 .num_items = 2,
2270 .items = {
2271 { "Mic", 0x1 },
2272 { "CD", 0x4 },
2273 },
2274};
2275
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002276
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002277/*
2278 * ALC880 ASUS model
2279 *
2280 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2281 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2282 * Mic = 0x18, Line = 0x1a
2283 */
2284
2285#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2286#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2287
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002288static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002289 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002290 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002291 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002292 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002293 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2294 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002295 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2296 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002297 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2298 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2299 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2300 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2301 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2302 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002303 {
2304 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2305 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002306 .info = alc_ch_mode_info,
2307 .get = alc_ch_mode_get,
2308 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002309 },
2310 { } /* end */
2311};
2312
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002313/*
2314 * ALC880 ASUS W1V model
2315 *
2316 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2317 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2318 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2319 */
2320
2321/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002322static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002323 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2324 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002325 { } /* end */
2326};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002327
Kailang Yangdf694da2005-12-05 19:42:22 +01002328/* TCL S700 */
2329static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2330 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2331 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2332 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2333 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2334 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2336 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2337 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2338 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002339 { } /* end */
2340};
2341
Kailang Yangccc656c2006-10-17 12:32:26 +02002342/* Uniwill */
2343static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002344 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2345 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2346 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2347 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002348 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2349 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2350 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2351 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2352 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2353 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2354 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2355 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2356 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2357 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2358 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2359 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002360 {
2361 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2362 .name = "Channel Mode",
2363 .info = alc_ch_mode_info,
2364 .get = alc_ch_mode_get,
2365 .put = alc_ch_mode_put,
2366 },
2367 { } /* end */
2368};
2369
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002370static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2371 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2372 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2373 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2374 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2375 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2376 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2377 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2378 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2379 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2380 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2381 { } /* end */
2382};
2383
Kailang Yangccc656c2006-10-17 12:32:26 +02002384static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002385 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2386 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2387 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2388 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002389 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2390 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2391 { } /* end */
2392};
2393
Linus Torvalds1da177e2005-04-16 15:20:36 -07002394/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002395 * virtual master controls
2396 */
2397
2398/*
2399 * slave controls for virtual master
2400 */
2401static const char *alc_slave_vols[] = {
2402 "Front Playback Volume",
2403 "Surround Playback Volume",
2404 "Center Playback Volume",
2405 "LFE Playback Volume",
2406 "Side Playback Volume",
2407 "Headphone Playback Volume",
2408 "Speaker Playback Volume",
2409 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002410 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002411 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002412 NULL,
2413};
2414
2415static const char *alc_slave_sws[] = {
2416 "Front Playback Switch",
2417 "Surround Playback Switch",
2418 "Center Playback Switch",
2419 "LFE Playback Switch",
2420 "Side Playback Switch",
2421 "Headphone Playback Switch",
2422 "Speaker Playback Switch",
2423 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002424 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002425 "Line-Out Playback Switch",
2426 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002427 NULL,
2428};
2429
2430/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002431 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002432 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002433
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002434#define NID_MAPPING (-1)
2435
2436#define SUBDEV_SPEAKER_ (0 << 6)
2437#define SUBDEV_HP_ (1 << 6)
2438#define SUBDEV_LINE_ (2 << 6)
2439#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2440#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2441#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2442
Takashi Iwai603c4012008-07-30 15:01:44 +02002443static void alc_free_kctls(struct hda_codec *codec);
2444
Takashi Iwai67d634c2009-11-16 15:35:59 +01002445#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002446/* additional beep mixers; the actual parameters are overwritten at build */
2447static struct snd_kcontrol_new alc_beep_mixer[] = {
2448 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002449 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002450 { } /* end */
2451};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002452#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002453
Linus Torvalds1da177e2005-04-16 15:20:36 -07002454static int alc_build_controls(struct hda_codec *codec)
2455{
2456 struct alc_spec *spec = codec->spec;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002457 struct snd_kcontrol *kctl;
2458 struct snd_kcontrol_new *knew;
2459 int i, j, err;
2460 unsigned int u;
2461 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002462
2463 for (i = 0; i < spec->num_mixers; i++) {
2464 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2465 if (err < 0)
2466 return err;
2467 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002468 if (spec->cap_mixer) {
2469 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2470 if (err < 0)
2471 return err;
2472 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002473 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002474 err = snd_hda_create_spdif_out_ctls(codec,
2475 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002476 if (err < 0)
2477 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002478 if (!spec->no_analog) {
2479 err = snd_hda_create_spdif_share_sw(codec,
2480 &spec->multiout);
2481 if (err < 0)
2482 return err;
2483 spec->multiout.share_spdif = 1;
2484 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002485 }
2486 if (spec->dig_in_nid) {
2487 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2488 if (err < 0)
2489 return err;
2490 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002491
Takashi Iwai67d634c2009-11-16 15:35:59 +01002492#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002493 /* create beep controls if needed */
2494 if (spec->beep_amp) {
2495 struct snd_kcontrol_new *knew;
2496 for (knew = alc_beep_mixer; knew->name; knew++) {
2497 struct snd_kcontrol *kctl;
2498 kctl = snd_ctl_new1(knew, codec);
2499 if (!kctl)
2500 return -ENOMEM;
2501 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002502 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002503 if (err < 0)
2504 return err;
2505 }
2506 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002507#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002508
Takashi Iwai2134ea42008-01-10 16:53:55 +01002509 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002510 if (!spec->no_analog &&
2511 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002512 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002513 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002514 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002515 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002516 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002517 if (err < 0)
2518 return err;
2519 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002520 if (!spec->no_analog &&
2521 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002522 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2523 NULL, alc_slave_sws);
2524 if (err < 0)
2525 return err;
2526 }
2527
Takashi Iwai603c4012008-07-30 15:01:44 +02002528 alc_free_kctls(codec); /* no longer needed */
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002529
2530 /* assign Capture Source enums to NID */
2531 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2532 if (!kctl)
2533 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2534 for (i = 0; kctl && i < kctl->count; i++) {
Takashi Iwaid1409ae2009-12-17 15:01:31 +01002535 hda_nid_t *nids = spec->capsrc_nids;
2536 if (!nids)
2537 nids = spec->adc_nids;
Takashi Iwai21949f02009-12-23 08:31:59 +01002538 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002539 if (err < 0)
2540 return err;
2541 }
2542 if (spec->cap_mixer) {
2543 const char *kname = kctl ? kctl->id.name : NULL;
2544 for (knew = spec->cap_mixer; knew->name; knew++) {
2545 if (kname && strcmp(knew->name, kname) == 0)
2546 continue;
2547 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2548 for (i = 0; kctl && i < kctl->count; i++) {
2549 err = snd_hda_add_nid(codec, kctl, i,
2550 spec->adc_nids[i]);
2551 if (err < 0)
2552 return err;
2553 }
2554 }
2555 }
2556
2557 /* other nid->control mapping */
2558 for (i = 0; i < spec->num_mixers; i++) {
2559 for (knew = spec->mixers[i]; knew->name; knew++) {
2560 if (knew->iface != NID_MAPPING)
2561 continue;
2562 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2563 if (kctl == NULL)
2564 continue;
2565 u = knew->subdevice;
2566 for (j = 0; j < 4; j++, u >>= 8) {
2567 nid = u & 0x3f;
2568 if (nid == 0)
2569 continue;
2570 switch (u & 0xc0) {
2571 case SUBDEV_SPEAKER_:
2572 nid = spec->autocfg.speaker_pins[nid];
2573 break;
2574 case SUBDEV_LINE_:
2575 nid = spec->autocfg.line_out_pins[nid];
2576 break;
2577 case SUBDEV_HP_:
2578 nid = spec->autocfg.hp_pins[nid];
2579 break;
2580 default:
2581 continue;
2582 }
2583 err = snd_hda_add_nid(codec, kctl, 0, nid);
2584 if (err < 0)
2585 return err;
2586 }
2587 u = knew->private_value;
2588 for (j = 0; j < 4; j++, u >>= 8) {
2589 nid = u & 0xff;
2590 if (nid == 0)
2591 continue;
2592 err = snd_hda_add_nid(codec, kctl, 0, nid);
2593 if (err < 0)
2594 return err;
2595 }
2596 }
2597 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002598 return 0;
2599}
2600
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002601
Linus Torvalds1da177e2005-04-16 15:20:36 -07002602/*
2603 * initialize the codec volumes, etc
2604 */
2605
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002606/*
2607 * generic initialization of ADC, input mixers and output mixers
2608 */
2609static struct hda_verb alc880_volume_init_verbs[] = {
2610 /*
2611 * Unmute ADC0-2 and set the default input to mic-in
2612 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002613 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002615 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002616 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002617 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002618 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002619
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002620 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2621 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002622 * Note: PASD motherboards uses the Line In 2 as the input for front
2623 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002624 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002625 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002626 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2627 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2628 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2629 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2630 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2631 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2632 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002633
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002634 /*
2635 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002636 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002637 /* set vol=0 to output mixers */
2638 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2639 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2640 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2641 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2642 /* set up input amps for analog loopback */
2643 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002644 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2645 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002646 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2647 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002648 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2649 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002650 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2651 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002652
2653 { }
2654};
2655
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002656/*
2657 * 3-stack pin configuration:
2658 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2659 */
2660static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2661 /*
2662 * preset connection lists of input pins
2663 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2664 */
2665 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2666 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2667 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2668
2669 /*
2670 * Set pin mode and muting
2671 */
2672 /* set front pin widgets 0x14 for output */
2673 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2674 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2675 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2676 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2677 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2678 /* Mic2 (as headphone out) for HP output */
2679 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2680 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2681 /* Line In pin widget for input */
2682 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2683 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2684 /* Line2 (as front mic) pin widget for input and vref at 80% */
2685 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2686 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2687 /* CD pin widget for input */
2688 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2689
2690 { }
2691};
2692
2693/*
2694 * 5-stack pin configuration:
2695 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2696 * line-in/side = 0x1a, f-mic = 0x1b
2697 */
2698static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2699 /*
2700 * preset connection lists of input pins
2701 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2702 */
2703 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2704 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2705
2706 /*
2707 * Set pin mode and muting
2708 */
2709 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002710 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2711 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2712 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2713 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002714 /* unmute pins for output (no gain on this amp) */
2715 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2716 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2717 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2718 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2719
Linus Torvalds1da177e2005-04-16 15:20:36 -07002720 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002721 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002722 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2723 /* Mic2 (as headphone out) for HP output */
2724 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002725 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002726 /* Line In pin widget for input */
2727 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2728 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2729 /* Line2 (as front mic) pin widget for input and vref at 80% */
2730 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2731 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2732 /* CD pin widget for input */
2733 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002734
2735 { }
2736};
2737
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002738/*
2739 * W810 pin configuration:
2740 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2741 */
2742static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002743 /* hphone/speaker input selector: front DAC */
2744 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2745
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002746 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2747 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2748 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2749 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2750 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2751 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2752
2753 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002754 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002755
Linus Torvalds1da177e2005-04-16 15:20:36 -07002756 { }
2757};
2758
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002759/*
2760 * Z71V pin configuration:
2761 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2762 */
2763static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002764 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002765 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002766 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002767 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002768
Takashi Iwai16ded522005-06-10 19:58:24 +02002769 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002770 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002771 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002772 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002773
2774 { }
2775};
2776
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002777/*
2778 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002779 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2780 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002781 */
2782static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2783 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2784
Takashi Iwai16ded522005-06-10 19:58:24 +02002785 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002786 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002787 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002788 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002789 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002790 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002791 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002792 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2793
Takashi Iwai16ded522005-06-10 19:58:24 +02002794 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002795 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002796 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002797 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002798 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002799 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002800 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002801 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002802 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002803
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002804 { }
2805};
Takashi Iwai16ded522005-06-10 19:58:24 +02002806
Kailang Yangccc656c2006-10-17 12:32:26 +02002807/*
2808 * Uniwill pin configuration:
2809 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2810 * line = 0x1a
2811 */
2812static struct hda_verb alc880_uniwill_init_verbs[] = {
2813 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2814
2815 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2816 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2817 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2818 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2819 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2820 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2821 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2822 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2823 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2824 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2825 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2826 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2827 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2828 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2829
2830 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2831 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2832 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2833 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2834 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2835 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2836 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2837 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2838 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2839
2840 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2841 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2842
2843 { }
2844};
2845
2846/*
2847* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002848* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002849 */
2850static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2851 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2852
2853 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2854 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2855 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2857 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2858 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2859 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2860 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2861 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2862 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2863 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2864 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2865
2866 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2867 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2868 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2869 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2870 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2871 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2872
2873 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2874 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2875
2876 { }
2877};
2878
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002879static struct hda_verb alc880_beep_init_verbs[] = {
2880 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2881 { }
2882};
2883
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002884/* auto-toggle front mic */
2885static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2886{
2887 unsigned int present;
2888 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002889
Wu Fengguang864f92b2009-11-18 12:38:02 +08002890 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002891 bits = present ? HDA_AMP_MUTE : 0;
2892 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002893}
2894
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002895static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002896{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002897 struct alc_spec *spec = codec->spec;
2898
2899 spec->autocfg.hp_pins[0] = 0x14;
2900 spec->autocfg.speaker_pins[0] = 0x15;
2901 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002902}
2903
2904static void alc880_uniwill_init_hook(struct hda_codec *codec)
2905{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002906 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002907 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002908}
2909
2910static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2911 unsigned int res)
2912{
2913 /* Looks like the unsol event is incompatible with the standard
2914 * definition. 4bit tag is placed at 28 bit!
2915 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002916 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002917 case ALC880_MIC_EVENT:
2918 alc880_uniwill_mic_automute(codec);
2919 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002920 default:
2921 alc_automute_amp_unsol_event(codec, res);
2922 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002923 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002924}
2925
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002926static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002927{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002928 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002929
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002930 spec->autocfg.hp_pins[0] = 0x14;
2931 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002932}
2933
2934static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2935{
2936 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002937
Kailang Yangccc656c2006-10-17 12:32:26 +02002938 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002939 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2940 present &= HDA_AMP_VOLMASK;
2941 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2942 HDA_AMP_VOLMASK, present);
2943 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2944 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002945}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002946
Kailang Yangccc656c2006-10-17 12:32:26 +02002947static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2948 unsigned int res)
2949{
2950 /* Looks like the unsol event is incompatible with the standard
2951 * definition. 4bit tag is placed at 28 bit!
2952 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002953 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002954 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002955 else
2956 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002957}
2958
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002959/*
2960 * F1734 pin configuration:
2961 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2962 */
2963static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002964 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002965 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2966 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2967 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2968 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2969
2970 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2971 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2972 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2973 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2974
2975 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2976 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002977 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002978 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2979 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2980 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2981 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2982 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2983 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002984
Takashi Iwai937b4162008-02-11 14:52:36 +01002985 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2986 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2987
Takashi Iwai16ded522005-06-10 19:58:24 +02002988 { }
2989};
2990
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002991/*
2992 * ASUS pin configuration:
2993 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2994 */
2995static struct hda_verb alc880_pin_asus_init_verbs[] = {
2996 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2997 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2998 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2999 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3000
3001 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3002 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3003 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3004 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3005 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3006 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3007 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3008 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3009
3010 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3011 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3012 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3013 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3014 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3015 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3016 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3017 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3018 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003019
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003020 { }
3021};
3022
3023/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003024#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3025#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003026#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003027
Kailang Yangdf694da2005-12-05 19:42:22 +01003028/* Clevo m520g init */
3029static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3030 /* headphone output */
3031 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3032 /* line-out */
3033 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3034 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3035 /* Line-in */
3036 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3037 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3038 /* CD */
3039 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3040 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3041 /* Mic1 (rear panel) */
3042 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3043 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3044 /* Mic2 (front panel) */
3045 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3046 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3047 /* headphone */
3048 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3049 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3050 /* change to EAPD mode */
3051 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3052 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3053
3054 { }
3055};
3056
3057static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003058 /* change to EAPD mode */
3059 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3060 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3061
Kailang Yangdf694da2005-12-05 19:42:22 +01003062 /* Headphone output */
3063 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3064 /* Front output*/
3065 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3066 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3067
3068 /* Line In pin widget for input */
3069 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3070 /* CD pin widget for input */
3071 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3072 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3073 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3074
3075 /* change to EAPD mode */
3076 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3077 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3078
3079 { }
3080};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003081
3082/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003083 * LG m1 express dual
3084 *
3085 * Pin assignment:
3086 * Rear Line-In/Out (blue): 0x14
3087 * Build-in Mic-In: 0x15
3088 * Speaker-out: 0x17
3089 * HP-Out (green): 0x1b
3090 * Mic-In/Out (red): 0x19
3091 * SPDIF-Out: 0x1e
3092 */
3093
3094/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3095static hda_nid_t alc880_lg_dac_nids[3] = {
3096 0x05, 0x02, 0x03
3097};
3098
3099/* seems analog CD is not working */
3100static struct hda_input_mux alc880_lg_capture_source = {
3101 .num_items = 3,
3102 .items = {
3103 { "Mic", 0x1 },
3104 { "Line", 0x5 },
3105 { "Internal Mic", 0x6 },
3106 },
3107};
3108
3109/* 2,4,6 channel modes */
3110static struct hda_verb alc880_lg_ch2_init[] = {
3111 /* set line-in and mic-in to input */
3112 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3113 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3114 { }
3115};
3116
3117static struct hda_verb alc880_lg_ch4_init[] = {
3118 /* set line-in to out and mic-in to input */
3119 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3120 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3121 { }
3122};
3123
3124static struct hda_verb alc880_lg_ch6_init[] = {
3125 /* set line-in and mic-in to output */
3126 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3127 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3128 { }
3129};
3130
3131static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3132 { 2, alc880_lg_ch2_init },
3133 { 4, alc880_lg_ch4_init },
3134 { 6, alc880_lg_ch6_init },
3135};
3136
3137static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003138 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3139 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003140 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3141 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3142 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3143 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3144 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3145 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3146 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3147 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3148 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3149 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3150 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3151 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3152 {
3153 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3154 .name = "Channel Mode",
3155 .info = alc_ch_mode_info,
3156 .get = alc_ch_mode_get,
3157 .put = alc_ch_mode_put,
3158 },
3159 { } /* end */
3160};
3161
3162static struct hda_verb alc880_lg_init_verbs[] = {
3163 /* set capture source to mic-in */
3164 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3165 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3166 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3167 /* mute all amp mixer inputs */
3168 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003169 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3170 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003171 /* line-in to input */
3172 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3173 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3174 /* built-in mic */
3175 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3176 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3177 /* speaker-out */
3178 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3179 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3180 /* mic-in to input */
3181 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3182 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3183 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3184 /* HP-out */
3185 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3186 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3187 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3188 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003189 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003190 { }
3191};
3192
3193/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003194static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003195{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003196 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003197
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003198 spec->autocfg.hp_pins[0] = 0x1b;
3199 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003200}
3201
3202/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003203 * LG LW20
3204 *
3205 * Pin assignment:
3206 * Speaker-out: 0x14
3207 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003208 * Built-in Mic-In: 0x19
3209 * Line-In: 0x1b
3210 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003211 * SPDIF-Out: 0x1e
3212 */
3213
Takashi Iwaid6815182006-03-23 16:06:23 +01003214static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003215 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003216 .items = {
3217 { "Mic", 0x0 },
3218 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003219 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003220 },
3221};
3222
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003223#define alc880_lg_lw_modes alc880_threestack_modes
3224
Takashi Iwaid6815182006-03-23 16:06:23 +01003225static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003226 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3227 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3228 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3229 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3230 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3231 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3232 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3233 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3234 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3235 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003236 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3237 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3238 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3239 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003240 {
3241 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3242 .name = "Channel Mode",
3243 .info = alc_ch_mode_info,
3244 .get = alc_ch_mode_get,
3245 .put = alc_ch_mode_put,
3246 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003247 { } /* end */
3248};
3249
3250static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003251 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3252 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3253 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3254
Takashi Iwaid6815182006-03-23 16:06:23 +01003255 /* set capture source to mic-in */
3256 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3257 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3258 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003259 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003260 /* speaker-out */
3261 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3262 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3263 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003264 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3265 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3266 /* mic-in to input */
3267 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3268 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3269 /* built-in mic */
3270 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3271 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3272 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003273 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003274 { }
3275};
3276
3277/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003278static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003279{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003280 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003281
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003282 spec->autocfg.hp_pins[0] = 0x1b;
3283 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003284}
3285
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003286static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3287 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3288 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3289 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3290 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3291 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3292 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3293 { } /* end */
3294};
3295
3296static struct hda_input_mux alc880_medion_rim_capture_source = {
3297 .num_items = 2,
3298 .items = {
3299 { "Mic", 0x0 },
3300 { "Internal Mic", 0x1 },
3301 },
3302};
3303
3304static struct hda_verb alc880_medion_rim_init_verbs[] = {
3305 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3306
3307 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3308 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3309
3310 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3311 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3312 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3313 /* Mic2 (as headphone out) for HP output */
3314 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3315 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3316 /* Internal Speaker */
3317 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3318 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3319
3320 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3321 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3322
3323 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3324 { }
3325};
3326
3327/* toggle speaker-output according to the hp-jack state */
3328static void alc880_medion_rim_automute(struct hda_codec *codec)
3329{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003330 struct alc_spec *spec = codec->spec;
3331 alc_automute_amp(codec);
3332 /* toggle EAPD */
3333 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003334 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3335 else
3336 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3337}
3338
3339static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3340 unsigned int res)
3341{
3342 /* Looks like the unsol event is incompatible with the standard
3343 * definition. 4bit tag is placed at 28 bit!
3344 */
3345 if ((res >> 28) == ALC880_HP_EVENT)
3346 alc880_medion_rim_automute(codec);
3347}
3348
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003349static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003350{
3351 struct alc_spec *spec = codec->spec;
3352
3353 spec->autocfg.hp_pins[0] = 0x14;
3354 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003355}
3356
Takashi Iwaicb53c622007-08-10 17:21:45 +02003357#ifdef CONFIG_SND_HDA_POWER_SAVE
3358static struct hda_amp_list alc880_loopbacks[] = {
3359 { 0x0b, HDA_INPUT, 0 },
3360 { 0x0b, HDA_INPUT, 1 },
3361 { 0x0b, HDA_INPUT, 2 },
3362 { 0x0b, HDA_INPUT, 3 },
3363 { 0x0b, HDA_INPUT, 4 },
3364 { } /* end */
3365};
3366
3367static struct hda_amp_list alc880_lg_loopbacks[] = {
3368 { 0x0b, HDA_INPUT, 1 },
3369 { 0x0b, HDA_INPUT, 6 },
3370 { 0x0b, HDA_INPUT, 7 },
3371 { } /* end */
3372};
3373#endif
3374
Takashi Iwaid6815182006-03-23 16:06:23 +01003375/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003376 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003377 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003378
Linus Torvalds1da177e2005-04-16 15:20:36 -07003379static int alc_init(struct hda_codec *codec)
3380{
3381 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003382 unsigned int i;
3383
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003384 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003385 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003386
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003387 for (i = 0; i < spec->num_init_verbs; i++)
3388 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003389
3390 if (spec->init_hook)
3391 spec->init_hook(codec);
3392
Linus Torvalds1da177e2005-04-16 15:20:36 -07003393 return 0;
3394}
3395
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003396static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3397{
3398 struct alc_spec *spec = codec->spec;
3399
3400 if (spec->unsol_event)
3401 spec->unsol_event(codec, res);
3402}
3403
Takashi Iwaicb53c622007-08-10 17:21:45 +02003404#ifdef CONFIG_SND_HDA_POWER_SAVE
3405static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3406{
3407 struct alc_spec *spec = codec->spec;
3408 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3409}
3410#endif
3411
Linus Torvalds1da177e2005-04-16 15:20:36 -07003412/*
3413 * Analog playback callbacks
3414 */
3415static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3416 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003417 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003418{
3419 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003420 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3421 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003422}
3423
3424static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3425 struct hda_codec *codec,
3426 unsigned int stream_tag,
3427 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003428 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003429{
3430 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003431 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3432 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003433}
3434
3435static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3436 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003437 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003438{
3439 struct alc_spec *spec = codec->spec;
3440 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3441}
3442
3443/*
3444 * Digital out
3445 */
3446static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3447 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003448 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003449{
3450 struct alc_spec *spec = codec->spec;
3451 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3452}
3453
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003454static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3455 struct hda_codec *codec,
3456 unsigned int stream_tag,
3457 unsigned int format,
3458 struct snd_pcm_substream *substream)
3459{
3460 struct alc_spec *spec = codec->spec;
3461 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3462 stream_tag, format, substream);
3463}
3464
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003465static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3466 struct hda_codec *codec,
3467 struct snd_pcm_substream *substream)
3468{
3469 struct alc_spec *spec = codec->spec;
3470 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3471}
3472
Linus Torvalds1da177e2005-04-16 15:20:36 -07003473static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3474 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003475 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003476{
3477 struct alc_spec *spec = codec->spec;
3478 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3479}
3480
3481/*
3482 * Analog capture
3483 */
Takashi Iwai63300792008-01-24 15:31:36 +01003484static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003485 struct hda_codec *codec,
3486 unsigned int stream_tag,
3487 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003488 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003489{
3490 struct alc_spec *spec = codec->spec;
3491
Takashi Iwai63300792008-01-24 15:31:36 +01003492 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003493 stream_tag, 0, format);
3494 return 0;
3495}
3496
Takashi Iwai63300792008-01-24 15:31:36 +01003497static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003498 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003499 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003500{
3501 struct alc_spec *spec = codec->spec;
3502
Takashi Iwai888afa12008-03-18 09:57:50 +01003503 snd_hda_codec_cleanup_stream(codec,
3504 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003505 return 0;
3506}
3507
3508
3509/*
3510 */
3511static struct hda_pcm_stream alc880_pcm_analog_playback = {
3512 .substreams = 1,
3513 .channels_min = 2,
3514 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003515 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003516 .ops = {
3517 .open = alc880_playback_pcm_open,
3518 .prepare = alc880_playback_pcm_prepare,
3519 .cleanup = alc880_playback_pcm_cleanup
3520 },
3521};
3522
3523static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003524 .substreams = 1,
3525 .channels_min = 2,
3526 .channels_max = 2,
3527 /* NID is set in alc_build_pcms */
3528};
3529
3530static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3531 .substreams = 1,
3532 .channels_min = 2,
3533 .channels_max = 2,
3534 /* NID is set in alc_build_pcms */
3535};
3536
3537static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3538 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003539 .channels_min = 2,
3540 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003541 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003542 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003543 .prepare = alc880_alt_capture_pcm_prepare,
3544 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003545 },
3546};
3547
3548static struct hda_pcm_stream alc880_pcm_digital_playback = {
3549 .substreams = 1,
3550 .channels_min = 2,
3551 .channels_max = 2,
3552 /* NID is set in alc_build_pcms */
3553 .ops = {
3554 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003555 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003556 .prepare = alc880_dig_playback_pcm_prepare,
3557 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003558 },
3559};
3560
3561static struct hda_pcm_stream alc880_pcm_digital_capture = {
3562 .substreams = 1,
3563 .channels_min = 2,
3564 .channels_max = 2,
3565 /* NID is set in alc_build_pcms */
3566};
3567
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003568/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003569static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003570 .substreams = 0,
3571 .channels_min = 0,
3572 .channels_max = 0,
3573};
3574
Linus Torvalds1da177e2005-04-16 15:20:36 -07003575static int alc_build_pcms(struct hda_codec *codec)
3576{
3577 struct alc_spec *spec = codec->spec;
3578 struct hda_pcm *info = spec->pcm_rec;
3579 int i;
3580
3581 codec->num_pcms = 1;
3582 codec->pcm_info = info;
3583
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003584 if (spec->no_analog)
3585 goto skip_analog;
3586
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003587 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3588 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003589 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003590
Takashi Iwai4a471b72005-12-07 13:56:29 +01003591 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003592 if (snd_BUG_ON(!spec->multiout.dac_nids))
3593 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003594 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3595 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3596 }
3597 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003598 if (snd_BUG_ON(!spec->adc_nids))
3599 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003600 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3601 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3602 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003603
Takashi Iwai4a471b72005-12-07 13:56:29 +01003604 if (spec->channel_mode) {
3605 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3606 for (i = 0; i < spec->num_channel_mode; i++) {
3607 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3608 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3609 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003610 }
3611 }
3612
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003613 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003614 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003615 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003616 snprintf(spec->stream_name_digital,
3617 sizeof(spec->stream_name_digital),
3618 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003619 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003620 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003621 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003622 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003623 if (spec->dig_out_type)
3624 info->pcm_type = spec->dig_out_type;
3625 else
3626 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003627 if (spec->multiout.dig_out_nid &&
3628 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003629 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3630 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3631 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003632 if (spec->dig_in_nid &&
3633 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003634 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3635 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3636 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003637 /* FIXME: do we need this for all Realtek codec models? */
3638 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003639 }
3640
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003641 if (spec->no_analog)
3642 return 0;
3643
Takashi Iwaie08a0072006-09-07 17:52:14 +02003644 /* If the use of more than one ADC is requested for the current
3645 * model, configure a second analog capture-only PCM.
3646 */
3647 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003648 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3649 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003650 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003651 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003652 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003653 if (spec->alt_dac_nid) {
3654 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3655 *spec->stream_analog_alt_playback;
3656 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3657 spec->alt_dac_nid;
3658 } else {
3659 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3660 alc_pcm_null_stream;
3661 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3662 }
3663 if (spec->num_adc_nids > 1) {
3664 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3665 *spec->stream_analog_alt_capture;
3666 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3667 spec->adc_nids[1];
3668 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3669 spec->num_adc_nids - 1;
3670 } else {
3671 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3672 alc_pcm_null_stream;
3673 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003674 }
3675 }
3676
Linus Torvalds1da177e2005-04-16 15:20:36 -07003677 return 0;
3678}
3679
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003680static inline void alc_shutup(struct hda_codec *codec)
3681{
3682 snd_hda_shutup_pins(codec);
3683}
3684
Takashi Iwai603c4012008-07-30 15:01:44 +02003685static void alc_free_kctls(struct hda_codec *codec)
3686{
3687 struct alc_spec *spec = codec->spec;
3688
3689 if (spec->kctls.list) {
3690 struct snd_kcontrol_new *kctl = spec->kctls.list;
3691 int i;
3692 for (i = 0; i < spec->kctls.used; i++)
3693 kfree(kctl[i].name);
3694 }
3695 snd_array_free(&spec->kctls);
3696}
3697
Linus Torvalds1da177e2005-04-16 15:20:36 -07003698static void alc_free(struct hda_codec *codec)
3699{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003700 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003701
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003702 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003703 return;
3704
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003705 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02003706 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003707 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003708 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003709}
3710
Hector Martinf5de24b2009-12-20 22:51:31 +01003711#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05003712static void alc_power_eapd(struct hda_codec *codec)
3713{
3714 /* We currently only handle front, HP */
3715 switch (codec->vendor_id) {
3716 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003717 set_eapd(codec, 0x0f, 0);
3718 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003719 break;
3720 case 0x10ec0262:
3721 case 0x10ec0267:
3722 case 0x10ec0268:
3723 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003724 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05003725 case 0x10ec0272:
3726 case 0x10ec0660:
3727 case 0x10ec0662:
3728 case 0x10ec0663:
3729 case 0x10ec0862:
3730 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003731 set_eapd(codec, 0x14, 0);
3732 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003733 break;
3734 }
3735}
3736
Hector Martinf5de24b2009-12-20 22:51:31 +01003737static int alc_suspend(struct hda_codec *codec, pm_message_t state)
3738{
3739 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003740 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003741 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05003742 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003743 return 0;
3744}
3745#endif
3746
Takashi Iwaie044c392008-10-27 16:56:24 +01003747#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003748static int alc_resume(struct hda_codec *codec)
3749{
Takashi Iwaie044c392008-10-27 16:56:24 +01003750 codec->patch_ops.init(codec);
3751 snd_hda_codec_resume_amp(codec);
3752 snd_hda_codec_resume_cache(codec);
3753 return 0;
3754}
Takashi Iwaie044c392008-10-27 16:56:24 +01003755#endif
3756
Linus Torvalds1da177e2005-04-16 15:20:36 -07003757/*
3758 */
3759static struct hda_codec_ops alc_patch_ops = {
3760 .build_controls = alc_build_controls,
3761 .build_pcms = alc_build_pcms,
3762 .init = alc_init,
3763 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003764 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003765#ifdef SND_HDA_NEEDS_RESUME
3766 .resume = alc_resume,
3767#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003768#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01003769 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003770 .check_power_status = alc_check_power_status,
3771#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05003772 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003773};
3774
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003775
3776/*
3777 * Test configuration for debugging
3778 *
3779 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3780 * enum controls.
3781 */
3782#ifdef CONFIG_SND_DEBUG
3783static hda_nid_t alc880_test_dac_nids[4] = {
3784 0x02, 0x03, 0x04, 0x05
3785};
3786
3787static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003788 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003789 .items = {
3790 { "In-1", 0x0 },
3791 { "In-2", 0x1 },
3792 { "In-3", 0x2 },
3793 { "In-4", 0x3 },
3794 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003795 { "Front", 0x5 },
3796 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003797 },
3798};
3799
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003800static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003801 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003802 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003803 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003804 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003805};
3806
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003807static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3808 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003809{
3810 static char *texts[] = {
3811 "N/A", "Line Out", "HP Out",
3812 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3813 };
3814 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3815 uinfo->count = 1;
3816 uinfo->value.enumerated.items = 8;
3817 if (uinfo->value.enumerated.item >= 8)
3818 uinfo->value.enumerated.item = 7;
3819 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3820 return 0;
3821}
3822
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003823static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3824 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003825{
3826 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3827 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3828 unsigned int pin_ctl, item = 0;
3829
3830 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3831 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3832 if (pin_ctl & AC_PINCTL_OUT_EN) {
3833 if (pin_ctl & AC_PINCTL_HP_EN)
3834 item = 2;
3835 else
3836 item = 1;
3837 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3838 switch (pin_ctl & AC_PINCTL_VREFEN) {
3839 case AC_PINCTL_VREF_HIZ: item = 3; break;
3840 case AC_PINCTL_VREF_50: item = 4; break;
3841 case AC_PINCTL_VREF_GRD: item = 5; break;
3842 case AC_PINCTL_VREF_80: item = 6; break;
3843 case AC_PINCTL_VREF_100: item = 7; break;
3844 }
3845 }
3846 ucontrol->value.enumerated.item[0] = item;
3847 return 0;
3848}
3849
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003850static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3851 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003852{
3853 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3854 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3855 static unsigned int ctls[] = {
3856 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3857 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3858 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3859 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3860 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3861 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3862 };
3863 unsigned int old_ctl, new_ctl;
3864
3865 old_ctl = snd_hda_codec_read(codec, nid, 0,
3866 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3867 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3868 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003869 int val;
3870 snd_hda_codec_write_cache(codec, nid, 0,
3871 AC_VERB_SET_PIN_WIDGET_CONTROL,
3872 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003873 val = ucontrol->value.enumerated.item[0] >= 3 ?
3874 HDA_AMP_MUTE : 0;
3875 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3876 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003877 return 1;
3878 }
3879 return 0;
3880}
3881
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003882static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3883 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003884{
3885 static char *texts[] = {
3886 "Front", "Surround", "CLFE", "Side"
3887 };
3888 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3889 uinfo->count = 1;
3890 uinfo->value.enumerated.items = 4;
3891 if (uinfo->value.enumerated.item >= 4)
3892 uinfo->value.enumerated.item = 3;
3893 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3894 return 0;
3895}
3896
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003897static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3898 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003899{
3900 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3901 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3902 unsigned int sel;
3903
3904 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3905 ucontrol->value.enumerated.item[0] = sel & 3;
3906 return 0;
3907}
3908
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003909static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3910 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003911{
3912 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3913 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3914 unsigned int sel;
3915
3916 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3917 if (ucontrol->value.enumerated.item[0] != sel) {
3918 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003919 snd_hda_codec_write_cache(codec, nid, 0,
3920 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003921 return 1;
3922 }
3923 return 0;
3924}
3925
3926#define PIN_CTL_TEST(xname,nid) { \
3927 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3928 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003929 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003930 .info = alc_test_pin_ctl_info, \
3931 .get = alc_test_pin_ctl_get, \
3932 .put = alc_test_pin_ctl_put, \
3933 .private_value = nid \
3934 }
3935
3936#define PIN_SRC_TEST(xname,nid) { \
3937 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3938 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003939 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003940 .info = alc_test_pin_src_info, \
3941 .get = alc_test_pin_src_get, \
3942 .put = alc_test_pin_src_put, \
3943 .private_value = nid \
3944 }
3945
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003946static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003947 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3948 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3949 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3950 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003951 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3952 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3953 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3954 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003955 PIN_CTL_TEST("Front Pin Mode", 0x14),
3956 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3957 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3958 PIN_CTL_TEST("Side Pin Mode", 0x17),
3959 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3960 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3961 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3962 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3963 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3964 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3965 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3966 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3967 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3968 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3969 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3970 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3971 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3972 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3973 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3974 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3975 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3976 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003977 {
3978 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3979 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003980 .info = alc_ch_mode_info,
3981 .get = alc_ch_mode_get,
3982 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003983 },
3984 { } /* end */
3985};
3986
3987static struct hda_verb alc880_test_init_verbs[] = {
3988 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003989 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3990 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3991 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3992 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3993 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3994 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3995 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3996 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003997 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003998 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3999 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4000 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4001 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004002 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004003 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4005 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4006 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004007 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004008 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4009 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4010 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4011 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004012 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004013 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4014 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004015 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4016 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4017 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004018 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004019 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4020 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4021 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4022 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004023 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004024 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004025 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004026 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004027 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004028 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004029 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004030 /* Analog input/passthru */
4031 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4032 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4033 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4034 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4035 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004036 { }
4037};
4038#endif
4039
Linus Torvalds1da177e2005-04-16 15:20:36 -07004040/*
4041 */
4042
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004043static const char *alc880_models[ALC880_MODEL_LAST] = {
4044 [ALC880_3ST] = "3stack",
4045 [ALC880_TCL_S700] = "tcl",
4046 [ALC880_3ST_DIG] = "3stack-digout",
4047 [ALC880_CLEVO] = "clevo",
4048 [ALC880_5ST] = "5stack",
4049 [ALC880_5ST_DIG] = "5stack-digout",
4050 [ALC880_W810] = "w810",
4051 [ALC880_Z71V] = "z71v",
4052 [ALC880_6ST] = "6stack",
4053 [ALC880_6ST_DIG] = "6stack-digout",
4054 [ALC880_ASUS] = "asus",
4055 [ALC880_ASUS_W1V] = "asus-w1v",
4056 [ALC880_ASUS_DIG] = "asus-dig",
4057 [ALC880_ASUS_DIG2] = "asus-dig2",
4058 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004059 [ALC880_UNIWILL_P53] = "uniwill-p53",
4060 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004061 [ALC880_F1734] = "F1734",
4062 [ALC880_LG] = "lg",
4063 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004064 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004065#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004066 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004067#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004068 [ALC880_AUTO] = "auto",
4069};
4070
4071static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004072 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004073 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4074 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4075 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4076 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4077 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4078 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4079 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4080 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004081 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4082 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004083 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4084 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4085 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4086 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4087 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4088 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4089 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4090 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4091 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4092 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004093 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004094 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4095 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4096 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004097 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004098 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004099 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4100 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004101 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4102 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004103 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4104 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4105 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4106 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004107 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4108 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004109 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004110 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004111 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004112 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004113 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4114 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004115 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004116 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004117 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004118 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004119 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004120 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004121 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004122 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004123 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004124 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4125 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004126 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004127 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4128 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4129 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4130 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004131 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4132 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004133 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004134 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004135 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4136 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004137 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4138 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4139 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004140 /* default Intel */
4141 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004142 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4143 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004144 {}
4145};
4146
Takashi Iwai16ded522005-06-10 19:58:24 +02004147/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004148 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004149 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004150static struct alc_config_preset alc880_presets[] = {
4151 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004152 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004153 .init_verbs = { alc880_volume_init_verbs,
4154 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004155 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004156 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004157 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4158 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004159 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004160 .input_mux = &alc880_capture_source,
4161 },
4162 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004163 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004164 .init_verbs = { alc880_volume_init_verbs,
4165 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004166 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004167 .dac_nids = alc880_dac_nids,
4168 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004169 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4170 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004171 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004172 .input_mux = &alc880_capture_source,
4173 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004174 [ALC880_TCL_S700] = {
4175 .mixers = { alc880_tcl_s700_mixer },
4176 .init_verbs = { alc880_volume_init_verbs,
4177 alc880_pin_tcl_S700_init_verbs,
4178 alc880_gpio2_init_verbs },
4179 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4180 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004181 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4182 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004183 .hp_nid = 0x03,
4184 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4185 .channel_mode = alc880_2_jack_modes,
4186 .input_mux = &alc880_capture_source,
4187 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004188 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004189 .mixers = { alc880_three_stack_mixer,
4190 alc880_five_stack_mixer},
4191 .init_verbs = { alc880_volume_init_verbs,
4192 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004193 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4194 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004195 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4196 .channel_mode = alc880_fivestack_modes,
4197 .input_mux = &alc880_capture_source,
4198 },
4199 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004200 .mixers = { alc880_three_stack_mixer,
4201 alc880_five_stack_mixer },
4202 .init_verbs = { alc880_volume_init_verbs,
4203 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004204 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4205 .dac_nids = alc880_dac_nids,
4206 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004207 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4208 .channel_mode = alc880_fivestack_modes,
4209 .input_mux = &alc880_capture_source,
4210 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004211 [ALC880_6ST] = {
4212 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004213 .init_verbs = { alc880_volume_init_verbs,
4214 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004215 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4216 .dac_nids = alc880_6st_dac_nids,
4217 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4218 .channel_mode = alc880_sixstack_modes,
4219 .input_mux = &alc880_6stack_capture_source,
4220 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004221 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004222 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004223 .init_verbs = { alc880_volume_init_verbs,
4224 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004225 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4226 .dac_nids = alc880_6st_dac_nids,
4227 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004228 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4229 .channel_mode = alc880_sixstack_modes,
4230 .input_mux = &alc880_6stack_capture_source,
4231 },
4232 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004233 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004234 .init_verbs = { alc880_volume_init_verbs,
4235 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004236 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004237 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4238 .dac_nids = alc880_w810_dac_nids,
4239 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004240 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4241 .channel_mode = alc880_w810_modes,
4242 .input_mux = &alc880_capture_source,
4243 },
4244 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004245 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004246 .init_verbs = { alc880_volume_init_verbs,
4247 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004248 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4249 .dac_nids = alc880_z71v_dac_nids,
4250 .dig_out_nid = ALC880_DIGOUT_NID,
4251 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004252 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4253 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004254 .input_mux = &alc880_capture_source,
4255 },
4256 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004257 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004258 .init_verbs = { alc880_volume_init_verbs,
4259 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004260 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4261 .dac_nids = alc880_f1734_dac_nids,
4262 .hp_nid = 0x02,
4263 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4264 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004265 .input_mux = &alc880_f1734_capture_source,
4266 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004267 .setup = alc880_uniwill_p53_setup,
4268 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004269 },
4270 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004271 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004272 .init_verbs = { alc880_volume_init_verbs,
4273 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004274 alc880_gpio1_init_verbs },
4275 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4276 .dac_nids = alc880_asus_dac_nids,
4277 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4278 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004279 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004280 .input_mux = &alc880_capture_source,
4281 },
4282 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004283 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004284 .init_verbs = { alc880_volume_init_verbs,
4285 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004286 alc880_gpio1_init_verbs },
4287 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4288 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004289 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004290 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4291 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004292 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004293 .input_mux = &alc880_capture_source,
4294 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004295 [ALC880_ASUS_DIG2] = {
4296 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004297 .init_verbs = { alc880_volume_init_verbs,
4298 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004299 alc880_gpio2_init_verbs }, /* use GPIO2 */
4300 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4301 .dac_nids = alc880_asus_dac_nids,
4302 .dig_out_nid = ALC880_DIGOUT_NID,
4303 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4304 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004305 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004306 .input_mux = &alc880_capture_source,
4307 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004308 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004309 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004310 .init_verbs = { alc880_volume_init_verbs,
4311 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004312 alc880_gpio1_init_verbs },
4313 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4314 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004315 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004316 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4317 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004318 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004319 .input_mux = &alc880_capture_source,
4320 },
4321 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004322 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004323 .init_verbs = { alc880_volume_init_verbs,
4324 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004325 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4326 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004327 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004328 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4329 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004330 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004331 .input_mux = &alc880_capture_source,
4332 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004333 [ALC880_UNIWILL] = {
4334 .mixers = { alc880_uniwill_mixer },
4335 .init_verbs = { alc880_volume_init_verbs,
4336 alc880_uniwill_init_verbs },
4337 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4338 .dac_nids = alc880_asus_dac_nids,
4339 .dig_out_nid = ALC880_DIGOUT_NID,
4340 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4341 .channel_mode = alc880_threestack_modes,
4342 .need_dac_fix = 1,
4343 .input_mux = &alc880_capture_source,
4344 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004345 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004346 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004347 },
4348 [ALC880_UNIWILL_P53] = {
4349 .mixers = { alc880_uniwill_p53_mixer },
4350 .init_verbs = { alc880_volume_init_verbs,
4351 alc880_uniwill_p53_init_verbs },
4352 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4353 .dac_nids = alc880_asus_dac_nids,
4354 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004355 .channel_mode = alc880_threestack_modes,
4356 .input_mux = &alc880_capture_source,
4357 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004358 .setup = alc880_uniwill_p53_setup,
4359 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004360 },
4361 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004362 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004363 .init_verbs = { alc880_volume_init_verbs,
4364 alc880_uniwill_p53_init_verbs,
4365 alc880_beep_init_verbs },
4366 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4367 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004368 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004369 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4370 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004371 .input_mux = &alc880_capture_source,
4372 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004373 .setup = alc880_uniwill_p53_setup,
4374 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004375 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004376 [ALC880_CLEVO] = {
4377 .mixers = { alc880_three_stack_mixer },
4378 .init_verbs = { alc880_volume_init_verbs,
4379 alc880_pin_clevo_init_verbs },
4380 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4381 .dac_nids = alc880_dac_nids,
4382 .hp_nid = 0x03,
4383 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4384 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004385 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004386 .input_mux = &alc880_capture_source,
4387 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004388 [ALC880_LG] = {
4389 .mixers = { alc880_lg_mixer },
4390 .init_verbs = { alc880_volume_init_verbs,
4391 alc880_lg_init_verbs },
4392 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4393 .dac_nids = alc880_lg_dac_nids,
4394 .dig_out_nid = ALC880_DIGOUT_NID,
4395 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4396 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004397 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004398 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004399 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004400 .setup = alc880_lg_setup,
4401 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004402#ifdef CONFIG_SND_HDA_POWER_SAVE
4403 .loopbacks = alc880_lg_loopbacks,
4404#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004405 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004406 [ALC880_LG_LW] = {
4407 .mixers = { alc880_lg_lw_mixer },
4408 .init_verbs = { alc880_volume_init_verbs,
4409 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004410 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004411 .dac_nids = alc880_dac_nids,
4412 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004413 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4414 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004415 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004416 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004417 .setup = alc880_lg_lw_setup,
4418 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004419 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004420 [ALC880_MEDION_RIM] = {
4421 .mixers = { alc880_medion_rim_mixer },
4422 .init_verbs = { alc880_volume_init_verbs,
4423 alc880_medion_rim_init_verbs,
4424 alc_gpio2_init_verbs },
4425 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4426 .dac_nids = alc880_dac_nids,
4427 .dig_out_nid = ALC880_DIGOUT_NID,
4428 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4429 .channel_mode = alc880_2_jack_modes,
4430 .input_mux = &alc880_medion_rim_capture_source,
4431 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004432 .setup = alc880_medion_rim_setup,
4433 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004434 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004435#ifdef CONFIG_SND_DEBUG
4436 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004437 .mixers = { alc880_test_mixer },
4438 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004439 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4440 .dac_nids = alc880_test_dac_nids,
4441 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004442 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4443 .channel_mode = alc880_test_modes,
4444 .input_mux = &alc880_test_capture_source,
4445 },
4446#endif
4447};
4448
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004449/*
4450 * Automatic parse of I/O pins from the BIOS configuration
4451 */
4452
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004453enum {
4454 ALC_CTL_WIDGET_VOL,
4455 ALC_CTL_WIDGET_MUTE,
4456 ALC_CTL_BIND_MUTE,
4457};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004458static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004459 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4460 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004461 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004462};
4463
4464/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004465static int add_control(struct alc_spec *spec, int type, const char *name,
4466 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004467{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004468 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004469
Takashi Iwai603c4012008-07-30 15:01:44 +02004470 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4471 knew = snd_array_new(&spec->kctls);
4472 if (!knew)
4473 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004474 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004475 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004476 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004477 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004478 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004479 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004480 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004481 return 0;
4482}
4483
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004484static int add_control_with_pfx(struct alc_spec *spec, int type,
4485 const char *pfx, const char *dir,
4486 const char *sfx, unsigned long val)
4487{
4488 char name[32];
4489 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4490 return add_control(spec, type, name, val);
4491}
4492
4493#define add_pb_vol_ctrl(spec, type, pfx, val) \
4494 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4495#define add_pb_sw_ctrl(spec, type, pfx, val) \
4496 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4497
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004498#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4499#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4500#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4501#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004502#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4503#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4504#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4505#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4506#define ALC880_PIN_CD_NID 0x1c
4507
4508/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004509static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4510 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004511{
4512 hda_nid_t nid;
4513 int assigned[4];
4514 int i, j;
4515
4516 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004517 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004518
4519 /* check the pins hardwired to audio widget */
4520 for (i = 0; i < cfg->line_outs; i++) {
4521 nid = cfg->line_out_pins[i];
4522 if (alc880_is_fixed_pin(nid)) {
4523 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004524 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004525 assigned[idx] = 1;
4526 }
4527 }
4528 /* left pins can be connect to any audio widget */
4529 for (i = 0; i < cfg->line_outs; i++) {
4530 nid = cfg->line_out_pins[i];
4531 if (alc880_is_fixed_pin(nid))
4532 continue;
4533 /* search for an empty channel */
4534 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004535 if (!assigned[j]) {
4536 spec->multiout.dac_nids[i] =
4537 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004538 assigned[j] = 1;
4539 break;
4540 }
4541 }
4542 }
4543 spec->multiout.num_dacs = cfg->line_outs;
4544 return 0;
4545}
4546
4547/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004548static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4549 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004550{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004551 static const char *chname[4] = {
4552 "Front", "Surround", NULL /*CLFE*/, "Side"
4553 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004554 hda_nid_t nid;
4555 int i, err;
4556
4557 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004558 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004559 continue;
4560 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4561 if (i == 2) {
4562 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004563 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4564 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004565 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4566 HDA_OUTPUT));
4567 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004568 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004569 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4570 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004571 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4572 HDA_OUTPUT));
4573 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004574 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004575 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4576 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004577 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4578 HDA_INPUT));
4579 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004580 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004581 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4582 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004583 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4584 HDA_INPUT));
4585 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004586 return err;
4587 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004588 const char *pfx;
4589 if (cfg->line_outs == 1 &&
4590 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4591 pfx = "Speaker";
4592 else
4593 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004594 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004595 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4596 HDA_OUTPUT));
4597 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004598 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004599 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004600 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4601 HDA_INPUT));
4602 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004603 return err;
4604 }
4605 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004606 return 0;
4607}
4608
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004609/* add playback controls for speaker and HP outputs */
4610static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4611 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004612{
4613 hda_nid_t nid;
4614 int err;
4615
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004616 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004617 return 0;
4618
4619 if (alc880_is_fixed_pin(pin)) {
4620 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004621 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004622 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004623 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004624 else
4625 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004626 /* control HP volume/switch on the output mixer amp */
4627 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004628 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004629 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4630 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004631 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004632 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004633 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4634 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004635 return err;
4636 } else if (alc880_is_multi_pin(pin)) {
4637 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004638 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004639 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004640 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4641 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004642 return err;
4643 }
4644 return 0;
4645}
4646
4647/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004648static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4649 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004650 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004651{
Kailang Yangdf694da2005-12-05 19:42:22 +01004652 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004653
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004654 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004655 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4656 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004657 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004658 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004659 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4660 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004661 return err;
4662 return 0;
4663}
4664
Takashi Iwai05f5f472009-08-25 13:10:18 +02004665static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004666{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004667 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4668 return (pincap & AC_PINCAP_IN) != 0;
4669}
4670
4671/* create playback/capture controls for input pins */
4672static int alc_auto_create_input_ctls(struct hda_codec *codec,
4673 const struct auto_pin_cfg *cfg,
4674 hda_nid_t mixer,
4675 hda_nid_t cap1, hda_nid_t cap2)
4676{
4677 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004678 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004679 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004680
4681 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004682 hda_nid_t pin;
4683
4684 pin = cfg->input_pins[i];
4685 if (!alc_is_input_pin(codec, pin))
4686 continue;
4687
4688 if (mixer) {
4689 idx = get_connection_index(codec, mixer, pin);
4690 if (idx >= 0) {
4691 err = new_analog_input(spec, pin,
4692 auto_pin_cfg_labels[i],
4693 idx, mixer);
4694 if (err < 0)
4695 return err;
4696 }
4697 }
4698
4699 if (!cap1)
4700 continue;
4701 idx = get_connection_index(codec, cap1, pin);
4702 if (idx < 0 && cap2)
4703 idx = get_connection_index(codec, cap2, pin);
4704 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004705 imux->items[imux->num_items].label =
4706 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004707 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004708 imux->num_items++;
4709 }
4710 }
4711 return 0;
4712}
4713
Takashi Iwai05f5f472009-08-25 13:10:18 +02004714static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4715 const struct auto_pin_cfg *cfg)
4716{
4717 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4718}
4719
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004720static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4721 unsigned int pin_type)
4722{
4723 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4724 pin_type);
4725 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004726 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4727 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004728}
4729
Kailang Yangdf694da2005-12-05 19:42:22 +01004730static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4731 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004732 int dac_idx)
4733{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004734 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004735 /* need the manual connection? */
4736 if (alc880_is_multi_pin(nid)) {
4737 struct alc_spec *spec = codec->spec;
4738 int idx = alc880_multi_pin_idx(nid);
4739 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4740 AC_VERB_SET_CONNECT_SEL,
4741 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4742 }
4743}
4744
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004745static int get_pin_type(int line_out_type)
4746{
4747 if (line_out_type == AUTO_PIN_HP_OUT)
4748 return PIN_HP;
4749 else
4750 return PIN_OUT;
4751}
4752
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004753static void alc880_auto_init_multi_out(struct hda_codec *codec)
4754{
4755 struct alc_spec *spec = codec->spec;
4756 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004757
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004758 for (i = 0; i < spec->autocfg.line_outs; i++) {
4759 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004760 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4761 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004762 }
4763}
4764
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004765static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004766{
4767 struct alc_spec *spec = codec->spec;
4768 hda_nid_t pin;
4769
Takashi Iwai82bc9552006-03-21 11:24:42 +01004770 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004771 if (pin) /* connect to front */
4772 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004773 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004774 if (pin) /* connect to front */
4775 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4776}
4777
4778static void alc880_auto_init_analog_input(struct hda_codec *codec)
4779{
4780 struct alc_spec *spec = codec->spec;
4781 int i;
4782
4783 for (i = 0; i < AUTO_PIN_LAST; i++) {
4784 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004785 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004786 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004787 if (nid != ALC880_PIN_CD_NID &&
4788 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004789 snd_hda_codec_write(codec, nid, 0,
4790 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004791 AMP_OUT_MUTE);
4792 }
4793 }
4794}
4795
4796/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004797/* return 1 if successful, 0 if the proper config is not found,
4798 * or a negative error code
4799 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004800static int alc880_parse_auto_config(struct hda_codec *codec)
4801{
4802 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004803 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004804 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004805
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004806 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4807 alc880_ignore);
4808 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004809 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004810 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004811 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004812
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004813 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4814 if (err < 0)
4815 return err;
4816 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4817 if (err < 0)
4818 return err;
4819 err = alc880_auto_create_extra_out(spec,
4820 spec->autocfg.speaker_pins[0],
4821 "Speaker");
4822 if (err < 0)
4823 return err;
4824 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4825 "Headphone");
4826 if (err < 0)
4827 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004828 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004829 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004830 return err;
4831
4832 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4833
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004834 /* check multiple SPDIF-out (for recent codecs) */
4835 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4836 hda_nid_t dig_nid;
4837 err = snd_hda_get_connections(codec,
4838 spec->autocfg.dig_out_pins[i],
4839 &dig_nid, 1);
4840 if (err < 0)
4841 continue;
4842 if (!i)
4843 spec->multiout.dig_out_nid = dig_nid;
4844 else {
4845 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004846 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004847 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004848 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004849 }
4850 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004851 if (spec->autocfg.dig_in_pin)
4852 spec->dig_in_nid = ALC880_DIGIN_NID;
4853
Takashi Iwai603c4012008-07-30 15:01:44 +02004854 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004855 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004856
Takashi Iwaid88897e2008-10-31 15:01:37 +01004857 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004858
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004859 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004860 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004861
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004862 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4863
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004864 return 1;
4865}
4866
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004867/* additional initialization for auto-configuration model */
4868static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004869{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004870 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004871 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004872 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004873 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004874 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004875 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004876}
4877
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004878/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4879 * one of two digital mic pins, e.g. on ALC272
4880 */
4881static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004882{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004883 struct alc_spec *spec = codec->spec;
4884 int i;
4885
4886 for (i = 0; i < spec->num_adc_nids; i++) {
4887 hda_nid_t cap = spec->capsrc_nids ?
4888 spec->capsrc_nids[i] : spec->adc_nids[i];
4889 int iidx, eidx;
4890
4891 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4892 if (iidx < 0)
4893 continue;
4894 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4895 if (eidx < 0)
4896 continue;
4897 spec->int_mic.mux_idx = iidx;
4898 spec->ext_mic.mux_idx = eidx;
4899 if (spec->capsrc_nids)
4900 spec->capsrc_nids += i;
4901 spec->adc_nids += i;
4902 spec->num_adc_nids = 1;
4903 return;
4904 }
4905 snd_printd(KERN_INFO "hda_codec: %s: "
4906 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4907 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4908 spec->auto_mic = 0; /* disable auto-mic to be sure */
4909}
4910
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004911/* choose the ADC/MUX containing the input pin and initialize the setup */
4912static void fixup_single_adc(struct hda_codec *codec)
4913{
4914 struct alc_spec *spec = codec->spec;
4915 hda_nid_t pin;
4916 int i;
4917
4918 /* search for the input pin; there must be only one */
4919 for (i = 0; i < AUTO_PIN_LAST; i++) {
4920 if (spec->autocfg.input_pins[i]) {
4921 pin = spec->autocfg.input_pins[i];
4922 break;
4923 }
4924 }
4925 if (!pin)
4926 return;
4927
4928 /* set the default connection to that pin */
4929 for (i = 0; i < spec->num_adc_nids; i++) {
4930 hda_nid_t cap = spec->capsrc_nids ?
4931 spec->capsrc_nids[i] : spec->adc_nids[i];
4932 int idx;
4933
4934 idx = get_connection_index(codec, cap, pin);
4935 if (idx < 0)
4936 continue;
4937 /* use only this ADC */
4938 if (spec->capsrc_nids)
4939 spec->capsrc_nids += i;
4940 spec->adc_nids += i;
4941 spec->num_adc_nids = 1;
4942 /* select or unmute this route */
4943 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
4944 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
4945 HDA_AMP_MUTE, 0);
4946 } else {
4947 snd_hda_codec_write_cache(codec, cap, 0,
4948 AC_VERB_SET_CONNECT_SEL, idx);
4949 }
4950 return;
4951 }
4952}
4953
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004954static void set_capture_mixer(struct hda_codec *codec)
4955{
4956 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004957 static struct snd_kcontrol_new *caps[2][3] = {
4958 { alc_capture_mixer_nosrc1,
4959 alc_capture_mixer_nosrc2,
4960 alc_capture_mixer_nosrc3 },
4961 { alc_capture_mixer1,
4962 alc_capture_mixer2,
4963 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004964 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004965 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004966 int mux = 0;
4967 if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004968 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004969 else if (spec->input_mux) {
4970 if (spec->input_mux->num_items > 1)
4971 mux = 1;
4972 else if (spec->input_mux->num_items == 1)
4973 fixup_single_adc(codec);
4974 }
Takashi Iwaia23b6882009-03-23 15:21:36 +01004975 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4976 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004977}
4978
Takashi Iwai67d634c2009-11-16 15:35:59 +01004979#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004980#define set_beep_amp(spec, nid, idx, dir) \
4981 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01004982#else
4983#define set_beep_amp(spec, nid, idx, dir) /* NOP */
4984#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004985
4986/*
4987 * OK, here we have finally the patch for ALC880
4988 */
4989
Linus Torvalds1da177e2005-04-16 15:20:36 -07004990static int patch_alc880(struct hda_codec *codec)
4991{
4992 struct alc_spec *spec;
4993 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004994 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004995
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004996 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004997 if (spec == NULL)
4998 return -ENOMEM;
4999
5000 codec->spec = spec;
5001
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005002 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5003 alc880_models,
5004 alc880_cfg_tbl);
5005 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005006 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5007 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005008 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005009 }
5010
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005011 if (board_config == ALC880_AUTO) {
5012 /* automatic parse from the BIOS config */
5013 err = alc880_parse_auto_config(codec);
5014 if (err < 0) {
5015 alc_free(codec);
5016 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005017 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005018 printk(KERN_INFO
5019 "hda_codec: Cannot set up configuration "
5020 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005021 board_config = ALC880_3ST;
5022 }
5023 }
5024
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005025 err = snd_hda_attach_beep_device(codec, 0x1);
5026 if (err < 0) {
5027 alc_free(codec);
5028 return err;
5029 }
5030
Kailang Yangdf694da2005-12-05 19:42:22 +01005031 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005032 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005033
Linus Torvalds1da177e2005-04-16 15:20:36 -07005034 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5035 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005036 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005037
Linus Torvalds1da177e2005-04-16 15:20:36 -07005038 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5039 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5040
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005041 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005042 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005043 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005044 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005045 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005046 if (wcap != AC_WID_AUD_IN) {
5047 spec->adc_nids = alc880_adc_nids_alt;
5048 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005049 } else {
5050 spec->adc_nids = alc880_adc_nids;
5051 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005052 }
5053 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005054 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005055 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005056
Takashi Iwai2134ea42008-01-10 16:53:55 +01005057 spec->vmaster_nid = 0x0c;
5058
Linus Torvalds1da177e2005-04-16 15:20:36 -07005059 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005060 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005061 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005062#ifdef CONFIG_SND_HDA_POWER_SAVE
5063 if (!spec->loopback.amplist)
5064 spec->loopback.amplist = alc880_loopbacks;
5065#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005066
5067 return 0;
5068}
5069
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005070
Linus Torvalds1da177e2005-04-16 15:20:36 -07005071/*
5072 * ALC260 support
5073 */
5074
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005075static hda_nid_t alc260_dac_nids[1] = {
5076 /* front */
5077 0x02,
5078};
5079
5080static hda_nid_t alc260_adc_nids[1] = {
5081 /* ADC0 */
5082 0x04,
5083};
5084
Kailang Yangdf694da2005-12-05 19:42:22 +01005085static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005086 /* ADC1 */
5087 0x05,
5088};
5089
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005090/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5091 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5092 */
5093static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005094 /* ADC0, ADC1 */
5095 0x04, 0x05
5096};
5097
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005098#define ALC260_DIGOUT_NID 0x03
5099#define ALC260_DIGIN_NID 0x06
5100
5101static struct hda_input_mux alc260_capture_source = {
5102 .num_items = 4,
5103 .items = {
5104 { "Mic", 0x0 },
5105 { "Front Mic", 0x1 },
5106 { "Line", 0x2 },
5107 { "CD", 0x4 },
5108 },
5109};
5110
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005111/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005112 * headphone jack and the internal CD lines since these are the only pins at
5113 * which audio can appear. For flexibility, also allow the option of
5114 * recording the mixer output on the second ADC (ADC0 doesn't have a
5115 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005116 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005117static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5118 {
5119 .num_items = 3,
5120 .items = {
5121 { "Mic/Line", 0x0 },
5122 { "CD", 0x4 },
5123 { "Headphone", 0x2 },
5124 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005125 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005126 {
5127 .num_items = 4,
5128 .items = {
5129 { "Mic/Line", 0x0 },
5130 { "CD", 0x4 },
5131 { "Headphone", 0x2 },
5132 { "Mixer", 0x5 },
5133 },
5134 },
5135
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005136};
5137
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005138/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5139 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005140 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005141static struct hda_input_mux alc260_acer_capture_sources[2] = {
5142 {
5143 .num_items = 4,
5144 .items = {
5145 { "Mic", 0x0 },
5146 { "Line", 0x2 },
5147 { "CD", 0x4 },
5148 { "Headphone", 0x5 },
5149 },
5150 },
5151 {
5152 .num_items = 5,
5153 .items = {
5154 { "Mic", 0x0 },
5155 { "Line", 0x2 },
5156 { "CD", 0x4 },
5157 { "Headphone", 0x6 },
5158 { "Mixer", 0x5 },
5159 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005160 },
5161};
Michael Schwingencc959482009-02-22 18:58:45 +01005162
5163/* Maxdata Favorit 100XS */
5164static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5165 {
5166 .num_items = 2,
5167 .items = {
5168 { "Line/Mic", 0x0 },
5169 { "CD", 0x4 },
5170 },
5171 },
5172 {
5173 .num_items = 3,
5174 .items = {
5175 { "Line/Mic", 0x0 },
5176 { "CD", 0x4 },
5177 { "Mixer", 0x5 },
5178 },
5179 },
5180};
5181
Linus Torvalds1da177e2005-04-16 15:20:36 -07005182/*
5183 * This is just place-holder, so there's something for alc_build_pcms to look
5184 * at when it calculates the maximum number of channels. ALC260 has no mixer
5185 * element which allows changing the channel mode, so the verb list is
5186 * never used.
5187 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005188static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005189 { 2, NULL },
5190};
5191
Kailang Yangdf694da2005-12-05 19:42:22 +01005192
5193/* Mixer combinations
5194 *
5195 * basic: base_output + input + pc_beep + capture
5196 * HP: base_output + input + capture_alt
5197 * HP_3013: hp_3013 + input + capture
5198 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005199 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005200 */
5201
5202static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005203 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005204 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005205 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5206 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5207 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5208 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5209 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005210};
Kailang Yangdf694da2005-12-05 19:42:22 +01005211
5212static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005213 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5214 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5215 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5216 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5217 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5218 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5219 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5220 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005221 { } /* end */
5222};
5223
Takashi Iwaibec15c32008-01-28 18:16:30 +01005224/* update HP, line and mono out pins according to the master switch */
5225static void alc260_hp_master_update(struct hda_codec *codec,
5226 hda_nid_t hp, hda_nid_t line,
5227 hda_nid_t mono)
5228{
5229 struct alc_spec *spec = codec->spec;
5230 unsigned int val = spec->master_sw ? PIN_HP : 0;
5231 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005232 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005233 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005234 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005235 val);
5236 /* mono (speaker) depending on the HP jack sense */
5237 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005238 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005239 val);
5240}
5241
5242static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5243 struct snd_ctl_elem_value *ucontrol)
5244{
5245 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5246 struct alc_spec *spec = codec->spec;
5247 *ucontrol->value.integer.value = spec->master_sw;
5248 return 0;
5249}
5250
5251static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5252 struct snd_ctl_elem_value *ucontrol)
5253{
5254 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5255 struct alc_spec *spec = codec->spec;
5256 int val = !!*ucontrol->value.integer.value;
5257 hda_nid_t hp, line, mono;
5258
5259 if (val == spec->master_sw)
5260 return 0;
5261 spec->master_sw = val;
5262 hp = (kcontrol->private_value >> 16) & 0xff;
5263 line = (kcontrol->private_value >> 8) & 0xff;
5264 mono = kcontrol->private_value & 0xff;
5265 alc260_hp_master_update(codec, hp, line, mono);
5266 return 1;
5267}
5268
5269static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5270 {
5271 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5272 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005273 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005274 .info = snd_ctl_boolean_mono_info,
5275 .get = alc260_hp_master_sw_get,
5276 .put = alc260_hp_master_sw_put,
5277 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5278 },
5279 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5280 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5281 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5282 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5283 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5284 HDA_OUTPUT),
5285 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5286 { } /* end */
5287};
5288
5289static struct hda_verb alc260_hp_unsol_verbs[] = {
5290 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5291 {},
5292};
5293
5294static void alc260_hp_automute(struct hda_codec *codec)
5295{
5296 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005297
Wu Fengguang864f92b2009-11-18 12:38:02 +08005298 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005299 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5300}
5301
5302static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5303{
5304 if ((res >> 26) == ALC880_HP_EVENT)
5305 alc260_hp_automute(codec);
5306}
5307
Kailang Yangdf694da2005-12-05 19:42:22 +01005308static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005309 {
5310 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5311 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005312 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005313 .info = snd_ctl_boolean_mono_info,
5314 .get = alc260_hp_master_sw_get,
5315 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005316 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005317 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005318 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5319 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5320 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5321 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5322 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5323 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005324 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5325 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005326 { } /* end */
5327};
5328
Kailang Yang3f878302008-08-26 13:02:23 +02005329static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5330 .ops = &snd_hda_bind_vol,
5331 .values = {
5332 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5333 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5334 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5335 0
5336 },
5337};
5338
5339static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5340 .ops = &snd_hda_bind_sw,
5341 .values = {
5342 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5343 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5344 0
5345 },
5346};
5347
5348static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5349 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5350 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5351 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5352 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5353 { } /* end */
5354};
5355
Takashi Iwaibec15c32008-01-28 18:16:30 +01005356static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5357 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5358 {},
5359};
5360
5361static void alc260_hp_3013_automute(struct hda_codec *codec)
5362{
5363 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005364
Wu Fengguang864f92b2009-11-18 12:38:02 +08005365 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005366 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005367}
5368
5369static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5370 unsigned int res)
5371{
5372 if ((res >> 26) == ALC880_HP_EVENT)
5373 alc260_hp_3013_automute(codec);
5374}
5375
Kailang Yang3f878302008-08-26 13:02:23 +02005376static void alc260_hp_3012_automute(struct hda_codec *codec)
5377{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005378 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005379
Kailang Yang3f878302008-08-26 13:02:23 +02005380 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5381 bits);
5382 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5383 bits);
5384 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5385 bits);
5386}
5387
5388static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5389 unsigned int res)
5390{
5391 if ((res >> 26) == ALC880_HP_EVENT)
5392 alc260_hp_3012_automute(codec);
5393}
5394
5395/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005396 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5397 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005398static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005399 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005400 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005401 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005402 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5403 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5404 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5405 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005406 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005407 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5408 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005409 { } /* end */
5410};
5411
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005412/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5413 * versions of the ALC260 don't act on requests to enable mic bias from NID
5414 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5415 * datasheet doesn't mention this restriction. At this stage it's not clear
5416 * whether this behaviour is intentional or is a hardware bug in chip
5417 * revisions available in early 2006. Therefore for now allow the
5418 * "Headphone Jack Mode" control to span all choices, but if it turns out
5419 * that the lack of mic bias for this NID is intentional we could change the
5420 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5421 *
5422 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5423 * don't appear to make the mic bias available from the "line" jack, even
5424 * though the NID used for this jack (0x14) can supply it. The theory is
5425 * that perhaps Acer have included blocking capacitors between the ALC260
5426 * and the output jack. If this turns out to be the case for all such
5427 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5428 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005429 *
5430 * The C20x Tablet series have a mono internal speaker which is controlled
5431 * via the chip's Mono sum widget and pin complex, so include the necessary
5432 * controls for such models. On models without a "mono speaker" the control
5433 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005434 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005435static struct snd_kcontrol_new alc260_acer_mixer[] = {
5436 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5437 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005438 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005439 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005440 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005441 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005442 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005443 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5444 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5445 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5446 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5447 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5448 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5449 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5450 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005451 { } /* end */
5452};
5453
Michael Schwingencc959482009-02-22 18:58:45 +01005454/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5455 */
5456static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5457 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5458 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5459 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5460 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5461 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5462 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5463 { } /* end */
5464};
5465
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005466/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5467 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5468 */
5469static struct snd_kcontrol_new alc260_will_mixer[] = {
5470 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5471 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5473 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5474 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5475 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5476 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5477 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5478 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5479 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005480 { } /* end */
5481};
5482
5483/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5484 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5485 */
5486static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5487 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5488 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5489 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5490 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5491 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5492 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5493 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5494 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5495 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5496 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5497 { } /* end */
5498};
5499
Kailang Yangdf694da2005-12-05 19:42:22 +01005500/*
5501 * initialization verbs
5502 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005503static struct hda_verb alc260_init_verbs[] = {
5504 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005505 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005506 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005507 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005508 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005509 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005510 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005511 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005512 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005513 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005514 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005515 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005516 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005517 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005518 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005519 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005520 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005521 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5522 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005523 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005524 /* set connection select to line in (default select for this ADC) */
5525 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005526 /* mute capture amp left and right */
5527 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5528 /* set connection select to line in (default select for this ADC) */
5529 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005530 /* set vol=0 Line-Out mixer amp left and right */
5531 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5532 /* unmute pin widget amp left and right (no gain on this amp) */
5533 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5534 /* set vol=0 HP mixer amp left and right */
5535 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5536 /* unmute pin widget amp left and right (no gain on this amp) */
5537 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5538 /* set vol=0 Mono mixer amp left and right */
5539 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5540 /* unmute pin widget amp left and right (no gain on this amp) */
5541 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5542 /* unmute LINE-2 out pin */
5543 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005544 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5545 * Line In 2 = 0x03
5546 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005547 /* mute analog inputs */
5548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5549 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5551 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5552 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005553 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005554 /* mute Front out path */
5555 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5556 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5557 /* mute Headphone out path */
5558 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5559 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5560 /* mute Mono out path */
5561 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5562 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005563 { }
5564};
5565
Takashi Iwai474167d2006-05-17 17:17:43 +02005566#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005567static struct hda_verb alc260_hp_init_verbs[] = {
5568 /* Headphone and output */
5569 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5570 /* mono output */
5571 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5572 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5573 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5574 /* Mic2 (front panel) pin widget for input and vref at 80% */
5575 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5576 /* Line In pin widget for input */
5577 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5578 /* Line-2 pin widget for output */
5579 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5580 /* CD pin widget for input */
5581 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5582 /* unmute amp left and right */
5583 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5584 /* set connection select to line in (default select for this ADC) */
5585 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5586 /* unmute Line-Out mixer amp left and right (volume = 0) */
5587 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5588 /* mute pin widget amp left and right (no gain on this amp) */
5589 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5590 /* unmute HP mixer amp left and right (volume = 0) */
5591 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5592 /* mute pin widget amp left and right (no gain on this amp) */
5593 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005594 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5595 * Line In 2 = 0x03
5596 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005597 /* mute analog inputs */
5598 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5599 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5600 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5601 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5602 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005603 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5604 /* Unmute Front out path */
5605 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5606 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5607 /* Unmute Headphone out path */
5608 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5609 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5610 /* Unmute Mono out path */
5611 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5612 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5613 { }
5614};
Takashi Iwai474167d2006-05-17 17:17:43 +02005615#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005616
5617static struct hda_verb alc260_hp_3013_init_verbs[] = {
5618 /* Line out and output */
5619 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5620 /* mono output */
5621 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5622 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5623 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5624 /* Mic2 (front panel) pin widget for input and vref at 80% */
5625 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5626 /* Line In pin widget for input */
5627 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5628 /* Headphone pin widget for output */
5629 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5630 /* CD pin widget for input */
5631 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5632 /* unmute amp left and right */
5633 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5634 /* set connection select to line in (default select for this ADC) */
5635 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5636 /* unmute Line-Out mixer amp left and right (volume = 0) */
5637 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5638 /* mute pin widget amp left and right (no gain on this amp) */
5639 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5640 /* unmute HP mixer amp left and right (volume = 0) */
5641 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5642 /* mute pin widget amp left and right (no gain on this amp) */
5643 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005644 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5645 * Line In 2 = 0x03
5646 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005647 /* mute analog inputs */
5648 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5649 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5650 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5651 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5652 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005653 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5654 /* Unmute Front out path */
5655 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5656 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5657 /* Unmute Headphone out path */
5658 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5659 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5660 /* Unmute Mono out path */
5661 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5662 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5663 { }
5664};
5665
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005666/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005667 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5668 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005669 */
5670static struct hda_verb alc260_fujitsu_init_verbs[] = {
5671 /* Disable all GPIOs */
5672 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5673 /* Internal speaker is connected to headphone pin */
5674 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5675 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5676 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005677 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5678 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5679 /* Ensure all other unused pins are disabled and muted. */
5680 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5681 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005682 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005683 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005684 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005685 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5686 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5687 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005688
Jonathan Woithef7ace402006-02-28 11:46:14 +01005689 /* Disable digital (SPDIF) pins */
5690 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5691 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005692
Kailang Yangea1fb292008-08-26 12:58:38 +02005693 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005694 * when acting as an output.
5695 */
5696 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5697
5698 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005699 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5700 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5701 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5702 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5703 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5704 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5705 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5706 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5707 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005708
Jonathan Woithef7ace402006-02-28 11:46:14 +01005709 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5710 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5711 /* Unmute Line1 pin widget output buffer since it starts as an output.
5712 * If the pin mode is changed by the user the pin mode control will
5713 * take care of enabling the pin's input/output buffers as needed.
5714 * Therefore there's no need to enable the input buffer at this
5715 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005716 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005717 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005718 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005719 * mixer ctrl)
5720 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005721 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005722
Jonathan Woithef7ace402006-02-28 11:46:14 +01005723 /* Mute capture amp left and right */
5724 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005725 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005726 * in (on mic1 pin)
5727 */
5728 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005729
Jonathan Woithef7ace402006-02-28 11:46:14 +01005730 /* Do the same for the second ADC: mute capture input amp and
5731 * set ADC connection to line in (on mic1 pin)
5732 */
5733 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5734 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005735
Jonathan Woithef7ace402006-02-28 11:46:14 +01005736 /* Mute all inputs to mixer widget (even unconnected ones) */
5737 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5738 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5739 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5740 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5741 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5742 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5743 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5744 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005745
5746 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005747};
5748
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005749/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5750 * similar laptops (adapted from Fujitsu init verbs).
5751 */
5752static struct hda_verb alc260_acer_init_verbs[] = {
5753 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5754 * the headphone jack. Turn this on and rely on the standard mute
5755 * methods whenever the user wants to turn these outputs off.
5756 */
5757 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5758 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5759 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5760 /* Internal speaker/Headphone jack is connected to Line-out pin */
5761 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5762 /* Internal microphone/Mic jack is connected to Mic1 pin */
5763 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5764 /* Line In jack is connected to Line1 pin */
5765 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005766 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5767 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005768 /* Ensure all other unused pins are disabled and muted. */
5769 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5770 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005771 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5772 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5773 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5774 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5775 /* Disable digital (SPDIF) pins */
5776 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5777 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5778
Kailang Yangea1fb292008-08-26 12:58:38 +02005779 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005780 * bus when acting as outputs.
5781 */
5782 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5783 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5784
5785 /* Start with output sum widgets muted and their output gains at min */
5786 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5787 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5788 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5789 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5790 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5791 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5792 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5793 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5794 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5795
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005796 /* Unmute Line-out pin widget amp left and right
5797 * (no equiv mixer ctrl)
5798 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005799 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005800 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5801 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005802 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5803 * inputs. If the pin mode is changed by the user the pin mode control
5804 * will take care of enabling the pin's input/output buffers as needed.
5805 * Therefore there's no need to enable the input buffer at this
5806 * stage.
5807 */
5808 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5809 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5810
5811 /* Mute capture amp left and right */
5812 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5813 /* Set ADC connection select to match default mixer setting - mic
5814 * (on mic1 pin)
5815 */
5816 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5817
5818 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005819 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005820 */
5821 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005822 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005823
5824 /* Mute all inputs to mixer widget (even unconnected ones) */
5825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5826 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5827 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5828 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5829 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5830 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5831 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5832 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5833
5834 { }
5835};
5836
Michael Schwingencc959482009-02-22 18:58:45 +01005837/* Initialisation sequence for Maxdata Favorit 100XS
5838 * (adapted from Acer init verbs).
5839 */
5840static struct hda_verb alc260_favorit100_init_verbs[] = {
5841 /* GPIO 0 enables the output jack.
5842 * Turn this on and rely on the standard mute
5843 * methods whenever the user wants to turn these outputs off.
5844 */
5845 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5846 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5847 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5848 /* Line/Mic input jack is connected to Mic1 pin */
5849 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5850 /* Ensure all other unused pins are disabled and muted. */
5851 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5852 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5853 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5854 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5855 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5856 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5857 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5858 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5859 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5860 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5861 /* Disable digital (SPDIF) pins */
5862 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5863 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5864
5865 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5866 * bus when acting as outputs.
5867 */
5868 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5869 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5870
5871 /* Start with output sum widgets muted and their output gains at min */
5872 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5873 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5874 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5875 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5876 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5877 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5878 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5879 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5880 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5881
5882 /* Unmute Line-out pin widget amp left and right
5883 * (no equiv mixer ctrl)
5884 */
5885 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5886 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5887 * inputs. If the pin mode is changed by the user the pin mode control
5888 * will take care of enabling the pin's input/output buffers as needed.
5889 * Therefore there's no need to enable the input buffer at this
5890 * stage.
5891 */
5892 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5893
5894 /* Mute capture amp left and right */
5895 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5896 /* Set ADC connection select to match default mixer setting - mic
5897 * (on mic1 pin)
5898 */
5899 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5900
5901 /* Do similar with the second ADC: mute capture input amp and
5902 * set ADC connection to mic to match ALSA's default state.
5903 */
5904 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5905 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5906
5907 /* Mute all inputs to mixer widget (even unconnected ones) */
5908 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5909 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5910 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5911 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5912 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5913 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5914 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5915 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5916
5917 { }
5918};
5919
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005920static struct hda_verb alc260_will_verbs[] = {
5921 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5922 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5923 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5924 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5925 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5926 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5927 {}
5928};
5929
5930static struct hda_verb alc260_replacer_672v_verbs[] = {
5931 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5932 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5933 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5934
5935 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5936 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5937 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5938
5939 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5940 {}
5941};
5942
5943/* toggle speaker-output according to the hp-jack state */
5944static void alc260_replacer_672v_automute(struct hda_codec *codec)
5945{
5946 unsigned int present;
5947
5948 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08005949 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005950 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005951 snd_hda_codec_write_cache(codec, 0x01, 0,
5952 AC_VERB_SET_GPIO_DATA, 1);
5953 snd_hda_codec_write_cache(codec, 0x0f, 0,
5954 AC_VERB_SET_PIN_WIDGET_CONTROL,
5955 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005956 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005957 snd_hda_codec_write_cache(codec, 0x01, 0,
5958 AC_VERB_SET_GPIO_DATA, 0);
5959 snd_hda_codec_write_cache(codec, 0x0f, 0,
5960 AC_VERB_SET_PIN_WIDGET_CONTROL,
5961 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005962 }
5963}
5964
5965static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5966 unsigned int res)
5967{
5968 if ((res >> 26) == ALC880_HP_EVENT)
5969 alc260_replacer_672v_automute(codec);
5970}
5971
Kailang Yang3f878302008-08-26 13:02:23 +02005972static struct hda_verb alc260_hp_dc7600_verbs[] = {
5973 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5974 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5975 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5976 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5977 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5978 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5979 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5980 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5981 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5982 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5983 {}
5984};
5985
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005986/* Test configuration for debugging, modelled after the ALC880 test
5987 * configuration.
5988 */
5989#ifdef CONFIG_SND_DEBUG
5990static hda_nid_t alc260_test_dac_nids[1] = {
5991 0x02,
5992};
5993static hda_nid_t alc260_test_adc_nids[2] = {
5994 0x04, 0x05,
5995};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005996/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005997 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005998 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005999 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006000static struct hda_input_mux alc260_test_capture_sources[2] = {
6001 {
6002 .num_items = 7,
6003 .items = {
6004 { "MIC1 pin", 0x0 },
6005 { "MIC2 pin", 0x1 },
6006 { "LINE1 pin", 0x2 },
6007 { "LINE2 pin", 0x3 },
6008 { "CD pin", 0x4 },
6009 { "LINE-OUT pin", 0x5 },
6010 { "HP-OUT pin", 0x6 },
6011 },
6012 },
6013 {
6014 .num_items = 8,
6015 .items = {
6016 { "MIC1 pin", 0x0 },
6017 { "MIC2 pin", 0x1 },
6018 { "LINE1 pin", 0x2 },
6019 { "LINE2 pin", 0x3 },
6020 { "CD pin", 0x4 },
6021 { "Mixer", 0x5 },
6022 { "LINE-OUT pin", 0x6 },
6023 { "HP-OUT pin", 0x7 },
6024 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006025 },
6026};
6027static struct snd_kcontrol_new alc260_test_mixer[] = {
6028 /* Output driver widgets */
6029 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6030 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6031 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6032 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6033 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6034 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6035
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006036 /* Modes for retasking pin widgets
6037 * Note: the ALC260 doesn't seem to act on requests to enable mic
6038 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6039 * mention this restriction. At this stage it's not clear whether
6040 * this behaviour is intentional or is a hardware bug in chip
6041 * revisions available at least up until early 2006. Therefore for
6042 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6043 * choices, but if it turns out that the lack of mic bias for these
6044 * NIDs is intentional we could change their modes from
6045 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6046 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006047 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6048 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6049 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6050 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6051 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6052 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6053
6054 /* Loopback mixer controls */
6055 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6056 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6057 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6058 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6059 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6060 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6061 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6062 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6063 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6064 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006065 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6066 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6067 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6068 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006069
6070 /* Controls for GPIO pins, assuming they are configured as outputs */
6071 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6072 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6073 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6074 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6075
Jonathan Woithe92621f12006-02-28 11:47:47 +01006076 /* Switches to allow the digital IO pins to be enabled. The datasheet
6077 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006078 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006079 */
6080 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6081 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6082
Jonathan Woithef8225f62008-01-08 12:16:54 +01006083 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6084 * this output to turn on an external amplifier.
6085 */
6086 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6087 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6088
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006089 { } /* end */
6090};
6091static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006092 /* Enable all GPIOs as outputs with an initial value of 0 */
6093 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6094 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6095 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6096
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006097 /* Enable retasking pins as output, initially without power amp */
6098 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6099 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6100 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6101 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6102 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6103 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6104
Jonathan Woithe92621f12006-02-28 11:47:47 +01006105 /* Disable digital (SPDIF) pins initially, but users can enable
6106 * them via a mixer switch. In the case of SPDIF-out, this initverb
6107 * payload also sets the generation to 0, output to be in "consumer"
6108 * PCM format, copyright asserted, no pre-emphasis and no validity
6109 * control.
6110 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006111 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6112 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6113
Kailang Yangea1fb292008-08-26 12:58:38 +02006114 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006115 * OUT1 sum bus when acting as an output.
6116 */
6117 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6118 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6119 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6120 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6121
6122 /* Start with output sum widgets muted and their output gains at min */
6123 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6124 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6125 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6126 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6127 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6128 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6129 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6130 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6131 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6132
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006133 /* Unmute retasking pin widget output buffers since the default
6134 * state appears to be output. As the pin mode is changed by the
6135 * user the pin mode control will take care of enabling the pin's
6136 * input/output buffers as needed.
6137 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006138 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6139 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6140 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6141 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6142 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6143 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6144 /* Also unmute the mono-out pin widget */
6145 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6146
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006147 /* Mute capture amp left and right */
6148 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006149 /* Set ADC connection select to match default mixer setting (mic1
6150 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006151 */
6152 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6153
6154 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006155 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006156 */
6157 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6158 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6159
6160 /* Mute all inputs to mixer widget (even unconnected ones) */
6161 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6162 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6163 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6164 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6165 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6166 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6167 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6168 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6169
6170 { }
6171};
6172#endif
6173
Takashi Iwai63300792008-01-24 15:31:36 +01006174#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6175#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006176
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006177#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6178#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6179
Kailang Yangdf694da2005-12-05 19:42:22 +01006180/*
6181 * for BIOS auto-configuration
6182 */
6183
6184static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006185 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006186{
6187 hda_nid_t nid_vol;
6188 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006189 int err;
6190
6191 if (nid >= 0x0f && nid < 0x11) {
6192 nid_vol = nid - 0x7;
6193 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6194 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6195 } else if (nid == 0x11) {
6196 nid_vol = nid - 0x7;
6197 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6198 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6199 } else if (nid >= 0x12 && nid <= 0x15) {
6200 nid_vol = 0x08;
6201 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6202 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6203 } else
6204 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006205
Takashi Iwai863b4512008-10-21 17:01:47 +02006206 if (!(*vol_bits & (1 << nid_vol))) {
6207 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006208 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006209 if (err < 0)
6210 return err;
6211 *vol_bits |= (1 << nid_vol);
6212 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006213 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006214 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006215 return err;
6216 return 1;
6217}
6218
6219/* add playback controls from the parsed DAC table */
6220static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6221 const struct auto_pin_cfg *cfg)
6222{
6223 hda_nid_t nid;
6224 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006225 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006226
6227 spec->multiout.num_dacs = 1;
6228 spec->multiout.dac_nids = spec->private_dac_nids;
6229 spec->multiout.dac_nids[0] = 0x02;
6230
6231 nid = cfg->line_out_pins[0];
6232 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006233 const char *pfx;
6234 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6235 pfx = "Master";
6236 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6237 pfx = "Speaker";
6238 else
6239 pfx = "Front";
6240 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006241 if (err < 0)
6242 return err;
6243 }
6244
Takashi Iwai82bc9552006-03-21 11:24:42 +01006245 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006246 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006247 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006248 if (err < 0)
6249 return err;
6250 }
6251
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006252 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006253 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006254 err = alc260_add_playback_controls(spec, nid, "Headphone",
6255 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006256 if (err < 0)
6257 return err;
6258 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006259 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006260}
6261
6262/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006263static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006264 const struct auto_pin_cfg *cfg)
6265{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006266 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006267}
6268
6269static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6270 hda_nid_t nid, int pin_type,
6271 int sel_idx)
6272{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006273 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006274 /* need the manual connection? */
6275 if (nid >= 0x12) {
6276 int idx = nid - 0x12;
6277 snd_hda_codec_write(codec, idx + 0x0b, 0,
6278 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006279 }
6280}
6281
6282static void alc260_auto_init_multi_out(struct hda_codec *codec)
6283{
6284 struct alc_spec *spec = codec->spec;
6285 hda_nid_t nid;
6286
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006287 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006288 if (nid) {
6289 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6290 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6291 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006292
Takashi Iwai82bc9552006-03-21 11:24:42 +01006293 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006294 if (nid)
6295 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6296
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006297 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006298 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006299 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006300}
Kailang Yangdf694da2005-12-05 19:42:22 +01006301
6302#define ALC260_PIN_CD_NID 0x16
6303static void alc260_auto_init_analog_input(struct hda_codec *codec)
6304{
6305 struct alc_spec *spec = codec->spec;
6306 int i;
6307
6308 for (i = 0; i < AUTO_PIN_LAST; i++) {
6309 hda_nid_t nid = spec->autocfg.input_pins[i];
6310 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006311 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006312 if (nid != ALC260_PIN_CD_NID &&
6313 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006314 snd_hda_codec_write(codec, nid, 0,
6315 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006316 AMP_OUT_MUTE);
6317 }
6318 }
6319}
6320
6321/*
6322 * generic initialization of ADC, input mixers and output mixers
6323 */
6324static struct hda_verb alc260_volume_init_verbs[] = {
6325 /*
6326 * Unmute ADC0-1 and set the default input to mic-in
6327 */
6328 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6329 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6330 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6331 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006332
Kailang Yangdf694da2005-12-05 19:42:22 +01006333 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6334 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006335 * Note: PASD motherboards uses the Line In 2 as the input for
6336 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006337 */
6338 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006339 /* mute analog inputs */
6340 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6341 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6342 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6343 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6344 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006345
6346 /*
6347 * Set up output mixers (0x08 - 0x0a)
6348 */
6349 /* set vol=0 to output mixers */
6350 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6351 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6352 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6353 /* set up input amps for analog loopback */
6354 /* Amp Indices: DAC = 0, mixer = 1 */
6355 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6356 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6357 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6358 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6359 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6360 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006361
Kailang Yangdf694da2005-12-05 19:42:22 +01006362 { }
6363};
6364
6365static int alc260_parse_auto_config(struct hda_codec *codec)
6366{
6367 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006368 int err;
6369 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6370
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006371 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6372 alc260_ignore);
6373 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006374 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006375 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6376 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006377 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006378 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006379 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006380 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006381 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006382 return err;
6383
6384 spec->multiout.max_channels = 2;
6385
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006386 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006387 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006388 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006389 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006390
Takashi Iwaid88897e2008-10-31 15:01:37 +01006391 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006392
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006393 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006394 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006395
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006396 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6397
Kailang Yangdf694da2005-12-05 19:42:22 +01006398 return 1;
6399}
6400
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006401/* additional initialization for auto-configuration model */
6402static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006403{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006404 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006405 alc260_auto_init_multi_out(codec);
6406 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006407 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006408 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006409}
6410
Takashi Iwaicb53c622007-08-10 17:21:45 +02006411#ifdef CONFIG_SND_HDA_POWER_SAVE
6412static struct hda_amp_list alc260_loopbacks[] = {
6413 { 0x07, HDA_INPUT, 0 },
6414 { 0x07, HDA_INPUT, 1 },
6415 { 0x07, HDA_INPUT, 2 },
6416 { 0x07, HDA_INPUT, 3 },
6417 { 0x07, HDA_INPUT, 4 },
6418 { } /* end */
6419};
6420#endif
6421
Kailang Yangdf694da2005-12-05 19:42:22 +01006422/*
6423 * ALC260 configurations
6424 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006425static const char *alc260_models[ALC260_MODEL_LAST] = {
6426 [ALC260_BASIC] = "basic",
6427 [ALC260_HP] = "hp",
6428 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006429 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006430 [ALC260_FUJITSU_S702X] = "fujitsu",
6431 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006432 [ALC260_WILL] = "will",
6433 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006434 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006435#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006436 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006437#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006438 [ALC260_AUTO] = "auto",
6439};
6440
6441static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006442 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006443 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006444 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006445 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006446 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006447 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006448 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006449 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006450 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006451 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6452 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6453 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6454 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6455 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6456 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6457 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6458 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6459 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006460 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006461 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006462 {}
6463};
6464
Kailang Yangdf694da2005-12-05 19:42:22 +01006465static struct alc_config_preset alc260_presets[] = {
6466 [ALC260_BASIC] = {
6467 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006468 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006469 .init_verbs = { alc260_init_verbs },
6470 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6471 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006472 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006473 .adc_nids = alc260_adc_nids,
6474 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6475 .channel_mode = alc260_modes,
6476 .input_mux = &alc260_capture_source,
6477 },
6478 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006479 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006480 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006481 .init_verbs = { alc260_init_verbs,
6482 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006483 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6484 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006485 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6486 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006487 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6488 .channel_mode = alc260_modes,
6489 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006490 .unsol_event = alc260_hp_unsol_event,
6491 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006492 },
Kailang Yang3f878302008-08-26 13:02:23 +02006493 [ALC260_HP_DC7600] = {
6494 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006495 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006496 .init_verbs = { alc260_init_verbs,
6497 alc260_hp_dc7600_verbs },
6498 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6499 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006500 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6501 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006502 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6503 .channel_mode = alc260_modes,
6504 .input_mux = &alc260_capture_source,
6505 .unsol_event = alc260_hp_3012_unsol_event,
6506 .init_hook = alc260_hp_3012_automute,
6507 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006508 [ALC260_HP_3013] = {
6509 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006510 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006511 .init_verbs = { alc260_hp_3013_init_verbs,
6512 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006513 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6514 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006515 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6516 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006517 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6518 .channel_mode = alc260_modes,
6519 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006520 .unsol_event = alc260_hp_3013_unsol_event,
6521 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006522 },
6523 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006524 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006525 .init_verbs = { alc260_fujitsu_init_verbs },
6526 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6527 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006528 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6529 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006530 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6531 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006532 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6533 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006534 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006535 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006536 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006537 .init_verbs = { alc260_acer_init_verbs },
6538 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6539 .dac_nids = alc260_dac_nids,
6540 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6541 .adc_nids = alc260_dual_adc_nids,
6542 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6543 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006544 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6545 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006546 },
Michael Schwingencc959482009-02-22 18:58:45 +01006547 [ALC260_FAVORIT100] = {
6548 .mixers = { alc260_favorit100_mixer },
6549 .init_verbs = { alc260_favorit100_init_verbs },
6550 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6551 .dac_nids = alc260_dac_nids,
6552 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6553 .adc_nids = alc260_dual_adc_nids,
6554 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6555 .channel_mode = alc260_modes,
6556 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6557 .input_mux = alc260_favorit100_capture_sources,
6558 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006559 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006560 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006561 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6562 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6563 .dac_nids = alc260_dac_nids,
6564 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6565 .adc_nids = alc260_adc_nids,
6566 .dig_out_nid = ALC260_DIGOUT_NID,
6567 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6568 .channel_mode = alc260_modes,
6569 .input_mux = &alc260_capture_source,
6570 },
6571 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006572 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006573 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6574 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6575 .dac_nids = alc260_dac_nids,
6576 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6577 .adc_nids = alc260_adc_nids,
6578 .dig_out_nid = ALC260_DIGOUT_NID,
6579 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6580 .channel_mode = alc260_modes,
6581 .input_mux = &alc260_capture_source,
6582 .unsol_event = alc260_replacer_672v_unsol_event,
6583 .init_hook = alc260_replacer_672v_automute,
6584 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006585#ifdef CONFIG_SND_DEBUG
6586 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006587 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006588 .init_verbs = { alc260_test_init_verbs },
6589 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6590 .dac_nids = alc260_test_dac_nids,
6591 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6592 .adc_nids = alc260_test_adc_nids,
6593 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6594 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006595 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6596 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006597 },
6598#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006599};
6600
Linus Torvalds1da177e2005-04-16 15:20:36 -07006601static int patch_alc260(struct hda_codec *codec)
6602{
6603 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006604 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006605
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006606 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006607 if (spec == NULL)
6608 return -ENOMEM;
6609
6610 codec->spec = spec;
6611
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006612 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6613 alc260_models,
6614 alc260_cfg_tbl);
6615 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006616 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006617 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006618 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006619 }
6620
Kailang Yangdf694da2005-12-05 19:42:22 +01006621 if (board_config == ALC260_AUTO) {
6622 /* automatic parse from the BIOS config */
6623 err = alc260_parse_auto_config(codec);
6624 if (err < 0) {
6625 alc_free(codec);
6626 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006627 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006628 printk(KERN_INFO
6629 "hda_codec: Cannot set up configuration "
6630 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006631 board_config = ALC260_BASIC;
6632 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006633 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006634
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006635 err = snd_hda_attach_beep_device(codec, 0x1);
6636 if (err < 0) {
6637 alc_free(codec);
6638 return err;
6639 }
6640
Kailang Yangdf694da2005-12-05 19:42:22 +01006641 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006642 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006643
Linus Torvalds1da177e2005-04-16 15:20:36 -07006644 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6645 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6646
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006647 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6648 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6649
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006650 if (!spec->adc_nids && spec->input_mux) {
6651 /* check whether NID 0x04 is valid */
6652 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006653 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006654 /* get type */
6655 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6656 spec->adc_nids = alc260_adc_nids_alt;
6657 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6658 } else {
6659 spec->adc_nids = alc260_adc_nids;
6660 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6661 }
6662 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006663 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006664 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006665
Takashi Iwai2134ea42008-01-10 16:53:55 +01006666 spec->vmaster_nid = 0x08;
6667
Linus Torvalds1da177e2005-04-16 15:20:36 -07006668 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006669 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006670 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006671#ifdef CONFIG_SND_HDA_POWER_SAVE
6672 if (!spec->loopback.amplist)
6673 spec->loopback.amplist = alc260_loopbacks;
6674#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006675
6676 return 0;
6677}
6678
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006679
Linus Torvalds1da177e2005-04-16 15:20:36 -07006680/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006681 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006682 *
6683 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6684 * configuration. Each pin widget can choose any input DACs and a mixer.
6685 * Each ADC is connected from a mixer of all inputs. This makes possible
6686 * 6-channel independent captures.
6687 *
6688 * In addition, an independent DAC for the multi-playback (not used in this
6689 * driver yet).
6690 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006691#define ALC882_DIGOUT_NID 0x06
6692#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006693#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6694#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6695#define ALC1200_DIGOUT_NID 0x10
6696
Linus Torvalds1da177e2005-04-16 15:20:36 -07006697
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006698static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006699 { 8, NULL }
6700};
6701
Takashi Iwai4953550a2009-06-30 15:28:30 +02006702/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006703static hda_nid_t alc882_dac_nids[4] = {
6704 /* front, rear, clfe, rear_surr */
6705 0x02, 0x03, 0x04, 0x05
6706};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006707#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006708
Takashi Iwai4953550a2009-06-30 15:28:30 +02006709/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006710#define alc882_adc_nids alc880_adc_nids
6711#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006712#define alc883_adc_nids alc882_adc_nids_alt
6713static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6714static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6715#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006716
Takashi Iwaie1406342008-02-11 18:32:32 +01006717static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6718static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006719#define alc883_capsrc_nids alc882_capsrc_nids_alt
6720static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6721#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006722
Linus Torvalds1da177e2005-04-16 15:20:36 -07006723/* input MUX */
6724/* FIXME: should be a matrix-type input source selection */
6725
6726static struct hda_input_mux alc882_capture_source = {
6727 .num_items = 4,
6728 .items = {
6729 { "Mic", 0x0 },
6730 { "Front Mic", 0x1 },
6731 { "Line", 0x2 },
6732 { "CD", 0x4 },
6733 },
6734};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006735
Takashi Iwai4953550a2009-06-30 15:28:30 +02006736#define alc883_capture_source alc882_capture_source
6737
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006738static struct hda_input_mux alc889_capture_source = {
6739 .num_items = 3,
6740 .items = {
6741 { "Front Mic", 0x0 },
6742 { "Mic", 0x3 },
6743 { "Line", 0x2 },
6744 },
6745};
6746
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006747static struct hda_input_mux mb5_capture_source = {
6748 .num_items = 3,
6749 .items = {
6750 { "Mic", 0x1 },
6751 { "Line", 0x2 },
6752 { "CD", 0x4 },
6753 },
6754};
6755
Luke Yelaviche458b1f2010-02-12 16:28:29 +11006756static struct hda_input_mux macmini3_capture_source = {
6757 .num_items = 2,
6758 .items = {
6759 { "Line", 0x2 },
6760 { "CD", 0x4 },
6761 },
6762};
6763
Takashi Iwai4953550a2009-06-30 15:28:30 +02006764static struct hda_input_mux alc883_3stack_6ch_intel = {
6765 .num_items = 4,
6766 .items = {
6767 { "Mic", 0x1 },
6768 { "Front Mic", 0x0 },
6769 { "Line", 0x2 },
6770 { "CD", 0x4 },
6771 },
6772};
6773
6774static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6775 .num_items = 2,
6776 .items = {
6777 { "Mic", 0x1 },
6778 { "Line", 0x2 },
6779 },
6780};
6781
6782static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6783 .num_items = 4,
6784 .items = {
6785 { "Mic", 0x0 },
6786 { "iMic", 0x1 },
6787 { "Line", 0x2 },
6788 { "CD", 0x4 },
6789 },
6790};
6791
6792static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6793 .num_items = 2,
6794 .items = {
6795 { "Mic", 0x0 },
6796 { "Int Mic", 0x1 },
6797 },
6798};
6799
6800static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6801 .num_items = 3,
6802 .items = {
6803 { "Mic", 0x0 },
6804 { "Front Mic", 0x1 },
6805 { "Line", 0x4 },
6806 },
6807};
6808
6809static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6810 .num_items = 2,
6811 .items = {
6812 { "Mic", 0x0 },
6813 { "Line", 0x2 },
6814 },
6815};
6816
6817static struct hda_input_mux alc889A_mb31_capture_source = {
6818 .num_items = 2,
6819 .items = {
6820 { "Mic", 0x0 },
6821 /* Front Mic (0x01) unused */
6822 { "Line", 0x2 },
6823 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02006824 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006825 },
6826};
6827
6828/*
6829 * 2ch mode
6830 */
6831static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6832 { 2, NULL }
6833};
6834
Kailang Yangdf694da2005-12-05 19:42:22 +01006835/*
Kailang Yang272a5272007-05-14 11:00:38 +02006836 * 2ch mode
6837 */
6838static struct hda_verb alc882_3ST_ch2_init[] = {
6839 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6840 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6841 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6842 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6843 { } /* end */
6844};
6845
6846/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006847 * 4ch mode
6848 */
6849static struct hda_verb alc882_3ST_ch4_init[] = {
6850 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6851 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6852 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6853 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6854 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6855 { } /* end */
6856};
6857
6858/*
Kailang Yang272a5272007-05-14 11:00:38 +02006859 * 6ch mode
6860 */
6861static struct hda_verb alc882_3ST_ch6_init[] = {
6862 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6863 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6864 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6865 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6866 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6867 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6868 { } /* end */
6869};
6870
Takashi Iwai4953550a2009-06-30 15:28:30 +02006871static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006872 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006873 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006874 { 6, alc882_3ST_ch6_init },
6875};
6876
Takashi Iwai4953550a2009-06-30 15:28:30 +02006877#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6878
Kailang Yang272a5272007-05-14 11:00:38 +02006879/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306880 * 2ch mode
6881 */
6882static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6883 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6884 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6885 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6886 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6887 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6888 { } /* end */
6889};
6890
6891/*
6892 * 4ch mode
6893 */
6894static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6895 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6896 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6897 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6898 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6899 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6900 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6901 { } /* end */
6902};
6903
6904/*
6905 * 6ch mode
6906 */
6907static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6908 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6909 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6910 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6911 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6912 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6913 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6914 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6915 { } /* end */
6916};
6917
6918static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6919 { 2, alc883_3ST_ch2_clevo_init },
6920 { 4, alc883_3ST_ch4_clevo_init },
6921 { 6, alc883_3ST_ch6_clevo_init },
6922};
6923
6924
6925/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006926 * 6ch mode
6927 */
6928static struct hda_verb alc882_sixstack_ch6_init[] = {
6929 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6930 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6931 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6932 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6933 { } /* end */
6934};
6935
6936/*
6937 * 8ch mode
6938 */
6939static struct hda_verb alc882_sixstack_ch8_init[] = {
6940 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6941 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6942 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6943 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6944 { } /* end */
6945};
6946
6947static struct hda_channel_mode alc882_sixstack_modes[2] = {
6948 { 6, alc882_sixstack_ch6_init },
6949 { 8, alc882_sixstack_ch8_init },
6950};
6951
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08006952
6953/* Macbook Air 2,1 */
6954
6955static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
6956 { 2, NULL },
6957};
6958
Takashi Iwai87350ad2007-08-16 18:19:38 +02006959/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006960 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006961 */
6962
6963/*
6964 * 2ch mode
6965 */
6966static struct hda_verb alc885_mbp_ch2_init[] = {
6967 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6968 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6969 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6970 { } /* end */
6971};
6972
6973/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006974 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02006975 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006976static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006977 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6978 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6979 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6980 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6981 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6982 { } /* end */
6983};
6984
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006985static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006986 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006987 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006988};
6989
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006990/*
6991 * 2ch
6992 * Speakers/Woofer/HP = Front
6993 * LineIn = Input
6994 */
6995static struct hda_verb alc885_mb5_ch2_init[] = {
6996 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6997 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6998 { } /* end */
6999};
7000
7001/*
7002 * 6ch mode
7003 * Speakers/HP = Front
7004 * Woofer = LFE
7005 * LineIn = Surround
7006 */
7007static struct hda_verb alc885_mb5_ch6_init[] = {
7008 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7009 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7010 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7011 { } /* end */
7012};
7013
7014static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7015 { 2, alc885_mb5_ch2_init },
7016 { 6, alc885_mb5_ch6_init },
7017};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007018
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007019#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007020
7021/*
7022 * 2ch mode
7023 */
7024static struct hda_verb alc883_4ST_ch2_init[] = {
7025 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7026 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7027 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7028 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7029 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7030 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7031 { } /* end */
7032};
7033
7034/*
7035 * 4ch mode
7036 */
7037static struct hda_verb alc883_4ST_ch4_init[] = {
7038 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7039 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7040 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7041 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7042 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7043 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7044 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7045 { } /* end */
7046};
7047
7048/*
7049 * 6ch mode
7050 */
7051static struct hda_verb alc883_4ST_ch6_init[] = {
7052 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7053 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7054 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7055 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7056 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7057 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7058 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7059 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7060 { } /* end */
7061};
7062
7063/*
7064 * 8ch mode
7065 */
7066static struct hda_verb alc883_4ST_ch8_init[] = {
7067 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7068 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7069 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7070 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7071 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7072 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7073 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7074 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7075 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7076 { } /* end */
7077};
7078
7079static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7080 { 2, alc883_4ST_ch2_init },
7081 { 4, alc883_4ST_ch4_init },
7082 { 6, alc883_4ST_ch6_init },
7083 { 8, alc883_4ST_ch8_init },
7084};
7085
7086
7087/*
7088 * 2ch mode
7089 */
7090static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7091 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7092 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7093 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7094 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7095 { } /* end */
7096};
7097
7098/*
7099 * 4ch mode
7100 */
7101static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7102 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7103 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7104 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7105 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7106 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7107 { } /* end */
7108};
7109
7110/*
7111 * 6ch mode
7112 */
7113static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7114 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7115 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7116 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7117 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7118 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7119 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7120 { } /* end */
7121};
7122
7123static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7124 { 2, alc883_3ST_ch2_intel_init },
7125 { 4, alc883_3ST_ch4_intel_init },
7126 { 6, alc883_3ST_ch6_intel_init },
7127};
7128
7129/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007130 * 2ch mode
7131 */
7132static struct hda_verb alc889_ch2_intel_init[] = {
7133 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7134 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7135 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7136 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7137 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7138 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7139 { } /* end */
7140};
7141
7142/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007143 * 6ch mode
7144 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007145static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007146 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7147 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7148 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7149 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7150 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007151 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7152 { } /* end */
7153};
7154
7155/*
7156 * 8ch mode
7157 */
7158static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007159 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7160 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7161 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7162 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7163 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007164 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7165 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007166 { } /* end */
7167};
7168
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007169static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7170 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007171 { 6, alc889_ch6_intel_init },
7172 { 8, alc889_ch8_intel_init },
7173};
7174
7175/*
7176 * 6ch mode
7177 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007178static struct hda_verb alc883_sixstack_ch6_init[] = {
7179 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7180 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7181 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7182 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7183 { } /* end */
7184};
7185
7186/*
7187 * 8ch mode
7188 */
7189static struct hda_verb alc883_sixstack_ch8_init[] = {
7190 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7191 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7192 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7193 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7194 { } /* end */
7195};
7196
7197static struct hda_channel_mode alc883_sixstack_modes[2] = {
7198 { 6, alc883_sixstack_ch6_init },
7199 { 8, alc883_sixstack_ch8_init },
7200};
7201
7202
Linus Torvalds1da177e2005-04-16 15:20:36 -07007203/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7204 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7205 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007206static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007207 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007208 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007209 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007210 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007211 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7212 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007213 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7214 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007215 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007216 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007217 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7218 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7219 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7220 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7221 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7222 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007223 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007224 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7225 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007226 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007227 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007228 { } /* end */
7229};
7230
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007231/* Macbook Air 2,1 same control for HP and internal Speaker */
7232
7233static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7234 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7235 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7236 { }
7237};
7238
7239
Takashi Iwai87350ad2007-08-16 18:19:38 +02007240static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007241 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7242 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7243 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7244 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7245 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007246 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7247 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007248 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7249 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007250 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007251 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7252 { } /* end */
7253};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007254
7255static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007256 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7257 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7258 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7259 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7260 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7261 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307262 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7263 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007264 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7265 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7266 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7267 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7268 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7269 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7270 { } /* end */
7271};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007272
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007273static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7274 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7275 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7276 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7277 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7278 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7279 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7280 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7281 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7282 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7283 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7284 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7285 { } /* end */
7286};
7287
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007288static struct snd_kcontrol_new alc885_imac91_mixer[] = {
7289 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7290 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
7291 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
7292 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7293 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7294 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7295 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7296 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7297 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7298 { } /* end */
7299};
7300
7301
Kailang Yangbdd148a2007-05-08 15:19:08 +02007302static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7303 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7304 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7305 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7306 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7307 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7308 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7309 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7310 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7311 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007312 { } /* end */
7313};
7314
Kailang Yang272a5272007-05-14 11:00:38 +02007315static struct snd_kcontrol_new alc882_targa_mixer[] = {
7316 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7317 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7318 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7319 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7320 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7321 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7322 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7323 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7324 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007325 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007326 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7327 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007328 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007329 { } /* end */
7330};
7331
7332/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7333 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7334 */
7335static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7336 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7337 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7338 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7339 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7340 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7341 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7342 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7343 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7344 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7345 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7346 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7347 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007348 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007349 { } /* end */
7350};
7351
Takashi Iwai914759b2007-09-06 14:52:04 +02007352static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7353 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7354 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7355 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7356 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7357 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7358 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7359 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7360 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7361 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7362 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007363 { } /* end */
7364};
7365
Kailang Yangdf694da2005-12-05 19:42:22 +01007366static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7367 {
7368 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7369 .name = "Channel Mode",
7370 .info = alc_ch_mode_info,
7371 .get = alc_ch_mode_get,
7372 .put = alc_ch_mode_put,
7373 },
7374 { } /* end */
7375};
7376
Takashi Iwai4953550a2009-06-30 15:28:30 +02007377static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007378 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007379 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7380 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007381 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007382 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7383 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007384 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007385 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7386 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007387 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007388 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7389 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007390
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007391 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007392 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007393 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007394 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007395 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007396 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007397 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007398 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007399 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007400 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007401 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007402 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007403 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007404 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007405 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007406 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007407 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007408 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007409 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7410 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007411 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007412 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7413 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007414 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007415 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7416 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7417 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7418 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7419 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007420 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007421 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007422
7423 /* FIXME: use matrix-type input source selection */
7424 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007425 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007426 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007427 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007428 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007429 /* ADC2: mute amp left and right */
7430 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007431 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007432 /* ADC3: mute amp left and right */
7433 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007434 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007435
7436 { }
7437};
7438
Takashi Iwai4953550a2009-06-30 15:28:30 +02007439static struct hda_verb alc882_adc1_init_verbs[] = {
7440 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7441 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7442 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7443 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7444 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7445 /* ADC1: mute amp left and right */
7446 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7447 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7448 { }
7449};
7450
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007451static struct hda_verb alc882_eapd_verbs[] = {
7452 /* change to EAPD mode */
7453 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007454 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007455 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007456};
7457
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007458static struct hda_verb alc889_eapd_verbs[] = {
7459 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7460 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7461 { }
7462};
7463
Wu Fengguang6732bd02009-07-30 09:19:14 +02007464static struct hda_verb alc_hp15_unsol_verbs[] = {
7465 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7467 {}
7468};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007469
7470static struct hda_verb alc885_init_verbs[] = {
7471 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01007472 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7473 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007474 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007475 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7476 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007477 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007478 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7479 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007480 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007481 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7482 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007483
7484 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007485 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007486 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7487 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7488 /* Front Pin: output 0 (0x0c) */
7489 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7490 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7491 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7492 /* Rear Pin: output 1 (0x0d) */
7493 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7494 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7495 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7496 /* CLFE Pin: output 2 (0x0e) */
7497 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7498 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7499 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7500 /* Side Pin: output 3 (0x0f) */
7501 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7502 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7503 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7504 /* Mic (rear) pin: input vref at 80% */
7505 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7506 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7507 /* Front Mic pin: input vref at 80% */
7508 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7509 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7510 /* Line In pin: input */
7511 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7512 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7513
7514 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7515 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01007516 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007517 /* Input mixer2 */
7518 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007519 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01007520 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007521 /* ADC2: mute amp left and right */
7522 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7523 /* ADC3: mute amp left and right */
7524 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7525
7526 { }
7527};
7528
7529static struct hda_verb alc885_init_input_verbs[] = {
7530 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7531 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7532 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7533 { }
7534};
7535
7536
7537/* Unmute Selector 24h and set the default input to front mic */
7538static struct hda_verb alc889_init_input_verbs[] = {
7539 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7540 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7541 { }
7542};
7543
7544
Takashi Iwai4953550a2009-06-30 15:28:30 +02007545#define alc883_init_verbs alc882_base_init_verbs
7546
Tobin Davis9102cd12006-12-15 10:02:12 +01007547/* Mac Pro test */
7548static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7549 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7550 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7551 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7552 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7553 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007554 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007555 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7556 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007557 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007558 { } /* end */
7559};
7560
7561static struct hda_verb alc882_macpro_init_verbs[] = {
7562 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7563 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7564 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7565 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7566 /* Front Pin: output 0 (0x0c) */
7567 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7568 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7569 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7570 /* Front Mic pin: input vref at 80% */
7571 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7572 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7573 /* Speaker: output */
7574 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7575 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7576 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7577 /* Headphone output (output 0 - 0x0c) */
7578 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7579 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7580 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7581
7582 /* FIXME: use matrix-type input source selection */
7583 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7584 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7585 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7586 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7587 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7588 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7589 /* Input mixer2 */
7590 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7591 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7592 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7593 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7594 /* Input mixer3 */
7595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7596 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7597 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7598 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7599 /* ADC1: mute amp left and right */
7600 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7601 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7602 /* ADC2: mute amp left and right */
7603 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7604 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7605 /* ADC3: mute amp left and right */
7606 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7607 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7608
7609 { }
7610};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007611
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007612/* Macbook 5,1 */
7613static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007614 /* DACs */
7615 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7616 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7617 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7618 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007619 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007620 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7621 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7622 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007623 /* Surround mixer */
7624 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7625 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7626 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7627 /* LFE mixer */
7628 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7629 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7630 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7631 /* HP mixer */
7632 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7633 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7634 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7635 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007636 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7637 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007638 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7639 /* LFE Pin (0x0e) */
7640 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7641 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7642 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7643 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007644 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7645 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007646 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10307647 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007648 /* Front Mic pin: input vref at 80% */
7649 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7650 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7651 /* Line In pin */
7652 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7653 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7654
7655 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7656 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7657 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7658 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7659 { }
7660};
7661
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007662/* Macmini 3,1 */
7663static struct hda_verb alc885_macmini3_init_verbs[] = {
7664 /* DACs */
7665 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7666 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7667 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7668 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7669 /* Front mixer */
7670 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7671 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7672 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7673 /* Surround mixer */
7674 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7675 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7676 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7677 /* LFE mixer */
7678 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7679 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7680 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7681 /* HP mixer */
7682 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7683 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7684 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7685 /* Front Pin (0x0c) */
7686 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7687 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7688 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7689 /* LFE Pin (0x0e) */
7690 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7692 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7693 /* HP Pin (0x0f) */
7694 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7695 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7696 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
7697 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7698 /* Line In pin */
7699 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7700 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7701
7702 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7703 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7704 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7705 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7706 { }
7707};
7708
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007709
7710static struct hda_verb alc885_mba21_init_verbs[] = {
7711 /*Internal and HP Speaker Mixer*/
7712 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7713 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7714 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7715 /*Internal Speaker Pin (0x0c)*/
7716 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
7717 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7718 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7719 /* HP Pin: output 0 (0x0e) */
7720 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7721 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7722 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7723 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
7724 /* Line in (is hp when jack connected)*/
7725 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
7726 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7727
7728 { }
7729 };
7730
7731
Takashi Iwai87350ad2007-08-16 18:19:38 +02007732/* Macbook Pro rev3 */
7733static struct hda_verb alc885_mbp3_init_verbs[] = {
7734 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7735 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7736 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7737 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7738 /* Rear mixer */
7739 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7740 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7741 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007742 /* HP mixer */
7743 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7744 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7745 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007746 /* Front Pin: output 0 (0x0c) */
7747 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7748 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7749 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007750 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007751 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007752 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7753 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007754 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7755 /* Mic (rear) pin: input vref at 80% */
7756 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7757 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7758 /* Front Mic pin: input vref at 80% */
7759 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7760 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7761 /* Line In pin: use output 1 when in LineOut mode */
7762 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7763 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7764 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7765
7766 /* FIXME: use matrix-type input source selection */
7767 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7768 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7769 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7770 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7771 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7772 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7773 /* Input mixer2 */
7774 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7775 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7776 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7777 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7778 /* Input mixer3 */
7779 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7780 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7781 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7782 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7783 /* ADC1: mute amp left and right */
7784 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7785 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7786 /* ADC2: mute amp left and right */
7787 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7788 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7789 /* ADC3: mute amp left and right */
7790 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7791 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7792
7793 { }
7794};
7795
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007796/* iMac 9,1 */
7797static struct hda_verb alc885_imac91_init_verbs[] = {
7798 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
7799 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7800 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7801 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7802 /* Rear mixer */
7803 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7804 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7805 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7806 /* HP Pin: output 0 (0x0c) */
7807 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7808 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7809 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7810 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7811 /* Internal Speakers: output 0 (0x0d) */
7812 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7813 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7814 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7815 /* Mic (rear) pin: input vref at 80% */
7816 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7817 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7818 /* Front Mic pin: input vref at 80% */
7819 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7820 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7821 /* Line In pin: use output 1 when in LineOut mode */
7822 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7823 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7824 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7825
7826 /* FIXME: use matrix-type input source selection */
7827 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7828 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7829 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7830 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7831 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7832 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7833 /* Input mixer2 */
7834 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7835 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7836 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7837 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7838 /* Input mixer3 */
7839 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7840 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7841 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7842 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7843 /* ADC1: mute amp left and right */
7844 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7845 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7846 /* ADC2: mute amp left and right */
7847 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7848 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7849 /* ADC3: mute amp left and right */
7850 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7851 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7852
7853 { }
7854};
7855
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007856/* iMac 24 mixer. */
7857static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7858 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7859 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7860 { } /* end */
7861};
7862
7863/* iMac 24 init verbs. */
7864static struct hda_verb alc885_imac24_init_verbs[] = {
7865 /* Internal speakers: output 0 (0x0c) */
7866 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7867 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7868 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7869 /* Internal speakers: output 0 (0x0c) */
7870 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7871 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7872 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7873 /* Headphone: output 0 (0x0c) */
7874 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7875 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7876 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7877 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7878 /* Front Mic: input vref at 80% */
7879 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7880 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7881 { }
7882};
7883
7884/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007885static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007886{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007887 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007888
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007889 spec->autocfg.hp_pins[0] = 0x14;
7890 spec->autocfg.speaker_pins[0] = 0x18;
7891 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007892}
7893
Takashi Iwai9d54f082010-02-22 08:34:40 +01007894#define alc885_mb5_setup alc885_imac24_setup
7895#define alc885_macmini3_setup alc885_imac24_setup
7896
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007897/* Macbook Air 2,1 */
7898static void alc885_mba21_setup(struct hda_codec *codec)
7899{
7900 struct alc_spec *spec = codec->spec;
7901
7902 spec->autocfg.hp_pins[0] = 0x14;
7903 spec->autocfg.speaker_pins[0] = 0x18;
7904}
7905
7906
7907
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007908static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007909{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007910 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007911
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007912 spec->autocfg.hp_pins[0] = 0x15;
7913 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007914}
7915
Takashi Iwai9d54f082010-02-22 08:34:40 +01007916static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10307917{
Takashi Iwai9d54f082010-02-22 08:34:40 +01007918 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10307919
Takashi Iwai9d54f082010-02-22 08:34:40 +01007920 spec->autocfg.hp_pins[0] = 0x14;
7921 spec->autocfg.speaker_pins[0] = 0x15;
7922 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007923}
Takashi Iwai87350ad2007-08-16 18:19:38 +02007924
Kailang Yang272a5272007-05-14 11:00:38 +02007925static struct hda_verb alc882_targa_verbs[] = {
7926 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7927 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7928
7929 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7930 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007931
Kailang Yang272a5272007-05-14 11:00:38 +02007932 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7933 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7934 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7935
7936 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007937 { } /* end */
7938};
7939
7940/* toggle speaker-output according to the hp-jack state */
7941static void alc882_targa_automute(struct hda_codec *codec)
7942{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007943 struct alc_spec *spec = codec->spec;
7944 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007945 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007946 spec->jack_present ? 1 : 3);
7947}
7948
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007949static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007950{
7951 struct alc_spec *spec = codec->spec;
7952
7953 spec->autocfg.hp_pins[0] = 0x14;
7954 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007955}
7956
7957static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7958{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007959 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007960 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007961}
7962
7963static struct hda_verb alc882_asus_a7j_verbs[] = {
7964 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7965 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7966
7967 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7968 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7969 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007970
Kailang Yang272a5272007-05-14 11:00:38 +02007971 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7972 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7973 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7974
7975 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7976 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7977 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7978 { } /* end */
7979};
7980
Takashi Iwai914759b2007-09-06 14:52:04 +02007981static struct hda_verb alc882_asus_a7m_verbs[] = {
7982 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7983 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7984
7985 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7986 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7987 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007988
Takashi Iwai914759b2007-09-06 14:52:04 +02007989 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7990 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7991 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7992
7993 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7994 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7995 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7996 { } /* end */
7997};
7998
Tobin Davis9102cd12006-12-15 10:02:12 +01007999static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8000{
8001 unsigned int gpiostate, gpiomask, gpiodir;
8002
8003 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8004 AC_VERB_GET_GPIO_DATA, 0);
8005
8006 if (!muted)
8007 gpiostate |= (1 << pin);
8008 else
8009 gpiostate &= ~(1 << pin);
8010
8011 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8012 AC_VERB_GET_GPIO_MASK, 0);
8013 gpiomask |= (1 << pin);
8014
8015 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8016 AC_VERB_GET_GPIO_DIRECTION, 0);
8017 gpiodir |= (1 << pin);
8018
8019
8020 snd_hda_codec_write(codec, codec->afg, 0,
8021 AC_VERB_SET_GPIO_MASK, gpiomask);
8022 snd_hda_codec_write(codec, codec->afg, 0,
8023 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8024
8025 msleep(1);
8026
8027 snd_hda_codec_write(codec, codec->afg, 0,
8028 AC_VERB_SET_GPIO_DATA, gpiostate);
8029}
8030
Takashi Iwai7debbe52007-08-16 15:01:03 +02008031/* set up GPIO at initialization */
8032static void alc885_macpro_init_hook(struct hda_codec *codec)
8033{
8034 alc882_gpio_mute(codec, 0, 0);
8035 alc882_gpio_mute(codec, 1, 0);
8036}
8037
8038/* set up GPIO and update auto-muting at initialization */
8039static void alc885_imac24_init_hook(struct hda_codec *codec)
8040{
8041 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008042 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008043}
8044
Kailang Yangdf694da2005-12-05 19:42:22 +01008045/*
8046 * generic initialization of ADC, input mixers and output mixers
8047 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008048static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008049 /*
8050 * Unmute ADC0-2 and set the default input to mic-in
8051 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008052 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8053 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8054 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8055 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8056
Kailang Yangdf694da2005-12-05 19:42:22 +01008057 /*
8058 * Set up output mixers (0x0c - 0x0f)
8059 */
8060 /* set vol=0 to output mixers */
8061 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8062 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8063 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8064 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8065 /* set up input amps for analog loopback */
8066 /* Amp Indices: DAC = 0, mixer = 1 */
8067 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8068 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8069 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8070 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8071 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8072 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8073 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8074 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8075 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8076 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8077
8078 /* FIXME: use matrix-type input source selection */
8079 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008080 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008081 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008082 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008083 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008084 { }
8085};
8086
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008087/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8088static struct hda_verb alc889A_mb31_ch2_init[] = {
8089 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8090 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8091 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8092 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8093 { } /* end */
8094};
8095
8096/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8097static struct hda_verb alc889A_mb31_ch4_init[] = {
8098 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8099 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8100 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8101 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8102 { } /* end */
8103};
8104
8105/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8106static struct hda_verb alc889A_mb31_ch5_init[] = {
8107 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8108 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8109 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8110 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8111 { } /* end */
8112};
8113
8114/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8115static struct hda_verb alc889A_mb31_ch6_init[] = {
8116 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8117 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8118 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8119 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8120 { } /* end */
8121};
8122
8123static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8124 { 2, alc889A_mb31_ch2_init },
8125 { 4, alc889A_mb31_ch4_init },
8126 { 5, alc889A_mb31_ch5_init },
8127 { 6, alc889A_mb31_ch6_init },
8128};
8129
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008130static struct hda_verb alc883_medion_eapd_verbs[] = {
8131 /* eanable EAPD on medion laptop */
8132 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8133 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8134 { }
8135};
8136
Takashi Iwai4953550a2009-06-30 15:28:30 +02008137#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008138
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008139static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8140 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8141 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8142 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8143 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8144 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8145 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8146 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8147 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8148 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8149 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8150 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8151 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8152 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008153 { } /* end */
8154};
8155
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008156static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008157 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8158 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8159 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8160 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8161 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8162 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8164 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8165 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8166 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008167 { } /* end */
8168};
8169
Jiang zhefb97dc62008-03-06 11:07:11 +01008170static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8171 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8172 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8173 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8174 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8175 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8176 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8177 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8178 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8179 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8180 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008181 { } /* end */
8182};
8183
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008184static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8185 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8186 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8187 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8188 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8189 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8190 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8191 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8192 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008193 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008194 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8195 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008196 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008197 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008198 { } /* end */
8199};
8200
8201static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8202 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8203 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8204 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8205 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8206 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8207 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8208 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8209 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8210 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8211 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8212 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8213 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8214 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008216 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008217 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8218 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008219 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008220 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008221 { } /* end */
8222};
8223
Jiang zhe17bba1b2008-06-04 12:11:07 +02008224static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8225 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8226 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8227 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8228 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8229 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8230 HDA_OUTPUT),
8231 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8232 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8233 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8234 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8235 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8236 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8237 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8238 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8239 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8240 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8241 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8242 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8243 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8244 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008245 { } /* end */
8246};
8247
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008248static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8249 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8250 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8251 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8252 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8253 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8254 HDA_OUTPUT),
8255 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8256 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8257 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8258 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8259 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8260 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
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, 0x3, HDA_INPUT),
8264 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8265 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8266 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8267 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8268 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8269 { } /* end */
8270};
8271
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008272static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008273 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008274 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008275 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008276 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008277 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),
Takashi Iwai0701e062008-06-27 16:30:57 +02008279 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),
Tobin Davisc07584c2006-10-13 12:32:16 +02008281 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),
Tobin Davisc07584c2006-10-13 12:32:16 +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),
Tobin Davisc07584c2006-10-13 12:32:16 +02008291 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008292 { } /* end */
8293};
8294
Sasha Alexandrc2592492009-06-16 14:52:54 -04008295static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008296 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008297 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008298 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008299 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008300 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8301 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8302 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8303 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8304 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8305 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
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, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008311 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008312 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008313 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008314};
Kailang Yangccc656c2006-10-17 12:32:26 +02008315
Sasha Alexandrc2592492009-06-16 14:52:54 -04008316static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008317 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008318 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008319 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008320 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008321 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8322 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8323 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008324 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008325 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008326 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8327 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8328 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008329 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008330};
Kailang Yangccc656c2006-10-17 12:32:26 +02008331
Takashi Iwaib99dba32009-09-17 18:23:00 +02008332static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8333 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8334 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8335 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8336 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8337 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8338 { } /* end */
8339};
8340
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008341static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8342 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8343 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008344 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8345 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008346 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8347 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8348 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8349 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008350 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008351};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008352
Kailang Yang272a5272007-05-14 11:00:38 +02008353static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8354 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8355 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8356 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8357 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8358 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8359 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8360 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8361 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8362 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008363 { } /* end */
8364};
8365
8366static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8367 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8368 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8369 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8370 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8371 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8372 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8373 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8374 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8375 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008376 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008377};
Kailang Yang272a5272007-05-14 11:00:38 +02008378
Tobin Davis2880a862007-08-07 11:50:26 +02008379static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008380 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8381 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008382 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008383 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8384 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008385 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8386 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8387 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008388 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008389};
Tobin Davis2880a862007-08-07 11:50:26 +02008390
Tony Vroond2fd4b02009-06-21 00:40:10 +01008391static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8392 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8393 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8394 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8395 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008396 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8397 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008398 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8399 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8400 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8401 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8402 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8403 { } /* end */
8404};
8405
Kailang Yange2757d52008-08-26 13:17:46 +02008406static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8407 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8408 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8409 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8410 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8411 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8412 0x0d, 1, 0x0, HDA_OUTPUT),
8413 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8414 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8415 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8416 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8417 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008418 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8419 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8420 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8421 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8422 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8423 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8424 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8425 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8426 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8427 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008428 { } /* end */
8429};
8430
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008431static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8432 /* Output mixers */
8433 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8434 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8435 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8436 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8437 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8438 HDA_OUTPUT),
8439 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8440 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8441 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8442 /* Output switches */
8443 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8444 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8445 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8446 /* Boost mixers */
8447 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8448 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8449 /* Input mixers */
8450 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8451 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8452 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8453 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8454 { } /* end */
8455};
8456
Guido Günther3e1647c2009-06-05 00:47:26 +02008457static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8458 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8459 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8460 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8461 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8462 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8463 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8464 { } /* end */
8465};
8466
Kailang Yange2757d52008-08-26 13:17:46 +02008467static struct hda_bind_ctls alc883_bind_cap_vol = {
8468 .ops = &snd_hda_bind_vol,
8469 .values = {
8470 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8471 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8472 0
8473 },
8474};
8475
8476static struct hda_bind_ctls alc883_bind_cap_switch = {
8477 .ops = &snd_hda_bind_sw,
8478 .values = {
8479 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8480 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8481 0
8482 },
8483};
8484
8485static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8486 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8487 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8488 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8489 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8490 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8491 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8492 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8493 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008494 { } /* end */
8495};
8496
8497static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008498 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8499 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8500 {
8501 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8502 /* .name = "Capture Source", */
8503 .name = "Input Source",
8504 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008505 .info = alc_mux_enum_info,
8506 .get = alc_mux_enum_get,
8507 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008508 },
8509 { } /* end */
8510};
8511
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008512static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8513 {
8514 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8515 .name = "Channel Mode",
8516 .info = alc_ch_mode_info,
8517 .get = alc_ch_mode_get,
8518 .put = alc_ch_mode_put,
8519 },
8520 { } /* end */
8521};
8522
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008523/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008524static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008525{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008526 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008527
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008528 spec->autocfg.hp_pins[0] = 0x15;
8529 spec->autocfg.speaker_pins[0] = 0x14;
8530 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008531}
8532
8533/* auto-toggle front mic */
8534/*
8535static void alc883_mitac_mic_automute(struct hda_codec *codec)
8536{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008537 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008538
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008539 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8540}
8541*/
8542
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008543static struct hda_verb alc883_mitac_verbs[] = {
8544 /* HP */
8545 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8546 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8547 /* Subwoofer */
8548 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8549 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8550
8551 /* enable unsolicited event */
8552 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8553 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8554
8555 { } /* end */
8556};
8557
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308558static struct hda_verb alc883_clevo_m540r_verbs[] = {
8559 /* HP */
8560 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8561 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8562 /* Int speaker */
8563 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8564
8565 /* enable unsolicited event */
8566 /*
8567 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8568 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8569 */
8570
8571 { } /* end */
8572};
8573
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008574static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008575 /* HP */
8576 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8577 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8578 /* Int speaker */
8579 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8580 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8581
8582 /* enable unsolicited event */
8583 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008584 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008585
8586 { } /* end */
8587};
8588
Jiang zhefb97dc62008-03-06 11:07:11 +01008589static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8590 /* HP */
8591 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8592 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8593 /* Subwoofer */
8594 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8595 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8596
8597 /* enable unsolicited event */
8598 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8599
8600 { } /* end */
8601};
8602
Sasha Alexandrc2592492009-06-16 14:52:54 -04008603static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008604 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8605 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8606
8607 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8608 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008609
David Heidelberger64a8be72009-06-08 16:15:18 +02008610/* Connect Line-Out side jack (SPDIF) to Side */
8611 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8612 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8613 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8614/* Connect Mic jack to CLFE */
8615 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8616 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8617 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8618/* Connect Line-in jack to Surround */
8619 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8620 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8621 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8622/* Connect HP out jack to Front */
8623 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8624 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8625 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008626
8627 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008628
8629 { } /* end */
8630};
8631
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008632static struct hda_verb alc883_lenovo_101e_verbs[] = {
8633 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8634 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8635 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8636 { } /* end */
8637};
8638
Kailang Yang272a5272007-05-14 11:00:38 +02008639static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8640 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8641 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8642 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8644 { } /* end */
8645};
8646
8647static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8648 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8649 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8650 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8651 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8652 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8653 { } /* end */
8654};
8655
Kailang Yang189609a2007-08-20 11:31:23 +02008656static struct hda_verb alc883_haier_w66_verbs[] = {
8657 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8658 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8659
8660 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8661
8662 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8663 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8664 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8665 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8666 { } /* end */
8667};
8668
Kailang Yange2757d52008-08-26 13:17:46 +02008669static struct hda_verb alc888_lenovo_sky_verbs[] = {
8670 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8671 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8672 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8673 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8674 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8675 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8676 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8677 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8678 { } /* end */
8679};
8680
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008681static struct hda_verb alc888_6st_dell_verbs[] = {
8682 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8683 { }
8684};
8685
Guido Günther3e1647c2009-06-05 00:47:26 +02008686static struct hda_verb alc883_vaiott_verbs[] = {
8687 /* HP */
8688 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8689 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8690
8691 /* enable unsolicited event */
8692 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8693
8694 { } /* end */
8695};
8696
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008697static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008698{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008699 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008700
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008701 spec->autocfg.hp_pins[0] = 0x1b;
8702 spec->autocfg.speaker_pins[0] = 0x14;
8703 spec->autocfg.speaker_pins[1] = 0x16;
8704 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008705}
8706
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008707static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008708 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008709 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8710 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008711 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008712 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008713};
8714
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008715/*
8716 * 2ch mode
8717 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008718static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008719 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8720 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8721 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8722 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008723 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008724};
8725
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008726/*
8727 * 4ch mode
8728 */
8729static struct hda_verb alc888_3st_hp_4ch_init[] = {
8730 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8731 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8732 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8733 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8734 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8735 { } /* end */
8736};
8737
8738/*
8739 * 6ch mode
8740 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008741static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008742 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8743 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008744 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008745 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8746 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008747 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8748 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008749};
8750
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008751static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008752 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008753 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008754 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008755};
8756
Kailang Yang272a5272007-05-14 11:00:38 +02008757/* toggle front-jack and RCA according to the hp-jack state */
8758static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8759{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008760 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008761
Takashi Iwai47fd8302007-08-10 17:11:07 +02008762 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8763 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8764 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8765 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008766}
8767
8768/* toggle RCA according to the front-jack state */
8769static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8770{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008771 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02008772
Takashi Iwai47fd8302007-08-10 17:11:07 +02008773 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8774 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008775}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008776
Kailang Yang272a5272007-05-14 11:00:38 +02008777static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8778 unsigned int res)
8779{
8780 if ((res >> 26) == ALC880_HP_EVENT)
8781 alc888_lenovo_ms7195_front_automute(codec);
8782 if ((res >> 26) == ALC880_FRONT_EVENT)
8783 alc888_lenovo_ms7195_rca_automute(codec);
8784}
8785
8786static struct hda_verb alc883_medion_md2_verbs[] = {
8787 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8788 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8789
8790 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8791
8792 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8793 { } /* end */
8794};
8795
8796/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008797static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008798{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008799 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008800
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008801 spec->autocfg.hp_pins[0] = 0x14;
8802 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008803}
8804
Kailang Yangccc656c2006-10-17 12:32:26 +02008805/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008806#define alc883_targa_init_hook alc882_targa_init_hook
8807#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008808
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008809static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8810{
8811 unsigned int present;
8812
Takashi Iwaid56757a2009-11-18 08:00:14 +01008813 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008814 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8815 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8816}
8817
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008818static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008819{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008820 struct alc_spec *spec = codec->spec;
8821
8822 spec->autocfg.hp_pins[0] = 0x15;
8823 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008824}
8825
8826static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8827{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008828 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008829 alc883_clevo_m720_mic_automute(codec);
8830}
8831
8832static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008833 unsigned int res)
8834{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008835 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008836 case ALC880_MIC_EVENT:
8837 alc883_clevo_m720_mic_automute(codec);
8838 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008839 default:
8840 alc_automute_amp_unsol_event(codec, res);
8841 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008842 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008843}
8844
Jiang zhefb97dc62008-03-06 11:07:11 +01008845/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008846static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008847{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008848 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008849
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008850 spec->autocfg.hp_pins[0] = 0x14;
8851 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008852}
8853
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008854static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008855{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008856 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008857
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008858 spec->autocfg.hp_pins[0] = 0x1b;
8859 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008860}
8861
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008862static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8863{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008864 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008865
Takashi Iwai47fd8302007-08-10 17:11:07 +02008866 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8867 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008868}
8869
8870static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8871{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008872 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008873
Takashi Iwai47fd8302007-08-10 17:11:07 +02008874 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8875 HDA_AMP_MUTE, bits);
8876 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8877 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008878}
8879
8880static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8881 unsigned int res)
8882{
8883 if ((res >> 26) == ALC880_HP_EVENT)
8884 alc883_lenovo_101e_all_automute(codec);
8885 if ((res >> 26) == ALC880_FRONT_EVENT)
8886 alc883_lenovo_101e_ispeaker_automute(codec);
8887}
8888
Takashi Iwai676a9b52007-08-16 15:23:35 +02008889/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008890static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008891{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008892 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008893
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008894 spec->autocfg.hp_pins[0] = 0x14;
8895 spec->autocfg.speaker_pins[0] = 0x15;
8896 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008897}
8898
Kailang Yangd1a991a2007-08-15 16:21:59 +02008899static struct hda_verb alc883_acer_eapd_verbs[] = {
8900 /* HP Pin: output 0 (0x0c) */
8901 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8902 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8903 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8904 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008905 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8906 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008907 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008908 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8909 /* eanable EAPD on medion laptop */
8910 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8911 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008912 /* enable unsolicited event */
8913 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008914 { }
8915};
8916
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008917static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8918 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8919 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8920 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8921 { } /* end */
8922};
8923
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008924static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008925{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008926 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008927
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008928 spec->autocfg.hp_pins[0] = 0x1b;
8929 spec->autocfg.speaker_pins[0] = 0x14;
8930 spec->autocfg.speaker_pins[1] = 0x15;
8931 spec->autocfg.speaker_pins[2] = 0x16;
8932 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008933}
8934
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008935static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008936{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008937 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008938
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008939 spec->autocfg.hp_pins[0] = 0x1b;
8940 spec->autocfg.speaker_pins[0] = 0x14;
8941 spec->autocfg.speaker_pins[1] = 0x15;
8942 spec->autocfg.speaker_pins[2] = 0x16;
8943 spec->autocfg.speaker_pins[3] = 0x17;
8944 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008945}
8946
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008947static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02008948{
8949 struct alc_spec *spec = codec->spec;
8950
8951 spec->autocfg.hp_pins[0] = 0x15;
8952 spec->autocfg.speaker_pins[0] = 0x14;
8953 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02008954}
8955
Kailang Yange2757d52008-08-26 13:17:46 +02008956static struct hda_verb alc888_asus_m90v_verbs[] = {
8957 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8958 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8959 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8960 /* enable unsolicited event */
8961 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8962 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8963 { } /* end */
8964};
8965
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008966static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008967{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008968 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008969
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008970 spec->autocfg.hp_pins[0] = 0x1b;
8971 spec->autocfg.speaker_pins[0] = 0x14;
8972 spec->autocfg.speaker_pins[1] = 0x15;
8973 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008974 spec->ext_mic.pin = 0x18;
8975 spec->int_mic.pin = 0x19;
8976 spec->ext_mic.mux_idx = 0;
8977 spec->int_mic.mux_idx = 1;
8978 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008979}
8980
8981static struct hda_verb alc888_asus_eee1601_verbs[] = {
8982 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8983 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8984 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8985 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8986 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8987 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8988 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8989 /* enable unsolicited event */
8990 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8991 { } /* end */
8992};
8993
Kailang Yange2757d52008-08-26 13:17:46 +02008994static void alc883_eee1601_inithook(struct hda_codec *codec)
8995{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008996 struct alc_spec *spec = codec->spec;
8997
8998 spec->autocfg.hp_pins[0] = 0x14;
8999 spec->autocfg.speaker_pins[0] = 0x1b;
9000 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009001}
9002
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009003static struct hda_verb alc889A_mb31_verbs[] = {
9004 /* Init rear pin (used as headphone output) */
9005 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9006 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9007 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9008 /* Init line pin (used as output in 4ch and 6ch mode) */
9009 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9010 /* Init line 2 pin (used as headphone out by default) */
9011 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9012 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9013 { } /* end */
9014};
9015
9016/* Mute speakers according to the headphone jack state */
9017static void alc889A_mb31_automute(struct hda_codec *codec)
9018{
9019 unsigned int present;
9020
9021 /* Mute only in 2ch or 4ch mode */
9022 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9023 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009024 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009025 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9026 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9027 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9028 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9029 }
9030}
9031
9032static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9033{
9034 if ((res >> 26) == ALC880_HP_EVENT)
9035 alc889A_mb31_automute(codec);
9036}
9037
Takashi Iwai4953550a2009-06-30 15:28:30 +02009038
Takashi Iwaicb53c622007-08-10 17:21:45 +02009039#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009040#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009041#endif
9042
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009043/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009044#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9045#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9046#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9047#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9048
9049static hda_nid_t alc883_slave_dig_outs[] = {
9050 ALC1200_DIGOUT_NID, 0,
9051};
9052
9053static hda_nid_t alc1200_slave_dig_outs[] = {
9054 ALC883_DIGOUT_NID, 0,
9055};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009056
9057/*
9058 * configuration and preset
9059 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009060static const char *alc882_models[ALC882_MODEL_LAST] = {
9061 [ALC882_3ST_DIG] = "3stack-dig",
9062 [ALC882_6ST_DIG] = "6stack-dig",
9063 [ALC882_ARIMA] = "arima",
9064 [ALC882_W2JC] = "w2jc",
9065 [ALC882_TARGA] = "targa",
9066 [ALC882_ASUS_A7J] = "asus-a7j",
9067 [ALC882_ASUS_A7M] = "asus-a7m",
9068 [ALC885_MACPRO] = "macpro",
9069 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009070 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009071 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009072 [ALC885_MBP3] = "mbp3",
9073 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009074 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009075 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009076 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9077 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009078 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009079 [ALC883_TARGA_DIG] = "targa-dig",
9080 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009081 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009082 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009083 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009084 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009085 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009086 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009087 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009088 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009089 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009090 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009091 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009092 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9093 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009094 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009095 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009096 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009097 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009098 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309099 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009100 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009101 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009102 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009103 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009104 [ALC889A_INTEL] = "intel-alc889a",
9105 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009106 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009107 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009108 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009109 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009110};
9111
Takashi Iwai4953550a2009-06-30 15:28:30 +02009112static struct snd_pci_quirk alc882_cfg_tbl[] = {
9113 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9114
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009115 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009116 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009117 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009118 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9119 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009120 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009121 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9122 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009123 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009124 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009125 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9126 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009127 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9128 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009129 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9130 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009131 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009132 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009133 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009134 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009135 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9136 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009137 /* default Acer -- disabled as it causes more problems.
9138 * model=auto should work fine now
9139 */
9140 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009141
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009142 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009143
Tobin Davisfebe3372007-06-12 11:27:46 +02009144 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009145 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9146 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009147 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009148 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009149 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009150
9151 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9152 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9153 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009154 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009155 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9156 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9157 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009158 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009159 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009160 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009161 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009162
9163 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009164 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009165 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009166 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009167 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9168 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009169 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009170 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009171 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9172
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009173 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9174 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9175 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009176 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009177 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009178 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009179 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009180 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009181 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9182 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9183 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9184 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9185 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9186 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009187 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009188 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9189 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9190 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009191 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009192 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9193 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009194 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009195 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009196 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009197 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009198 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009199 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009200 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009201 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009202
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009203 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009204 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9205 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309206 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009207 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009208 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009209 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009210 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009211 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009212 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009213 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009214 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009215 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009216 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009217 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9218 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009219 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009220 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009221 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009222 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009223 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009224
Jiang zhe17bba1b2008-06-04 12:11:07 +02009225 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9226 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009227 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009228 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9229 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9230 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009231 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009232
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009233 {}
9234};
9235
Takashi Iwai4953550a2009-06-30 15:28:30 +02009236/* codec SSID table for Intel Mac */
9237static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9238 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9239 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9240 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9241 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9242 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9243 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9244 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
9245 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9246 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9247 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009248 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009249 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009250 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9251 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009252 */
9253 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009254 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009255 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009256 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009257};
9258
Takashi Iwai4953550a2009-06-30 15:28:30 +02009259static struct alc_config_preset alc882_presets[] = {
9260 [ALC882_3ST_DIG] = {
9261 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009262 .init_verbs = { alc882_base_init_verbs,
9263 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009264 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9265 .dac_nids = alc882_dac_nids,
9266 .dig_out_nid = ALC882_DIGOUT_NID,
9267 .dig_in_nid = ALC882_DIGIN_NID,
9268 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9269 .channel_mode = alc882_ch_modes,
9270 .need_dac_fix = 1,
9271 .input_mux = &alc882_capture_source,
9272 },
9273 [ALC882_6ST_DIG] = {
9274 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009275 .init_verbs = { alc882_base_init_verbs,
9276 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009277 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9278 .dac_nids = alc882_dac_nids,
9279 .dig_out_nid = ALC882_DIGOUT_NID,
9280 .dig_in_nid = ALC882_DIGIN_NID,
9281 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9282 .channel_mode = alc882_sixstack_modes,
9283 .input_mux = &alc882_capture_source,
9284 },
9285 [ALC882_ARIMA] = {
9286 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009287 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9288 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009289 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9290 .dac_nids = alc882_dac_nids,
9291 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9292 .channel_mode = alc882_sixstack_modes,
9293 .input_mux = &alc882_capture_source,
9294 },
9295 [ALC882_W2JC] = {
9296 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009297 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9298 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009299 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9300 .dac_nids = alc882_dac_nids,
9301 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9302 .channel_mode = alc880_threestack_modes,
9303 .need_dac_fix = 1,
9304 .input_mux = &alc882_capture_source,
9305 .dig_out_nid = ALC882_DIGOUT_NID,
9306 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009307 [ALC885_MBA21] = {
9308 .mixers = { alc885_mba21_mixer },
9309 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9310 .num_dacs = 2,
9311 .dac_nids = alc882_dac_nids,
9312 .channel_mode = alc885_mba21_ch_modes,
9313 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9314 .input_mux = &alc882_capture_source,
9315 .unsol_event = alc_automute_amp_unsol_event,
9316 .setup = alc885_mba21_setup,
9317 .init_hook = alc_automute_amp,
9318 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009319 [ALC885_MBP3] = {
9320 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9321 .init_verbs = { alc885_mbp3_init_verbs,
9322 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009323 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009324 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009325 .hp_nid = 0x04,
9326 .channel_mode = alc885_mbp_4ch_modes,
9327 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009328 .input_mux = &alc882_capture_source,
9329 .dig_out_nid = ALC882_DIGOUT_NID,
9330 .dig_in_nid = ALC882_DIGIN_NID,
9331 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009332 .setup = alc885_mbp3_setup,
9333 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009334 },
9335 [ALC885_MB5] = {
9336 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9337 .init_verbs = { alc885_mb5_init_verbs,
9338 alc880_gpio1_init_verbs },
9339 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9340 .dac_nids = alc882_dac_nids,
9341 .channel_mode = alc885_mb5_6ch_modes,
9342 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9343 .input_mux = &mb5_capture_source,
9344 .dig_out_nid = ALC882_DIGOUT_NID,
9345 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009346 .unsol_event = alc_automute_amp_unsol_event,
9347 .setup = alc885_mb5_setup,
9348 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009349 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009350 [ALC885_MACMINI3] = {
9351 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9352 .init_verbs = { alc885_macmini3_init_verbs,
9353 alc880_gpio1_init_verbs },
9354 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9355 .dac_nids = alc882_dac_nids,
9356 .channel_mode = alc885_macmini3_6ch_modes,
9357 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9358 .input_mux = &macmini3_capture_source,
9359 .dig_out_nid = ALC882_DIGOUT_NID,
9360 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009361 .unsol_event = alc_automute_amp_unsol_event,
9362 .setup = alc885_macmini3_setup,
9363 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009364 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009365 [ALC885_MACPRO] = {
9366 .mixers = { alc882_macpro_mixer },
9367 .init_verbs = { alc882_macpro_init_verbs },
9368 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9369 .dac_nids = alc882_dac_nids,
9370 .dig_out_nid = ALC882_DIGOUT_NID,
9371 .dig_in_nid = ALC882_DIGIN_NID,
9372 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9373 .channel_mode = alc882_ch_modes,
9374 .input_mux = &alc882_capture_source,
9375 .init_hook = alc885_macpro_init_hook,
9376 },
9377 [ALC885_IMAC24] = {
9378 .mixers = { alc885_imac24_mixer },
9379 .init_verbs = { alc885_imac24_init_verbs },
9380 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9381 .dac_nids = alc882_dac_nids,
9382 .dig_out_nid = ALC882_DIGOUT_NID,
9383 .dig_in_nid = ALC882_DIGIN_NID,
9384 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9385 .channel_mode = alc882_ch_modes,
9386 .input_mux = &alc882_capture_source,
9387 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009388 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009389 .init_hook = alc885_imac24_init_hook,
9390 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009391 [ALC885_IMAC91] = {
9392 .mixers = { alc885_imac91_mixer, alc882_chmode_mixer },
9393 .init_verbs = { alc885_imac91_init_verbs,
9394 alc880_gpio1_init_verbs },
9395 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9396 .dac_nids = alc882_dac_nids,
9397 .channel_mode = alc885_mbp_4ch_modes,
9398 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
9399 .input_mux = &alc882_capture_source,
9400 .dig_out_nid = ALC882_DIGOUT_NID,
9401 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009402 .unsol_event = alc_automute_amp_unsol_event,
9403 .setup = alc885_imac91_setup,
9404 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009405 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009406 [ALC882_TARGA] = {
9407 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009408 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009409 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009410 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9411 .dac_nids = alc882_dac_nids,
9412 .dig_out_nid = ALC882_DIGOUT_NID,
9413 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9414 .adc_nids = alc882_adc_nids,
9415 .capsrc_nids = alc882_capsrc_nids,
9416 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9417 .channel_mode = alc882_3ST_6ch_modes,
9418 .need_dac_fix = 1,
9419 .input_mux = &alc882_capture_source,
9420 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009421 .setup = alc882_targa_setup,
9422 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009423 },
9424 [ALC882_ASUS_A7J] = {
9425 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009426 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9427 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009428 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9429 .dac_nids = alc882_dac_nids,
9430 .dig_out_nid = ALC882_DIGOUT_NID,
9431 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9432 .adc_nids = alc882_adc_nids,
9433 .capsrc_nids = alc882_capsrc_nids,
9434 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9435 .channel_mode = alc882_3ST_6ch_modes,
9436 .need_dac_fix = 1,
9437 .input_mux = &alc882_capture_source,
9438 },
9439 [ALC882_ASUS_A7M] = {
9440 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009441 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9442 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009443 alc882_asus_a7m_verbs },
9444 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9445 .dac_nids = alc882_dac_nids,
9446 .dig_out_nid = ALC882_DIGOUT_NID,
9447 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9448 .channel_mode = alc880_threestack_modes,
9449 .need_dac_fix = 1,
9450 .input_mux = &alc882_capture_source,
9451 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009452 [ALC883_3ST_2ch_DIG] = {
9453 .mixers = { alc883_3ST_2ch_mixer },
9454 .init_verbs = { alc883_init_verbs },
9455 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9456 .dac_nids = alc883_dac_nids,
9457 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009458 .dig_in_nid = ALC883_DIGIN_NID,
9459 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9460 .channel_mode = alc883_3ST_2ch_modes,
9461 .input_mux = &alc883_capture_source,
9462 },
9463 [ALC883_3ST_6ch_DIG] = {
9464 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9465 .init_verbs = { alc883_init_verbs },
9466 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9467 .dac_nids = alc883_dac_nids,
9468 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009469 .dig_in_nid = ALC883_DIGIN_NID,
9470 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9471 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009472 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009473 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009474 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009475 [ALC883_3ST_6ch] = {
9476 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9477 .init_verbs = { alc883_init_verbs },
9478 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9479 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009480 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9481 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009482 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009483 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009484 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009485 [ALC883_3ST_6ch_INTEL] = {
9486 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9487 .init_verbs = { alc883_init_verbs },
9488 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9489 .dac_nids = alc883_dac_nids,
9490 .dig_out_nid = ALC883_DIGOUT_NID,
9491 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009492 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009493 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9494 .channel_mode = alc883_3ST_6ch_intel_modes,
9495 .need_dac_fix = 1,
9496 .input_mux = &alc883_3stack_6ch_intel,
9497 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009498 [ALC889A_INTEL] = {
9499 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009500 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9501 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009502 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9503 .dac_nids = alc883_dac_nids,
9504 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9505 .adc_nids = alc889_adc_nids,
9506 .dig_out_nid = ALC883_DIGOUT_NID,
9507 .dig_in_nid = ALC883_DIGIN_NID,
9508 .slave_dig_outs = alc883_slave_dig_outs,
9509 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9510 .channel_mode = alc889_8ch_intel_modes,
9511 .capsrc_nids = alc889_capsrc_nids,
9512 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009513 .setup = alc889_automute_setup,
9514 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009515 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009516 .need_dac_fix = 1,
9517 },
9518 [ALC889_INTEL] = {
9519 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9520 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009521 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009522 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9523 .dac_nids = alc883_dac_nids,
9524 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9525 .adc_nids = alc889_adc_nids,
9526 .dig_out_nid = ALC883_DIGOUT_NID,
9527 .dig_in_nid = ALC883_DIGIN_NID,
9528 .slave_dig_outs = alc883_slave_dig_outs,
9529 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9530 .channel_mode = alc889_8ch_intel_modes,
9531 .capsrc_nids = alc889_capsrc_nids,
9532 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009533 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009534 .init_hook = alc889_intel_init_hook,
9535 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009536 .need_dac_fix = 1,
9537 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009538 [ALC883_6ST_DIG] = {
9539 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9540 .init_verbs = { alc883_init_verbs },
9541 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9542 .dac_nids = alc883_dac_nids,
9543 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009544 .dig_in_nid = ALC883_DIGIN_NID,
9545 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9546 .channel_mode = alc883_sixstack_modes,
9547 .input_mux = &alc883_capture_source,
9548 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009549 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009550 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009551 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9552 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009553 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9554 .dac_nids = alc883_dac_nids,
9555 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009556 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9557 .channel_mode = alc883_3ST_6ch_modes,
9558 .need_dac_fix = 1,
9559 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009560 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009561 .setup = alc882_targa_setup,
9562 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009563 },
9564 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009565 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009566 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9567 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009568 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9569 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009570 .adc_nids = alc883_adc_nids_alt,
9571 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009572 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009573 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009574 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9575 .channel_mode = alc883_3ST_2ch_modes,
9576 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009577 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009578 .setup = alc882_targa_setup,
9579 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009580 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009581 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009582 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9583 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009584 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009585 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009586 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9587 .dac_nids = alc883_dac_nids,
9588 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9589 .adc_nids = alc883_adc_nids_rev,
9590 .capsrc_nids = alc883_capsrc_nids_rev,
9591 .dig_out_nid = ALC883_DIGOUT_NID,
9592 .dig_in_nid = ALC883_DIGIN_NID,
9593 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9594 .channel_mode = alc883_4ST_8ch_modes,
9595 .need_dac_fix = 1,
9596 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009597 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009598 .setup = alc882_targa_setup,
9599 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009600 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009601 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009602 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009603 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9604 * and the headphone jack. Turn this on and rely on the
9605 * standard mute methods whenever the user wants to turn
9606 * these outputs off.
9607 */
9608 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9609 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9610 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009611 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9612 .channel_mode = alc883_3ST_2ch_modes,
9613 .input_mux = &alc883_capture_source,
9614 },
Tobin Davis2880a862007-08-07 11:50:26 +02009615 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009616 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009617 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009618 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9619 .dac_nids = alc883_dac_nids,
9620 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009621 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9622 .channel_mode = alc883_3ST_2ch_modes,
9623 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009624 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009625 .setup = alc883_acer_aspire_setup,
9626 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009627 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009628 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009629 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009630 alc883_chmode_mixer },
9631 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9632 alc888_acer_aspire_4930g_verbs },
9633 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9634 .dac_nids = alc883_dac_nids,
9635 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9636 .adc_nids = alc883_adc_nids_rev,
9637 .capsrc_nids = alc883_capsrc_nids_rev,
9638 .dig_out_nid = ALC883_DIGOUT_NID,
9639 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9640 .channel_mode = alc883_3ST_6ch_modes,
9641 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +01009642 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009643 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009644 ARRAY_SIZE(alc888_2_capture_sources),
9645 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009646 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009647 .setup = alc888_acer_aspire_4930g_setup,
9648 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009649 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009650 [ALC888_ACER_ASPIRE_6530G] = {
9651 .mixers = { alc888_acer_aspire_6530_mixer },
9652 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9653 alc888_acer_aspire_6530g_verbs },
9654 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9655 .dac_nids = alc883_dac_nids,
9656 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9657 .adc_nids = alc883_adc_nids_rev,
9658 .capsrc_nids = alc883_capsrc_nids_rev,
9659 .dig_out_nid = ALC883_DIGOUT_NID,
9660 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9661 .channel_mode = alc883_3ST_2ch_modes,
9662 .num_mux_defs =
9663 ARRAY_SIZE(alc888_2_capture_sources),
9664 .input_mux = alc888_acer_aspire_6530_sources,
9665 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009666 .setup = alc888_acer_aspire_6530g_setup,
9667 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009668 },
Hector Martin3b315d72009-06-02 10:54:19 +02009669 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +01009670 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +02009671 alc883_chmode_mixer },
9672 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +01009673 alc889_acer_aspire_8930g_verbs,
9674 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +02009675 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9676 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009677 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9678 .adc_nids = alc889_adc_nids,
9679 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009680 .dig_out_nid = ALC883_DIGOUT_NID,
9681 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9682 .channel_mode = alc883_3ST_6ch_modes,
9683 .need_dac_fix = 1,
9684 .const_channel_count = 6,
9685 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009686 ARRAY_SIZE(alc889_capture_sources),
9687 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009688 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009689 .setup = alc889_acer_aspire_8930g_setup,
9690 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +01009691#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05009692 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +01009693#endif
Hector Martin3b315d72009-06-02 10:54:19 +02009694 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009695 [ALC888_ACER_ASPIRE_7730G] = {
9696 .mixers = { alc883_3ST_6ch_mixer,
9697 alc883_chmode_mixer },
9698 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9699 alc888_acer_aspire_7730G_verbs },
9700 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9701 .dac_nids = alc883_dac_nids,
9702 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9703 .adc_nids = alc883_adc_nids_rev,
9704 .capsrc_nids = alc883_capsrc_nids_rev,
9705 .dig_out_nid = ALC883_DIGOUT_NID,
9706 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9707 .channel_mode = alc883_3ST_6ch_modes,
9708 .need_dac_fix = 1,
9709 .const_channel_count = 6,
9710 .input_mux = &alc883_capture_source,
9711 .unsol_event = alc_automute_amp_unsol_event,
9712 .setup = alc888_acer_aspire_6530g_setup,
9713 .init_hook = alc_automute_amp,
9714 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009715 [ALC883_MEDION] = {
9716 .mixers = { alc883_fivestack_mixer,
9717 alc883_chmode_mixer },
9718 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009719 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009720 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9721 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009722 .adc_nids = alc883_adc_nids_alt,
9723 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009724 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009725 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9726 .channel_mode = alc883_sixstack_modes,
9727 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009728 },
Kailang Yang272a5272007-05-14 11:00:38 +02009729 [ALC883_MEDION_MD2] = {
9730 .mixers = { alc883_medion_md2_mixer},
9731 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9732 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9733 .dac_nids = alc883_dac_nids,
9734 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009735 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9736 .channel_mode = alc883_3ST_2ch_modes,
9737 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009738 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009739 .setup = alc883_medion_md2_setup,
9740 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009741 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009742 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009743 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009744 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9745 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9746 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009747 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9748 .channel_mode = alc883_3ST_2ch_modes,
9749 .input_mux = &alc883_capture_source,
9750 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309751 [ALC883_CLEVO_M540R] = {
9752 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9753 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9754 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9755 .dac_nids = alc883_dac_nids,
9756 .dig_out_nid = ALC883_DIGOUT_NID,
9757 .dig_in_nid = ALC883_DIGIN_NID,
9758 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9759 .channel_mode = alc883_3ST_6ch_clevo_modes,
9760 .need_dac_fix = 1,
9761 .input_mux = &alc883_capture_source,
9762 /* This machine has the hardware HP auto-muting, thus
9763 * we need no software mute via unsol event
9764 */
9765 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009766 [ALC883_CLEVO_M720] = {
9767 .mixers = { alc883_clevo_m720_mixer },
9768 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009769 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9770 .dac_nids = alc883_dac_nids,
9771 .dig_out_nid = ALC883_DIGOUT_NID,
9772 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9773 .channel_mode = alc883_3ST_2ch_modes,
9774 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009775 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009776 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009777 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009778 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009779 [ALC883_LENOVO_101E_2ch] = {
9780 .mixers = { alc883_lenovo_101e_2ch_mixer},
9781 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9782 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9783 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009784 .adc_nids = alc883_adc_nids_alt,
9785 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009786 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009787 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9788 .channel_mode = alc883_3ST_2ch_modes,
9789 .input_mux = &alc883_lenovo_101e_capture_source,
9790 .unsol_event = alc883_lenovo_101e_unsol_event,
9791 .init_hook = alc883_lenovo_101e_all_automute,
9792 },
Kailang Yang272a5272007-05-14 11:00:38 +02009793 [ALC883_LENOVO_NB0763] = {
9794 .mixers = { alc883_lenovo_nb0763_mixer },
9795 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9796 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9797 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009798 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9799 .channel_mode = alc883_3ST_2ch_modes,
9800 .need_dac_fix = 1,
9801 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009802 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009803 .setup = alc883_medion_md2_setup,
9804 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009805 },
9806 [ALC888_LENOVO_MS7195_DIG] = {
9807 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9808 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9809 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9810 .dac_nids = alc883_dac_nids,
9811 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009812 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9813 .channel_mode = alc883_3ST_6ch_modes,
9814 .need_dac_fix = 1,
9815 .input_mux = &alc883_capture_source,
9816 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9817 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009818 },
9819 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009820 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009821 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9822 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9823 .dac_nids = alc883_dac_nids,
9824 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009825 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9826 .channel_mode = alc883_3ST_2ch_modes,
9827 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009828 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009829 .setup = alc883_haier_w66_setup,
9830 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009831 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009832 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009833 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009834 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009835 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9836 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009837 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9838 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009839 .need_dac_fix = 1,
9840 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009841 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009842 .setup = alc888_3st_hp_setup,
9843 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009844 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009845 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009846 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009847 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9848 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9849 .dac_nids = alc883_dac_nids,
9850 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009851 .dig_in_nid = ALC883_DIGIN_NID,
9852 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9853 .channel_mode = alc883_sixstack_modes,
9854 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009855 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009856 .setup = alc888_6st_dell_setup,
9857 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009858 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009859 [ALC883_MITAC] = {
9860 .mixers = { alc883_mitac_mixer },
9861 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9862 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9863 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009864 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9865 .channel_mode = alc883_3ST_2ch_modes,
9866 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009867 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009868 .setup = alc883_mitac_setup,
9869 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009870 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009871 [ALC883_FUJITSU_PI2515] = {
9872 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9873 .init_verbs = { alc883_init_verbs,
9874 alc883_2ch_fujitsu_pi2515_verbs},
9875 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9876 .dac_nids = alc883_dac_nids,
9877 .dig_out_nid = ALC883_DIGOUT_NID,
9878 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9879 .channel_mode = alc883_3ST_2ch_modes,
9880 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009881 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009882 .setup = alc883_2ch_fujitsu_pi2515_setup,
9883 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009884 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009885 [ALC888_FUJITSU_XA3530] = {
9886 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9887 .init_verbs = { alc883_init_verbs,
9888 alc888_fujitsu_xa3530_verbs },
9889 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9890 .dac_nids = alc883_dac_nids,
9891 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9892 .adc_nids = alc883_adc_nids_rev,
9893 .capsrc_nids = alc883_capsrc_nids_rev,
9894 .dig_out_nid = ALC883_DIGOUT_NID,
9895 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9896 .channel_mode = alc888_4ST_8ch_intel_modes,
9897 .num_mux_defs =
9898 ARRAY_SIZE(alc888_2_capture_sources),
9899 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009900 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009901 .setup = alc888_fujitsu_xa3530_setup,
9902 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009903 },
Kailang Yange2757d52008-08-26 13:17:46 +02009904 [ALC888_LENOVO_SKY] = {
9905 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9906 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9907 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9908 .dac_nids = alc883_dac_nids,
9909 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009910 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9911 .channel_mode = alc883_sixstack_modes,
9912 .need_dac_fix = 1,
9913 .input_mux = &alc883_lenovo_sky_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_lenovo_sky_setup,
9916 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009917 },
9918 [ALC888_ASUS_M90V] = {
9919 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9920 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9921 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9922 .dac_nids = alc883_dac_nids,
9923 .dig_out_nid = ALC883_DIGOUT_NID,
9924 .dig_in_nid = ALC883_DIGIN_NID,
9925 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9926 .channel_mode = alc883_3ST_6ch_modes,
9927 .need_dac_fix = 1,
9928 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009929 .unsol_event = alc_sku_unsol_event,
9930 .setup = alc883_mode2_setup,
9931 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009932 },
9933 [ALC888_ASUS_EEE1601] = {
9934 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009935 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009936 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9937 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9938 .dac_nids = alc883_dac_nids,
9939 .dig_out_nid = ALC883_DIGOUT_NID,
9940 .dig_in_nid = ALC883_DIGIN_NID,
9941 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9942 .channel_mode = alc883_3ST_2ch_modes,
9943 .need_dac_fix = 1,
9944 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009945 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009946 .init_hook = alc883_eee1601_inithook,
9947 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009948 [ALC1200_ASUS_P5Q] = {
9949 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9950 .init_verbs = { alc883_init_verbs },
9951 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9952 .dac_nids = alc883_dac_nids,
9953 .dig_out_nid = ALC1200_DIGOUT_NID,
9954 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009955 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009956 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9957 .channel_mode = alc883_sixstack_modes,
9958 .input_mux = &alc883_capture_source,
9959 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009960 [ALC889A_MB31] = {
9961 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9962 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9963 alc880_gpio1_init_verbs },
9964 .adc_nids = alc883_adc_nids,
9965 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009966 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009967 .dac_nids = alc883_dac_nids,
9968 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9969 .channel_mode = alc889A_mb31_6ch_modes,
9970 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9971 .input_mux = &alc889A_mb31_capture_source,
9972 .dig_out_nid = ALC883_DIGOUT_NID,
9973 .unsol_event = alc889A_mb31_unsol_event,
9974 .init_hook = alc889A_mb31_automute,
9975 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009976 [ALC883_SONY_VAIO_TT] = {
9977 .mixers = { alc883_vaiott_mixer },
9978 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9979 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9980 .dac_nids = alc883_dac_nids,
9981 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9982 .channel_mode = alc883_3ST_2ch_modes,
9983 .input_mux = &alc883_capture_source,
9984 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009985 .setup = alc883_vaiott_setup,
9986 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +02009987 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009988};
9989
9990
9991/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009992 * Pin config fixes
9993 */
9994enum {
9995 PINFIX_ABIT_AW9D_MAX
9996};
9997
9998static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9999 { 0x15, 0x01080104 }, /* side */
10000 { 0x16, 0x01011012 }, /* rear */
10001 { 0x17, 0x01016011 }, /* clfe */
10002 { }
10003};
10004
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010005static const struct alc_fixup alc882_fixups[] = {
10006 [PINFIX_ABIT_AW9D_MAX] = {
10007 .pins = alc882_abit_aw9d_pinfix
10008 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010009};
10010
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010011static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +020010012 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10013 {}
10014};
10015
10016/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010017 * BIOS auto configuration
10018 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010019static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10020 const struct auto_pin_cfg *cfg)
10021{
10022 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10023}
10024
Takashi Iwai4953550a2009-06-30 15:28:30 +020010025static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010026 hda_nid_t nid, int pin_type,
10027 int dac_idx)
10028{
10029 /* set as output */
10030 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010031 int idx;
10032
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010033 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010034 if (spec->multiout.dac_nids[dac_idx] == 0x25)
10035 idx = 4;
10036 else
10037 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010038 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
10039
10040}
10041
Takashi Iwai4953550a2009-06-30 15:28:30 +020010042static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010043{
10044 struct alc_spec *spec = codec->spec;
10045 int i;
10046
10047 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010048 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010049 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010050 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010051 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010052 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010053 }
10054}
10055
Takashi Iwai4953550a2009-06-30 15:28:30 +020010056static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010057{
10058 struct alc_spec *spec = codec->spec;
10059 hda_nid_t pin;
10060
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010061 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010062 if (pin) /* connect to front */
10063 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010064 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010065 pin = spec->autocfg.speaker_pins[0];
10066 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010067 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010068}
10069
Takashi Iwai4953550a2009-06-30 15:28:30 +020010070static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010071{
10072 struct alc_spec *spec = codec->spec;
10073 int i;
10074
10075 for (i = 0; i < AUTO_PIN_LAST; i++) {
10076 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010077 if (!nid)
10078 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +020010079 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010080 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10081 snd_hda_codec_write(codec, nid, 0,
10082 AC_VERB_SET_AMP_GAIN_MUTE,
10083 AMP_OUT_MUTE);
10084 }
10085}
10086
10087static void alc882_auto_init_input_src(struct hda_codec *codec)
10088{
10089 struct alc_spec *spec = codec->spec;
10090 int c;
10091
10092 for (c = 0; c < spec->num_adc_nids; c++) {
10093 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10094 hda_nid_t nid = spec->capsrc_nids[c];
10095 unsigned int mux_idx;
10096 const struct hda_input_mux *imux;
10097 int conns, mute, idx, item;
10098
10099 conns = snd_hda_get_connections(codec, nid, conn_list,
10100 ARRAY_SIZE(conn_list));
10101 if (conns < 0)
10102 continue;
10103 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10104 imux = &spec->input_mux[mux_idx];
10105 for (idx = 0; idx < conns; idx++) {
10106 /* if the current connection is the selected one,
10107 * unmute it as default - otherwise mute it
10108 */
10109 mute = AMP_IN_MUTE(idx);
10110 for (item = 0; item < imux->num_items; item++) {
10111 if (imux->items[item].index == idx) {
10112 if (spec->cur_mux[c] == item)
10113 mute = AMP_IN_UNMUTE(idx);
10114 break;
10115 }
10116 }
10117 /* check if we have a selector or mixer
10118 * we could check for the widget type instead, but
10119 * just check for Amp-In presence (in case of mixer
10120 * without amp-in there is something wrong, this
10121 * function shouldn't be used or capsrc nid is wrong)
10122 */
10123 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010124 snd_hda_codec_write(codec, nid, 0,
10125 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010126 mute);
10127 else if (mute != AMP_IN_MUTE(idx))
10128 snd_hda_codec_write(codec, nid, 0,
10129 AC_VERB_SET_CONNECT_SEL,
10130 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010131 }
10132 }
10133}
10134
Takashi Iwai4953550a2009-06-30 15:28:30 +020010135/* add mic boosts if needed */
10136static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010137{
10138 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010139 int err;
10140 hda_nid_t nid;
10141
10142 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
10143 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10144 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10145 "Mic Boost",
10146 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10147 if (err < 0)
10148 return err;
10149 }
10150 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
10151 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10152 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10153 "Front Mic Boost",
10154 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10155 if (err < 0)
10156 return err;
10157 }
10158 return 0;
10159}
10160
10161/* almost identical with ALC880 parser... */
10162static int alc882_parse_auto_config(struct hda_codec *codec)
10163{
10164 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010165 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
10166 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010167
Takashi Iwai05f5f472009-08-25 13:10:18 +020010168 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10169 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010170 if (err < 0)
10171 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010172 if (!spec->autocfg.line_outs)
10173 return 0; /* can't find valid BIOS pin config */
10174
10175 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10176 if (err < 0)
10177 return err;
10178 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10179 if (err < 0)
10180 return err;
10181 err = alc880_auto_create_extra_out(spec,
10182 spec->autocfg.speaker_pins[0],
10183 "Speaker");
10184 if (err < 0)
10185 return err;
10186 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10187 "Headphone");
10188 if (err < 0)
10189 return err;
10190 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10191 if (err < 0)
10192 return err;
10193
10194 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10195
10196 /* check multiple SPDIF-out (for recent codecs) */
10197 for (i = 0; i < spec->autocfg.dig_outs; i++) {
10198 hda_nid_t dig_nid;
10199 err = snd_hda_get_connections(codec,
10200 spec->autocfg.dig_out_pins[i],
10201 &dig_nid, 1);
10202 if (err < 0)
10203 continue;
10204 if (!i)
10205 spec->multiout.dig_out_nid = dig_nid;
10206 else {
10207 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010208 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +020010209 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010210 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010211 }
10212 }
10213 if (spec->autocfg.dig_in_pin)
10214 spec->dig_in_nid = ALC880_DIGIN_NID;
10215
10216 if (spec->kctls.list)
10217 add_mixer(spec, spec->kctls.list);
10218
10219 add_verb(spec, alc883_auto_init_verbs);
10220 /* if ADC 0x07 is available, initialize it, too */
10221 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10222 add_verb(spec, alc882_adc1_init_verbs);
10223
10224 spec->num_mux_defs = 1;
10225 spec->input_mux = &spec->private_imux[0];
10226
10227 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
Takashi Iwai776e1842007-08-29 15:07:11 +020010228
10229 err = alc_auto_add_mic_boost(codec);
10230 if (err < 0)
10231 return err;
10232
Takashi Iwai776e1842007-08-29 15:07:11 +020010233 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010234}
10235
10236/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010237static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010238{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010239 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010240 alc882_auto_init_multi_out(codec);
10241 alc882_auto_init_hp_out(codec);
10242 alc882_auto_init_analog_input(codec);
10243 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010244 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010245 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010246}
10247
Takashi Iwai4953550a2009-06-30 15:28:30 +020010248static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010249{
10250 struct alc_spec *spec;
10251 int err, board_config;
10252
10253 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10254 if (spec == NULL)
10255 return -ENOMEM;
10256
10257 codec->spec = spec;
10258
Takashi Iwai4953550a2009-06-30 15:28:30 +020010259 switch (codec->vendor_id) {
10260 case 0x10ec0882:
10261 case 0x10ec0885:
10262 break;
10263 default:
10264 /* ALC883 and variants */
10265 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10266 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010267 }
10268
Takashi Iwai4953550a2009-06-30 15:28:30 +020010269 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10270 alc882_models,
10271 alc882_cfg_tbl);
10272
10273 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10274 board_config = snd_hda_check_board_codec_sid_config(codec,
10275 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10276
10277 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010278 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010279 codec->chip_name);
10280 board_config = ALC882_AUTO;
10281 }
10282
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010283 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010284
10285 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010286 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010287 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010288 if (err < 0) {
10289 alc_free(codec);
10290 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010291 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010292 printk(KERN_INFO
10293 "hda_codec: Cannot set up configuration "
10294 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010295 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010296 }
10297 }
10298
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010299 err = snd_hda_attach_beep_device(codec, 0x1);
10300 if (err < 0) {
10301 alc_free(codec);
10302 return err;
10303 }
10304
Takashi Iwai4953550a2009-06-30 15:28:30 +020010305 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010306 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010307
Takashi Iwai4953550a2009-06-30 15:28:30 +020010308 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10309 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10310 /* FIXME: setup DAC5 */
10311 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10312 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10313
10314 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10315 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10316
10317 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010318 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010319
10320 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010321 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010322 spec->num_adc_nids = 0;
10323 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010324 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010325 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010326 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010327 hda_nid_t nid = alc882_adc_nids[i];
10328 unsigned int wcap = get_wcaps(codec, nid);
10329 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010330 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010331 if (wcap != AC_WID_AUD_IN)
10332 continue;
10333 spec->private_adc_nids[spec->num_adc_nids] = nid;
10334 err = snd_hda_get_connections(codec, nid, &cap, 1);
10335 if (err < 0)
10336 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010337 err = snd_hda_get_connections(codec, cap, items,
10338 ARRAY_SIZE(items));
10339 if (err < 0)
10340 continue;
10341 for (j = 0; j < imux->num_items; j++)
10342 if (imux->items[j].index >= err)
10343 break;
10344 if (j < imux->num_items)
10345 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010346 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10347 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010348 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010349 spec->adc_nids = spec->private_adc_nids;
10350 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010351 }
10352
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010353 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010010354 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010355
Takashi Iwai2134ea42008-01-10 16:53:55 +010010356 spec->vmaster_nid = 0x0c;
10357
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010358 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010359 if (board_config == ALC882_AUTO)
10360 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010361#ifdef CONFIG_SND_HDA_POWER_SAVE
10362 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010363 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010364#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010365
10366 return 0;
10367}
10368
Takashi Iwai4953550a2009-06-30 15:28:30 +020010369
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010370/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010371 * ALC262 support
10372 */
10373
10374#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10375#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10376
10377#define alc262_dac_nids alc260_dac_nids
10378#define alc262_adc_nids alc882_adc_nids
10379#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010380#define alc262_capsrc_nids alc882_capsrc_nids
10381#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010382
10383#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010384#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010385
Kailang Yang4e555fe2008-08-26 13:05:55 +020010386static hda_nid_t alc262_dmic_adc_nids[1] = {
10387 /* ADC0 */
10388 0x09
10389};
10390
10391static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10392
Kailang Yangdf694da2005-12-05 19:42:22 +010010393static struct snd_kcontrol_new alc262_base_mixer[] = {
10394 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10395 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10396 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10397 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10398 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10399 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10400 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10401 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010402 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010403 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10404 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010405 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010406 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10407 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10408 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10409 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010410 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010411};
10412
Takashi Iwaice875f02008-01-28 18:17:43 +010010413/* update HP, line and mono-out pins according to the master switch */
10414static void alc262_hp_master_update(struct hda_codec *codec)
10415{
10416 struct alc_spec *spec = codec->spec;
10417 int val = spec->master_sw;
10418
10419 /* HP & line-out */
10420 snd_hda_codec_write_cache(codec, 0x1b, 0,
10421 AC_VERB_SET_PIN_WIDGET_CONTROL,
10422 val ? PIN_HP : 0);
10423 snd_hda_codec_write_cache(codec, 0x15, 0,
10424 AC_VERB_SET_PIN_WIDGET_CONTROL,
10425 val ? PIN_HP : 0);
10426 /* mono (speaker) depending on the HP jack sense */
10427 val = val && !spec->jack_present;
10428 snd_hda_codec_write_cache(codec, 0x16, 0,
10429 AC_VERB_SET_PIN_WIDGET_CONTROL,
10430 val ? PIN_OUT : 0);
10431}
10432
10433static void alc262_hp_bpc_automute(struct hda_codec *codec)
10434{
10435 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010436
10437 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010438 alc262_hp_master_update(codec);
10439}
10440
10441static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10442{
10443 if ((res >> 26) != ALC880_HP_EVENT)
10444 return;
10445 alc262_hp_bpc_automute(codec);
10446}
10447
10448static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10449{
10450 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010451
10452 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010453 alc262_hp_master_update(codec);
10454}
10455
10456static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10457 unsigned int res)
10458{
10459 if ((res >> 26) != ALC880_HP_EVENT)
10460 return;
10461 alc262_hp_wildwest_automute(codec);
10462}
10463
Takashi Iwaib72519b2009-05-08 14:31:55 +020010464#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010465
10466static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10467 struct snd_ctl_elem_value *ucontrol)
10468{
10469 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10470 struct alc_spec *spec = codec->spec;
10471 int val = !!*ucontrol->value.integer.value;
10472
10473 if (val == spec->master_sw)
10474 return 0;
10475 spec->master_sw = val;
10476 alc262_hp_master_update(codec);
10477 return 1;
10478}
10479
Takashi Iwaib72519b2009-05-08 14:31:55 +020010480#define ALC262_HP_MASTER_SWITCH \
10481 { \
10482 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10483 .name = "Master Playback Switch", \
10484 .info = snd_ctl_boolean_mono_info, \
10485 .get = alc262_hp_master_sw_get, \
10486 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010487 }, \
10488 { \
10489 .iface = NID_MAPPING, \
10490 .name = "Master Playback Switch", \
10491 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020010492 }
10493
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010494
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010495static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010496 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010497 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10498 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10499 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010500 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10501 HDA_OUTPUT),
10502 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10503 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010504 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10505 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010506 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010507 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10508 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010509 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010510 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10511 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10512 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10513 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010514 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10515 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10516 { } /* end */
10517};
10518
Kailang Yangcd7509a2007-01-26 18:33:17 +010010519static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010520 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010521 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10522 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10523 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10524 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010525 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10526 HDA_OUTPUT),
10527 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10528 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010529 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10530 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010531 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010532 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10533 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10534 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10535 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010536 { } /* end */
10537};
10538
10539static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10540 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10541 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010542 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010543 { } /* end */
10544};
10545
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010546/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010547static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010548{
10549 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010550
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010551 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010010552 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010553}
10554
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010555static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010556 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10557 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010558 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10559 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10560 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10561 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10562 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10563 { } /* end */
10564};
10565
10566static struct hda_verb alc262_hp_t5735_verbs[] = {
10567 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10568 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10569
10570 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10571 { }
10572};
10573
Kailang Yang8c427222008-01-10 13:03:59 +010010574static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010575 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10576 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010577 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10578 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010579 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10580 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10581 { } /* end */
10582};
10583
10584static struct hda_verb alc262_hp_rp5700_verbs[] = {
10585 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10586 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10587 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10588 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10589 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10590 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10591 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10592 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10593 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10594 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10595 {}
10596};
10597
10598static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10599 .num_items = 1,
10600 .items = {
10601 { "Line", 0x1 },
10602 },
10603};
10604
Takashi Iwai42171c12009-05-08 14:11:43 +020010605/* bind hp and internal speaker mute (with plug check) as master switch */
10606static void alc262_hippo_master_update(struct hda_codec *codec)
10607{
10608 struct alc_spec *spec = codec->spec;
10609 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10610 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10611 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10612 unsigned int mute;
10613
10614 /* HP */
10615 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10616 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10617 HDA_AMP_MUTE, mute);
10618 /* mute internal speaker per jack sense */
10619 if (spec->jack_present)
10620 mute = HDA_AMP_MUTE;
10621 if (line_nid)
10622 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10623 HDA_AMP_MUTE, mute);
10624 if (speaker_nid && speaker_nid != line_nid)
10625 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10626 HDA_AMP_MUTE, mute);
10627}
10628
10629#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10630
10631static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10632 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010633{
10634 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010635 struct alc_spec *spec = codec->spec;
10636 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010637
Takashi Iwai42171c12009-05-08 14:11:43 +020010638 if (val == spec->master_sw)
10639 return 0;
10640 spec->master_sw = val;
10641 alc262_hippo_master_update(codec);
10642 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010643}
Takashi Iwai5b319542007-07-26 11:49:22 +020010644
Takashi Iwai42171c12009-05-08 14:11:43 +020010645#define ALC262_HIPPO_MASTER_SWITCH \
10646 { \
10647 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10648 .name = "Master Playback Switch", \
10649 .info = snd_ctl_boolean_mono_info, \
10650 .get = alc262_hippo_master_sw_get, \
10651 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010652 }, \
10653 { \
10654 .iface = NID_MAPPING, \
10655 .name = "Master Playback Switch", \
10656 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
10657 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020010658 }
10659
10660static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10661 ALC262_HIPPO_MASTER_SWITCH,
10662 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10663 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10664 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10665 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10666 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10668 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10669 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10670 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10671 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10672 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10673 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10674 { } /* end */
10675};
10676
10677static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10678 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10679 ALC262_HIPPO_MASTER_SWITCH,
10680 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10681 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10682 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10683 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10684 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10685 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10686 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10687 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10688 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10689 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10690 { } /* end */
10691};
10692
10693/* mute/unmute internal speaker according to the hp jack and mute state */
10694static void alc262_hippo_automute(struct hda_codec *codec)
10695{
10696 struct alc_spec *spec = codec->spec;
10697 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010698
Wu Fengguang864f92b2009-11-18 12:38:02 +080010699 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010700 alc262_hippo_master_update(codec);
10701}
10702
10703static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10704{
10705 if ((res >> 26) != ALC880_HP_EVENT)
10706 return;
10707 alc262_hippo_automute(codec);
10708}
10709
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010710static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010711{
10712 struct alc_spec *spec = codec->spec;
10713
10714 spec->autocfg.hp_pins[0] = 0x15;
10715 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010716}
10717
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010718static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010719{
10720 struct alc_spec *spec = codec->spec;
10721
10722 spec->autocfg.hp_pins[0] = 0x1b;
10723 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010724}
10725
10726
Kailang Yang272a5272007-05-14 11:00:38 +020010727static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010728 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010729 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010730 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10731 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10732 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10733 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10734 { } /* end */
10735};
10736
Kailang Yang83c34212007-07-05 11:43:05 +020010737static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010738 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10739 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010740 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10741 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10742 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10743 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10744 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10745 { } /* end */
10746};
Kailang Yang272a5272007-05-14 11:00:38 +020010747
Tony Vroonba340e82009-02-02 19:01:30 +000010748static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10749 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10750 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10751 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10752 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10753 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10754 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10755 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10756 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10757 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10758 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10759 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10760 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10761 { } /* end */
10762};
10763
10764static struct hda_verb alc262_tyan_verbs[] = {
10765 /* Headphone automute */
10766 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10767 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10768 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10769
10770 /* P11 AUX_IN, white 4-pin connector */
10771 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10772 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10773 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10774 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10775
10776 {}
10777};
10778
10779/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010780static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010781{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010782 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010783
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010784 spec->autocfg.hp_pins[0] = 0x1b;
10785 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010786}
10787
Tony Vroonba340e82009-02-02 19:01:30 +000010788
Kailang Yangdf694da2005-12-05 19:42:22 +010010789#define alc262_capture_mixer alc882_capture_mixer
10790#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10791
10792/*
10793 * generic initialization of ADC, input mixers and output mixers
10794 */
10795static struct hda_verb alc262_init_verbs[] = {
10796 /*
10797 * Unmute ADC0-2 and set the default input to mic-in
10798 */
10799 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10800 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10801 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10802 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10803 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10804 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10805
Takashi Iwaicb53c622007-08-10 17:21:45 +020010806 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010807 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010808 * Note: PASD motherboards uses the Line In 2 as the input for
10809 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010810 */
10811 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010812 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10813 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10814 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10815 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10816 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010817
10818 /*
10819 * Set up output mixers (0x0c - 0x0e)
10820 */
10821 /* set vol=0 to output mixers */
10822 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10823 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10824 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10825 /* set up input amps for analog loopback */
10826 /* Amp Indices: DAC = 0, mixer = 1 */
10827 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10828 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10829 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10830 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10831 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10832 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10833
10834 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10835 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10836 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10837 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10838 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10839 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10840
10841 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10842 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10843 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10844 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10845 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010846
Kailang Yangdf694da2005-12-05 19:42:22 +010010847 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10848 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010849
Kailang Yangdf694da2005-12-05 19:42:22 +010010850 /* FIXME: use matrix-type input source selection */
10851 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10852 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10853 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10854 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10855 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10856 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10857 /* Input mixer2 */
10858 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10859 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10860 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10861 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10862 /* Input mixer3 */
10863 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10864 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10865 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010866 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010867
10868 { }
10869};
10870
Kailang Yang4e555fe2008-08-26 13:05:55 +020010871static struct hda_verb alc262_eapd_verbs[] = {
10872 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10873 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10874 { }
10875};
10876
Kailang Yangccc656c2006-10-17 12:32:26 +020010877static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10878 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10879 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10880 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10881
10882 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10883 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10884 {}
10885};
10886
Kailang Yang272a5272007-05-14 11:00:38 +020010887static struct hda_verb alc262_sony_unsol_verbs[] = {
10888 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10889 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10890 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10891
10892 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10893 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010894 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010895};
10896
Kailang Yang4e555fe2008-08-26 13:05:55 +020010897static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10898 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10899 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10900 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10901 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10902 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010903 { } /* end */
10904};
10905
10906static struct hda_verb alc262_toshiba_s06_verbs[] = {
10907 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10908 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10909 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10910 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10911 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10912 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10913 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10914 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10915 {}
10916};
10917
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010918static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010919{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010920 struct alc_spec *spec = codec->spec;
10921
10922 spec->autocfg.hp_pins[0] = 0x15;
10923 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010924 spec->ext_mic.pin = 0x18;
10925 spec->ext_mic.mux_idx = 0;
10926 spec->int_mic.pin = 0x12;
10927 spec->int_mic.mux_idx = 9;
10928 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010929}
10930
Takashi Iwai834be882006-03-01 14:16:17 +010010931/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010932 * nec model
10933 * 0x15 = headphone
10934 * 0x16 = internal speaker
10935 * 0x18 = external mic
10936 */
10937
10938static struct snd_kcontrol_new alc262_nec_mixer[] = {
10939 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10940 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10941
10942 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10943 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10944 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10945
10946 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10947 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10948 { } /* end */
10949};
10950
10951static struct hda_verb alc262_nec_verbs[] = {
10952 /* Unmute Speaker */
10953 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10954
10955 /* Headphone */
10956 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10957 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10958
10959 /* External mic to headphone */
10960 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10961 /* External mic to speaker */
10962 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10963 {}
10964};
10965
10966/*
Takashi Iwai834be882006-03-01 14:16:17 +010010967 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010968 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10969 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010970 */
10971
10972#define ALC_HP_EVENT 0x37
10973
10974static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10975 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10976 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010977 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10978 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010979 {}
10980};
10981
Jiang zhe0e31daf2008-03-20 12:12:39 +010010982static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10983 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10984 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10985 {}
10986};
10987
Daniel T Chene2595322009-12-19 18:19:02 -050010988static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
10989 /* Front Mic pin: input vref at 50% */
10990 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10991 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10992 {}
10993};
10994
Takashi Iwai834be882006-03-01 14:16:17 +010010995static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010996 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010997 .items = {
10998 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010999 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011000 { "CD", 0x4 },
11001 },
11002};
11003
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011004static struct hda_input_mux alc262_HP_capture_source = {
11005 .num_items = 5,
11006 .items = {
11007 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011008 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011009 { "Line", 0x2 },
11010 { "CD", 0x4 },
11011 { "AUX IN", 0x6 },
11012 },
11013};
11014
zhejiangaccbe492007-08-31 12:36:05 +020011015static struct hda_input_mux alc262_HP_D7000_capture_source = {
11016 .num_items = 4,
11017 .items = {
11018 { "Mic", 0x0 },
11019 { "Front Mic", 0x2 },
11020 { "Line", 0x1 },
11021 { "CD", 0x4 },
11022 },
11023};
11024
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011025/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011026static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11027{
11028 struct alc_spec *spec = codec->spec;
11029 unsigned int mute;
11030
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011031 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011032 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11033 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011034 spec->sense_updated = 1;
11035 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011036 /* unmute internal speaker only if both HPs are unplugged and
11037 * master switch is on
11038 */
11039 if (spec->jack_present)
11040 mute = HDA_AMP_MUTE;
11041 else
Takashi Iwai834be882006-03-01 14:16:17 +010011042 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011043 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11044 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011045}
11046
11047/* unsolicited event for HP jack sensing */
11048static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11049 unsigned int res)
11050{
11051 if ((res >> 26) != ALC_HP_EVENT)
11052 return;
11053 alc262_fujitsu_automute(codec, 1);
11054}
11055
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011056static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11057{
11058 alc262_fujitsu_automute(codec, 1);
11059}
11060
Takashi Iwai834be882006-03-01 14:16:17 +010011061/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011062static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11063 .ops = &snd_hda_bind_vol,
11064 .values = {
11065 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11066 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11067 0
11068 },
11069};
Takashi Iwai834be882006-03-01 14:16:17 +010011070
Jiang zhe0e31daf2008-03-20 12:12:39 +010011071/* mute/unmute internal speaker according to the hp jack and mute state */
11072static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11073{
11074 struct alc_spec *spec = codec->spec;
11075 unsigned int mute;
11076
11077 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011078 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011079 spec->sense_updated = 1;
11080 }
11081 if (spec->jack_present) {
11082 /* mute internal speaker */
11083 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11084 HDA_AMP_MUTE, HDA_AMP_MUTE);
11085 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11086 HDA_AMP_MUTE, HDA_AMP_MUTE);
11087 } else {
11088 /* unmute internal speaker if necessary */
11089 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11090 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11091 HDA_AMP_MUTE, mute);
11092 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11093 HDA_AMP_MUTE, mute);
11094 }
11095}
11096
11097/* unsolicited event for HP jack sensing */
11098static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11099 unsigned int res)
11100{
11101 if ((res >> 26) != ALC_HP_EVENT)
11102 return;
11103 alc262_lenovo_3000_automute(codec, 1);
11104}
11105
Takashi Iwai8de56b72009-07-24 16:51:47 +020011106static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11107 int dir, int idx, long *valp)
11108{
11109 int i, change = 0;
11110
11111 for (i = 0; i < 2; i++, valp++)
11112 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11113 HDA_AMP_MUTE,
11114 *valp ? 0 : HDA_AMP_MUTE);
11115 return change;
11116}
11117
Takashi Iwai834be882006-03-01 14:16:17 +010011118/* bind hp and internal speaker mute (with plug check) */
11119static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11120 struct snd_ctl_elem_value *ucontrol)
11121{
11122 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11123 long *valp = ucontrol->value.integer.value;
11124 int change;
11125
Takashi Iwai8de56b72009-07-24 16:51:47 +020011126 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11127 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011128 if (change)
11129 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011130 return change;
11131}
11132
11133static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011134 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011135 {
11136 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11137 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011138 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011139 .info = snd_hda_mixer_amp_switch_info,
11140 .get = snd_hda_mixer_amp_switch_get,
11141 .put = alc262_fujitsu_master_sw_put,
11142 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11143 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011144 {
11145 .iface = NID_MAPPING,
11146 .name = "Master Playback Switch",
11147 .private_value = 0x1b,
11148 },
Takashi Iwai834be882006-03-01 14:16:17 +010011149 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11150 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11151 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11152 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11153 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011154 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11155 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11156 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011157 { } /* end */
11158};
11159
Jiang zhe0e31daf2008-03-20 12:12:39 +010011160/* bind hp and internal speaker mute (with plug check) */
11161static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11162 struct snd_ctl_elem_value *ucontrol)
11163{
11164 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11165 long *valp = ucontrol->value.integer.value;
11166 int change;
11167
Takashi Iwai8de56b72009-07-24 16:51:47 +020011168 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011169 if (change)
11170 alc262_lenovo_3000_automute(codec, 0);
11171 return change;
11172}
11173
11174static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11175 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11176 {
11177 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11178 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011179 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011180 .info = snd_hda_mixer_amp_switch_info,
11181 .get = snd_hda_mixer_amp_switch_get,
11182 .put = alc262_lenovo_3000_master_sw_put,
11183 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11184 },
11185 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11186 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11187 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11188 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11189 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11190 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11191 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11192 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11193 { } /* end */
11194};
11195
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011196static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11197 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011198 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011199 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11200 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11201 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11202 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11203 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11204 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11205 { } /* end */
11206};
11207
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011208/* additional init verbs for Benq laptops */
11209static struct hda_verb alc262_EAPD_verbs[] = {
11210 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11211 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11212 {}
11213};
11214
Kailang Yang83c34212007-07-05 11:43:05 +020011215static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11216 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11217 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11218
11219 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11220 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11221 {}
11222};
11223
Tobin Davisf651b502007-10-26 12:40:47 +020011224/* Samsung Q1 Ultra Vista model setup */
11225static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011226 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11227 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011228 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11229 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11230 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011231 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011232 { } /* end */
11233};
11234
11235static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011236 /* output mixer */
11237 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11238 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11239 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11240 /* speaker */
11241 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11242 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11243 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11244 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11245 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011246 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011247 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11248 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11249 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11250 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11251 /* internal mic */
11252 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11253 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11254 /* ADC, choose mic */
11255 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11256 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11257 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11258 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11259 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11260 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11261 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11262 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11263 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11264 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011265 {}
11266};
11267
Tobin Davisf651b502007-10-26 12:40:47 +020011268/* mute/unmute internal speaker according to the hp jack and mute state */
11269static void alc262_ultra_automute(struct hda_codec *codec)
11270{
11271 struct alc_spec *spec = codec->spec;
11272 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011273
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011274 mute = 0;
11275 /* auto-mute only when HP is used as HP */
11276 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011277 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011278 if (spec->jack_present)
11279 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011280 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011281 /* mute/unmute internal speaker */
11282 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11283 HDA_AMP_MUTE, mute);
11284 /* mute/unmute HP */
11285 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11286 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011287}
11288
11289/* unsolicited event for HP jack sensing */
11290static void alc262_ultra_unsol_event(struct hda_codec *codec,
11291 unsigned int res)
11292{
11293 if ((res >> 26) != ALC880_HP_EVENT)
11294 return;
11295 alc262_ultra_automute(codec);
11296}
11297
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011298static struct hda_input_mux alc262_ultra_capture_source = {
11299 .num_items = 2,
11300 .items = {
11301 { "Mic", 0x1 },
11302 { "Headphone", 0x7 },
11303 },
11304};
11305
11306static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11307 struct snd_ctl_elem_value *ucontrol)
11308{
11309 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11310 struct alc_spec *spec = codec->spec;
11311 int ret;
11312
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011313 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011314 if (!ret)
11315 return 0;
11316 /* reprogram the HP pin as mic or HP according to the input source */
11317 snd_hda_codec_write_cache(codec, 0x15, 0,
11318 AC_VERB_SET_PIN_WIDGET_CONTROL,
11319 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11320 alc262_ultra_automute(codec); /* mute/unmute HP */
11321 return ret;
11322}
11323
11324static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11325 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11326 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11327 {
11328 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11329 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011330 .info = alc_mux_enum_info,
11331 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011332 .put = alc262_ultra_mux_enum_put,
11333 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011334 {
11335 .iface = NID_MAPPING,
11336 .name = "Capture Source",
11337 .private_value = 0x15,
11338 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011339 { } /* end */
11340};
11341
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011342/* We use two mixers depending on the output pin; 0x16 is a mono output
11343 * and thus it's bound with a different mixer.
11344 * This function returns which mixer amp should be used.
11345 */
11346static int alc262_check_volbit(hda_nid_t nid)
11347{
11348 if (!nid)
11349 return 0;
11350 else if (nid == 0x16)
11351 return 2;
11352 else
11353 return 1;
11354}
11355
11356static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11357 const char *pfx, int *vbits)
11358{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011359 unsigned long val;
11360 int vbit;
11361
11362 vbit = alc262_check_volbit(nid);
11363 if (!vbit)
11364 return 0;
11365 if (*vbits & vbit) /* a volume control for this mixer already there */
11366 return 0;
11367 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011368 if (vbit == 2)
11369 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11370 else
11371 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011372 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011373}
11374
11375static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11376 const char *pfx)
11377{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011378 unsigned long val;
11379
11380 if (!nid)
11381 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011382 if (nid == 0x16)
11383 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11384 else
11385 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011386 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011387}
11388
Kailang Yangdf694da2005-12-05 19:42:22 +010011389/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011390static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11391 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011392{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011393 const char *pfx;
11394 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011395 int err;
11396
11397 spec->multiout.num_dacs = 1; /* only use one dac */
11398 spec->multiout.dac_nids = spec->private_dac_nids;
11399 spec->multiout.dac_nids[0] = 2;
11400
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011401 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11402 pfx = "Master";
11403 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11404 pfx = "Speaker";
11405 else
11406 pfx = "Front";
11407 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11408 if (err < 0)
11409 return err;
11410 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11411 if (err < 0)
11412 return err;
11413 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11414 if (err < 0)
11415 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011416
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011417 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11418 alc262_check_volbit(cfg->speaker_pins[0]) |
11419 alc262_check_volbit(cfg->hp_pins[0]);
11420 if (vbits == 1 || vbits == 2)
11421 pfx = "Master"; /* only one mixer is used */
11422 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11423 pfx = "Speaker";
11424 else
11425 pfx = "Front";
11426 vbits = 0;
11427 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11428 if (err < 0)
11429 return err;
11430 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11431 &vbits);
11432 if (err < 0)
11433 return err;
11434 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11435 &vbits);
11436 if (err < 0)
11437 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011438 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011439}
11440
Takashi Iwai05f5f472009-08-25 13:10:18 +020011441#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011442 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011443
11444/*
11445 * generic initialization of ADC, input mixers and output mixers
11446 */
11447static struct hda_verb alc262_volume_init_verbs[] = {
11448 /*
11449 * Unmute ADC0-2 and set the default input to mic-in
11450 */
11451 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11452 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11453 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11454 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11455 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11456 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11457
Takashi Iwaicb53c622007-08-10 17:21:45 +020011458 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011459 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011460 * Note: PASD motherboards uses the Line In 2 as the input for
11461 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011462 */
11463 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011464 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11465 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11466 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11467 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11468 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011469
11470 /*
11471 * Set up output mixers (0x0c - 0x0f)
11472 */
11473 /* set vol=0 to output mixers */
11474 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11475 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11476 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011477
Kailang Yangdf694da2005-12-05 19:42:22 +010011478 /* set up input amps for analog loopback */
11479 /* Amp Indices: DAC = 0, mixer = 1 */
11480 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11481 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11482 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11483 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11484 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11485 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11486
11487 /* FIXME: use matrix-type input source selection */
11488 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11489 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11490 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11491 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11492 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11493 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11494 /* Input mixer2 */
11495 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11496 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11497 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11498 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11499 /* Input mixer3 */
11500 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11501 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11502 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11503 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11504
11505 { }
11506};
11507
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011508static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11509 /*
11510 * Unmute ADC0-2 and set the default input to mic-in
11511 */
11512 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11513 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11514 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11515 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11516 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11517 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11518
Takashi Iwaicb53c622007-08-10 17:21:45 +020011519 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011520 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011521 * Note: PASD motherboards uses the Line In 2 as the input for
11522 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011523 */
11524 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011525 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11526 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11527 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11529 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11530 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11531 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011532
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011533 /*
11534 * Set up output mixers (0x0c - 0x0e)
11535 */
11536 /* set vol=0 to output mixers */
11537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11538 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11540
11541 /* set up input amps for analog loopback */
11542 /* Amp Indices: DAC = 0, mixer = 1 */
11543 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11544 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11545 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11546 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11547 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11548 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11549
Takashi Iwaice875f02008-01-28 18:17:43 +010011550 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011551 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11552 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11553
11554 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11555 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11556
11557 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11558 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11559
11560 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11561 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11562 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11563 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11564 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11565
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011566 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011567 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11568 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011569 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011570 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11571 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11572
11573
11574 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011575 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11576 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011577 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011578 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11579 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11580 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11581 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11582 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11583 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11584 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11585 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011586 /* Input mixer2 */
11587 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011588 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11589 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11590 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11591 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11592 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11593 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11594 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11595 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011596 /* Input mixer3 */
11597 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011598 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11599 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11600 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11601 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11602 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11603 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11604 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11605 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011606
Takashi Iwaice875f02008-01-28 18:17:43 +010011607 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11608
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011609 { }
11610};
11611
Kailang Yangcd7509a2007-01-26 18:33:17 +010011612static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11613 /*
11614 * Unmute ADC0-2 and set the default input to mic-in
11615 */
11616 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11617 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11618 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11619 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11620 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11621 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11622
Takashi Iwaicb53c622007-08-10 17:21:45 +020011623 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011624 * mixer widget
11625 * Note: PASD motherboards uses the Line In 2 as the input for front
11626 * panel mic (mic 2)
11627 */
11628 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011629 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11630 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11631 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11632 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11633 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11634 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11635 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11636 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011637 /*
11638 * Set up output mixers (0x0c - 0x0e)
11639 */
11640 /* set vol=0 to output mixers */
11641 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11642 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11643 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11644
11645 /* set up input amps for analog loopback */
11646 /* Amp Indices: DAC = 0, mixer = 1 */
11647 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11648 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11649 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11650 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11651 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11652 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11653
11654
11655 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11656 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11657 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11658 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11659 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11660 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11661 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11662
11663 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11664 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11665
11666 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11667 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11668
11669 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11670 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11671 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11672 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11673 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11674 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11675
11676 /* FIXME: use matrix-type input source selection */
11677 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11678 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11679 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11680 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11681 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11682 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11683 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11684 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11685 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11686 /* Input mixer2 */
11687 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11688 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11689 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11690 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11691 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11692 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11693 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11694 /* Input mixer3 */
11695 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11696 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11697 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11698 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11699 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11700 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11701 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11702
Takashi Iwaice875f02008-01-28 18:17:43 +010011703 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11704
Kailang Yangcd7509a2007-01-26 18:33:17 +010011705 { }
11706};
11707
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011708static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11709
11710 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11711 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11712 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11713
11714 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11715 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11716 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11717 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11718
11719 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11720 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11721 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11722 {}
11723};
11724
11725
Takashi Iwaicb53c622007-08-10 17:21:45 +020011726#ifdef CONFIG_SND_HDA_POWER_SAVE
11727#define alc262_loopbacks alc880_loopbacks
11728#endif
11729
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011730/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011731#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11732#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11733#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11734#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11735
11736/*
11737 * BIOS auto configuration
11738 */
11739static int alc262_parse_auto_config(struct hda_codec *codec)
11740{
11741 struct alc_spec *spec = codec->spec;
11742 int err;
11743 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11744
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011745 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11746 alc262_ignore);
11747 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011748 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011749 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011750 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011751 spec->multiout.max_channels = 2;
11752 spec->no_analog = 1;
11753 goto dig_only;
11754 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011755 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011756 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011757 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11758 if (err < 0)
11759 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011760 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011761 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011762 return err;
11763
11764 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11765
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011766 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011767 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011768 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011769 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011770 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011771 if (spec->autocfg.dig_in_pin)
11772 spec->dig_in_nid = ALC262_DIGIN_NID;
11773
Takashi Iwai603c4012008-07-30 15:01:44 +020011774 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011775 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011776
Takashi Iwaid88897e2008-10-31 15:01:37 +010011777 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011778 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011779 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011780
Takashi Iwai776e1842007-08-29 15:07:11 +020011781 err = alc_auto_add_mic_boost(codec);
11782 if (err < 0)
11783 return err;
11784
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011785 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11786
Kailang Yangdf694da2005-12-05 19:42:22 +010011787 return 1;
11788}
11789
11790#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11791#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11792#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011793#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011794
11795
11796/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011797static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011798{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011799 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011800 alc262_auto_init_multi_out(codec);
11801 alc262_auto_init_hp_out(codec);
11802 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011803 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011804 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011805 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011806}
11807
11808/*
11809 * configuration and preset
11810 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011811static const char *alc262_models[ALC262_MODEL_LAST] = {
11812 [ALC262_BASIC] = "basic",
11813 [ALC262_HIPPO] = "hippo",
11814 [ALC262_HIPPO_1] = "hippo_1",
11815 [ALC262_FUJITSU] = "fujitsu",
11816 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011817 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011818 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011819 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011820 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011821 [ALC262_BENQ_T31] = "benq-t31",
11822 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011823 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011824 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011825 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011826 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011827 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011828 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011829 [ALC262_AUTO] = "auto",
11830};
11831
11832static struct snd_pci_quirk alc262_cfg_tbl[] = {
11833 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011834 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011835 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11836 ALC262_HP_BPC),
11837 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11838 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011839 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11840 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011841 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011842 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011843 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011844 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011845 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011846 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011847 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011848 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011849 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11850 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11851 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011852 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11853 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011854 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011855 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011856 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011857 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011858 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011859 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050011860 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010011861 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011862#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010011863 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11864 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011865#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090011866 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011867 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011868 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011869 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011870 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011871 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011872 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11873 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011874 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011875 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011876 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011877 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011878 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011879 {}
11880};
11881
11882static struct alc_config_preset alc262_presets[] = {
11883 [ALC262_BASIC] = {
11884 .mixers = { alc262_base_mixer },
11885 .init_verbs = { alc262_init_verbs },
11886 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11887 .dac_nids = alc262_dac_nids,
11888 .hp_nid = 0x03,
11889 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11890 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011891 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011892 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011893 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011894 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011895 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011896 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11897 .dac_nids = alc262_dac_nids,
11898 .hp_nid = 0x03,
11899 .dig_out_nid = ALC262_DIGOUT_NID,
11900 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11901 .channel_mode = alc262_modes,
11902 .input_mux = &alc262_capture_source,
11903 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011904 .setup = alc262_hippo_setup,
11905 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011906 },
11907 [ALC262_HIPPO_1] = {
11908 .mixers = { alc262_hippo1_mixer },
11909 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11910 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11911 .dac_nids = alc262_dac_nids,
11912 .hp_nid = 0x02,
11913 .dig_out_nid = ALC262_DIGOUT_NID,
11914 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11915 .channel_mode = alc262_modes,
11916 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011917 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011918 .setup = alc262_hippo1_setup,
11919 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011920 },
Takashi Iwai834be882006-03-01 14:16:17 +010011921 [ALC262_FUJITSU] = {
11922 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011923 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11924 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011925 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11926 .dac_nids = alc262_dac_nids,
11927 .hp_nid = 0x03,
11928 .dig_out_nid = ALC262_DIGOUT_NID,
11929 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11930 .channel_mode = alc262_modes,
11931 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011932 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011933 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011934 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011935 [ALC262_HP_BPC] = {
11936 .mixers = { alc262_HP_BPC_mixer },
11937 .init_verbs = { alc262_HP_BPC_init_verbs },
11938 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11939 .dac_nids = alc262_dac_nids,
11940 .hp_nid = 0x03,
11941 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11942 .channel_mode = alc262_modes,
11943 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011944 .unsol_event = alc262_hp_bpc_unsol_event,
11945 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011946 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011947 [ALC262_HP_BPC_D7000_WF] = {
11948 .mixers = { alc262_HP_BPC_WildWest_mixer },
11949 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11950 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11951 .dac_nids = alc262_dac_nids,
11952 .hp_nid = 0x03,
11953 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11954 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011955 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011956 .unsol_event = alc262_hp_wildwest_unsol_event,
11957 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011958 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011959 [ALC262_HP_BPC_D7000_WL] = {
11960 .mixers = { alc262_HP_BPC_WildWest_mixer,
11961 alc262_HP_BPC_WildWest_option_mixer },
11962 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11963 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11964 .dac_nids = alc262_dac_nids,
11965 .hp_nid = 0x03,
11966 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11967 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011968 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011969 .unsol_event = alc262_hp_wildwest_unsol_event,
11970 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011971 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011972 [ALC262_HP_TC_T5735] = {
11973 .mixers = { alc262_hp_t5735_mixer },
11974 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11975 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11976 .dac_nids = alc262_dac_nids,
11977 .hp_nid = 0x03,
11978 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11979 .channel_mode = alc262_modes,
11980 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010011981 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011982 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010011983 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010011984 },
11985 [ALC262_HP_RP5700] = {
11986 .mixers = { alc262_hp_rp5700_mixer },
11987 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11988 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11989 .dac_nids = alc262_dac_nids,
11990 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11991 .channel_mode = alc262_modes,
11992 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011993 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011994 [ALC262_BENQ_ED8] = {
11995 .mixers = { alc262_base_mixer },
11996 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11997 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11998 .dac_nids = alc262_dac_nids,
11999 .hp_nid = 0x03,
12000 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12001 .channel_mode = alc262_modes,
12002 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012003 },
Kailang Yang272a5272007-05-14 11:00:38 +020012004 [ALC262_SONY_ASSAMD] = {
12005 .mixers = { alc262_sony_mixer },
12006 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12007 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12008 .dac_nids = alc262_dac_nids,
12009 .hp_nid = 0x02,
12010 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12011 .channel_mode = alc262_modes,
12012 .input_mux = &alc262_capture_source,
12013 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012014 .setup = alc262_hippo_setup,
12015 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012016 },
12017 [ALC262_BENQ_T31] = {
12018 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012019 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12020 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012021 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12022 .dac_nids = alc262_dac_nids,
12023 .hp_nid = 0x03,
12024 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12025 .channel_mode = alc262_modes,
12026 .input_mux = &alc262_capture_source,
12027 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012028 .setup = alc262_hippo_setup,
12029 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012030 },
Tobin Davisf651b502007-10-26 12:40:47 +020012031 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012032 .mixers = { alc262_ultra_mixer },
12033 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012034 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012035 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12036 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012037 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12038 .channel_mode = alc262_modes,
12039 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012040 .adc_nids = alc262_adc_nids, /* ADC0 */
12041 .capsrc_nids = alc262_capsrc_nids,
12042 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012043 .unsol_event = alc262_ultra_unsol_event,
12044 .init_hook = alc262_ultra_automute,
12045 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012046 [ALC262_LENOVO_3000] = {
12047 .mixers = { alc262_lenovo_3000_mixer },
12048 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012049 alc262_lenovo_3000_unsol_verbs,
12050 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012051 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12052 .dac_nids = alc262_dac_nids,
12053 .hp_nid = 0x03,
12054 .dig_out_nid = ALC262_DIGOUT_NID,
12055 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12056 .channel_mode = alc262_modes,
12057 .input_mux = &alc262_fujitsu_capture_source,
12058 .unsol_event = alc262_lenovo_3000_unsol_event,
12059 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012060 [ALC262_NEC] = {
12061 .mixers = { alc262_nec_mixer },
12062 .init_verbs = { alc262_nec_verbs },
12063 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12064 .dac_nids = alc262_dac_nids,
12065 .hp_nid = 0x03,
12066 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12067 .channel_mode = alc262_modes,
12068 .input_mux = &alc262_capture_source,
12069 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012070 [ALC262_TOSHIBA_S06] = {
12071 .mixers = { alc262_toshiba_s06_mixer },
12072 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12073 alc262_eapd_verbs },
12074 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12075 .capsrc_nids = alc262_dmic_capsrc_nids,
12076 .dac_nids = alc262_dac_nids,
12077 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012078 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012079 .dig_out_nid = ALC262_DIGOUT_NID,
12080 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12081 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012082 .unsol_event = alc_sku_unsol_event,
12083 .setup = alc262_toshiba_s06_setup,
12084 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012085 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012086 [ALC262_TOSHIBA_RX1] = {
12087 .mixers = { alc262_toshiba_rx1_mixer },
12088 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12089 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12090 .dac_nids = alc262_dac_nids,
12091 .hp_nid = 0x03,
12092 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12093 .channel_mode = alc262_modes,
12094 .input_mux = &alc262_capture_source,
12095 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012096 .setup = alc262_hippo_setup,
12097 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012098 },
Tony Vroonba340e82009-02-02 19:01:30 +000012099 [ALC262_TYAN] = {
12100 .mixers = { alc262_tyan_mixer },
12101 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12102 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12103 .dac_nids = alc262_dac_nids,
12104 .hp_nid = 0x02,
12105 .dig_out_nid = ALC262_DIGOUT_NID,
12106 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12107 .channel_mode = alc262_modes,
12108 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012109 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012110 .setup = alc262_tyan_setup,
12111 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012112 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012113};
12114
12115static int patch_alc262(struct hda_codec *codec)
12116{
12117 struct alc_spec *spec;
12118 int board_config;
12119 int err;
12120
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012121 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012122 if (spec == NULL)
12123 return -ENOMEM;
12124
12125 codec->spec = spec;
12126#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012127 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12128 * under-run
12129 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012130 {
12131 int tmp;
12132 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12133 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12134 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12135 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12136 }
12137#endif
12138
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012139 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12140
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012141 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12142 alc262_models,
12143 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012144
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012145 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012146 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12147 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012148 board_config = ALC262_AUTO;
12149 }
12150
12151 if (board_config == ALC262_AUTO) {
12152 /* automatic parse from the BIOS config */
12153 err = alc262_parse_auto_config(codec);
12154 if (err < 0) {
12155 alc_free(codec);
12156 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012157 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012158 printk(KERN_INFO
12159 "hda_codec: Cannot set up configuration "
12160 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012161 board_config = ALC262_BASIC;
12162 }
12163 }
12164
Takashi Iwai07eba612009-02-19 08:06:35 +010012165 if (!spec->no_analog) {
12166 err = snd_hda_attach_beep_device(codec, 0x1);
12167 if (err < 0) {
12168 alc_free(codec);
12169 return err;
12170 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012171 }
12172
Kailang Yangdf694da2005-12-05 19:42:22 +010012173 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012174 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012175
Kailang Yangdf694da2005-12-05 19:42:22 +010012176 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12177 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012178
Kailang Yangdf694da2005-12-05 19:42:22 +010012179 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12180 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12181
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012182 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012183 int i;
12184 /* check whether the digital-mic has to be supported */
12185 for (i = 0; i < spec->input_mux->num_items; i++) {
12186 if (spec->input_mux->items[i].index >= 9)
12187 break;
12188 }
12189 if (i < spec->input_mux->num_items) {
12190 /* use only ADC0 */
12191 spec->adc_nids = alc262_dmic_adc_nids;
12192 spec->num_adc_nids = 1;
12193 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012194 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012195 /* all analog inputs */
12196 /* check whether NID 0x07 is valid */
12197 unsigned int wcap = get_wcaps(codec, 0x07);
12198
12199 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012200 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012201 if (wcap != AC_WID_AUD_IN) {
12202 spec->adc_nids = alc262_adc_nids_alt;
12203 spec->num_adc_nids =
12204 ARRAY_SIZE(alc262_adc_nids_alt);
12205 spec->capsrc_nids = alc262_capsrc_nids_alt;
12206 } else {
12207 spec->adc_nids = alc262_adc_nids;
12208 spec->num_adc_nids =
12209 ARRAY_SIZE(alc262_adc_nids);
12210 spec->capsrc_nids = alc262_capsrc_nids;
12211 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012212 }
12213 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012214 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012215 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010012216 if (!spec->no_analog)
12217 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012218
Takashi Iwai2134ea42008-01-10 16:53:55 +010012219 spec->vmaster_nid = 0x0c;
12220
Kailang Yangdf694da2005-12-05 19:42:22 +010012221 codec->patch_ops = alc_patch_ops;
12222 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012223 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012224#ifdef CONFIG_SND_HDA_POWER_SAVE
12225 if (!spec->loopback.amplist)
12226 spec->loopback.amplist = alc262_loopbacks;
12227#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012228
Kailang Yangdf694da2005-12-05 19:42:22 +010012229 return 0;
12230}
12231
Kailang Yangdf694da2005-12-05 19:42:22 +010012232/*
Kailang Yanga361d842007-06-05 12:30:55 +020012233 * ALC268 channel source setting (2 channel)
12234 */
12235#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12236#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012237
Kailang Yanga361d842007-06-05 12:30:55 +020012238static hda_nid_t alc268_dac_nids[2] = {
12239 /* front, hp */
12240 0x02, 0x03
12241};
12242
12243static hda_nid_t alc268_adc_nids[2] = {
12244 /* ADC0-1 */
12245 0x08, 0x07
12246};
12247
12248static hda_nid_t alc268_adc_nids_alt[1] = {
12249 /* ADC0 */
12250 0x08
12251};
12252
Takashi Iwaie1406342008-02-11 18:32:32 +010012253static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12254
Kailang Yanga361d842007-06-05 12:30:55 +020012255static struct snd_kcontrol_new alc268_base_mixer[] = {
12256 /* output mixer control */
12257 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12258 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12259 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12260 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012261 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12262 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12263 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012264 { }
12265};
12266
Takashi Iwai42171c12009-05-08 14:11:43 +020012267static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12268 /* output mixer control */
12269 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12270 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12271 ALC262_HIPPO_MASTER_SWITCH,
12272 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12273 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12274 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12275 { }
12276};
12277
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012278/* bind Beep switches of both NID 0x0f and 0x10 */
12279static struct hda_bind_ctls alc268_bind_beep_sw = {
12280 .ops = &snd_hda_bind_sw,
12281 .values = {
12282 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12283 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12284 0
12285 },
12286};
12287
12288static struct snd_kcontrol_new alc268_beep_mixer[] = {
12289 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12290 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12291 { }
12292};
12293
Kailang Yangd1a991a2007-08-15 16:21:59 +020012294static struct hda_verb alc268_eapd_verbs[] = {
12295 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12296 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12297 { }
12298};
12299
Takashi Iwaid2738092007-08-16 14:59:45 +020012300/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012301static struct hda_verb alc268_toshiba_verbs[] = {
12302 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12303 { } /* end */
12304};
12305
12306/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012307/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012308static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12309 .ops = &snd_hda_bind_vol,
12310 .values = {
12311 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12312 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12313 0
12314 },
12315};
12316
Takashi Iwai889c4392007-08-23 18:56:52 +020012317/* mute/unmute internal speaker according to the hp jack and mute state */
12318static void alc268_acer_automute(struct hda_codec *codec, int force)
12319{
12320 struct alc_spec *spec = codec->spec;
12321 unsigned int mute;
12322
12323 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012324 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012325 spec->sense_updated = 1;
12326 }
12327 if (spec->jack_present)
12328 mute = HDA_AMP_MUTE; /* mute internal speaker */
12329 else /* unmute internal speaker if necessary */
12330 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12331 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12332 HDA_AMP_MUTE, mute);
12333}
12334
12335
12336/* bind hp and internal speaker mute (with plug check) */
12337static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12338 struct snd_ctl_elem_value *ucontrol)
12339{
12340 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12341 long *valp = ucontrol->value.integer.value;
12342 int change;
12343
Takashi Iwai8de56b72009-07-24 16:51:47 +020012344 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012345 if (change)
12346 alc268_acer_automute(codec, 0);
12347 return change;
12348}
Takashi Iwaid2738092007-08-16 14:59:45 +020012349
Kailang Yang8ef355d2008-08-26 13:10:22 +020012350static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12351 /* output mixer control */
12352 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12353 {
12354 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12355 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012356 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012357 .info = snd_hda_mixer_amp_switch_info,
12358 .get = snd_hda_mixer_amp_switch_get,
12359 .put = alc268_acer_master_sw_put,
12360 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12361 },
12362 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12363 { }
12364};
12365
Takashi Iwaid2738092007-08-16 14:59:45 +020012366static struct snd_kcontrol_new alc268_acer_mixer[] = {
12367 /* output mixer control */
12368 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12369 {
12370 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12371 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012372 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012373 .info = snd_hda_mixer_amp_switch_info,
12374 .get = snd_hda_mixer_amp_switch_get,
12375 .put = alc268_acer_master_sw_put,
12376 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12377 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012378 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12379 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12380 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012381 { }
12382};
12383
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012384static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12385 /* output mixer control */
12386 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12387 {
12388 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12389 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012390 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012391 .info = snd_hda_mixer_amp_switch_info,
12392 .get = snd_hda_mixer_amp_switch_get,
12393 .put = alc268_acer_master_sw_put,
12394 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12395 },
12396 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12397 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12398 { }
12399};
12400
Kailang Yang8ef355d2008-08-26 13:10:22 +020012401static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12402 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12403 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12404 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12405 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12406 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12407 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12408 { }
12409};
12410
Takashi Iwaid2738092007-08-16 14:59:45 +020012411static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012412 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12413 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012414 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12415 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012416 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12417 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012418 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12419 { }
12420};
12421
12422/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012423#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012424#define alc268_toshiba_setup alc262_hippo_setup
12425#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012426
12427static void alc268_acer_unsol_event(struct hda_codec *codec,
12428 unsigned int res)
12429{
Takashi Iwai889c4392007-08-23 18:56:52 +020012430 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012431 return;
12432 alc268_acer_automute(codec, 1);
12433}
12434
Takashi Iwai889c4392007-08-23 18:56:52 +020012435static void alc268_acer_init_hook(struct hda_codec *codec)
12436{
12437 alc268_acer_automute(codec, 1);
12438}
12439
Kailang Yang8ef355d2008-08-26 13:10:22 +020012440/* toggle speaker-output according to the hp-jack state */
12441static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12442{
12443 unsigned int present;
12444 unsigned char bits;
12445
Wu Fengguang864f92b2009-11-18 12:38:02 +080012446 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012447 bits = present ? AMP_IN_MUTE(0) : 0;
12448 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12449 AMP_IN_MUTE(0), bits);
12450 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12451 AMP_IN_MUTE(0), bits);
12452}
12453
Kailang Yang8ef355d2008-08-26 13:10:22 +020012454static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12455 unsigned int res)
12456{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012457 switch (res >> 26) {
12458 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012459 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012460 break;
12461 case ALC880_MIC_EVENT:
12462 alc_mic_automute(codec);
12463 break;
12464 }
12465}
12466
12467static void alc268_acer_lc_setup(struct hda_codec *codec)
12468{
12469 struct alc_spec *spec = codec->spec;
12470 spec->ext_mic.pin = 0x18;
12471 spec->ext_mic.mux_idx = 0;
12472 spec->int_mic.pin = 0x12;
12473 spec->int_mic.mux_idx = 6;
12474 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012475}
12476
12477static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12478{
12479 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012480 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012481}
12482
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012483static struct snd_kcontrol_new alc268_dell_mixer[] = {
12484 /* output mixer control */
12485 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12486 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12487 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12488 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12489 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12490 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12491 { }
12492};
12493
12494static struct hda_verb alc268_dell_verbs[] = {
12495 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12496 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12497 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012498 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012499 { }
12500};
12501
12502/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012503static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012504{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012505 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012506
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012507 spec->autocfg.hp_pins[0] = 0x15;
12508 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012509 spec->ext_mic.pin = 0x18;
12510 spec->ext_mic.mux_idx = 0;
12511 spec->int_mic.pin = 0x19;
12512 spec->int_mic.mux_idx = 1;
12513 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012514}
12515
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012516static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12517 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12518 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12519 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12520 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12521 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12522 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12523 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12524 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12525 { }
12526};
12527
12528static struct hda_verb alc267_quanta_il1_verbs[] = {
12529 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12530 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12531 { }
12532};
12533
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012534static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012535{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012536 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012537 spec->autocfg.hp_pins[0] = 0x15;
12538 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012539 spec->ext_mic.pin = 0x18;
12540 spec->ext_mic.mux_idx = 0;
12541 spec->int_mic.pin = 0x19;
12542 spec->int_mic.mux_idx = 1;
12543 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012544}
12545
Kailang Yanga361d842007-06-05 12:30:55 +020012546/*
12547 * generic initialization of ADC, input mixers and output mixers
12548 */
12549static struct hda_verb alc268_base_init_verbs[] = {
12550 /* Unmute DAC0-1 and set vol = 0 */
12551 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012552 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012553
12554 /*
12555 * Set up output mixers (0x0c - 0x0e)
12556 */
12557 /* set vol=0 to output mixers */
12558 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012559 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12560
12561 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12562 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12563
12564 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12565 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12566 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12567 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12568 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12569 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12570 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12571 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12572
12573 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12574 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12575 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12576 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012577 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012578
12579 /* set PCBEEP vol = 0, mute connections */
12580 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12581 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12582 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012583
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012584 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012585
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012586 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12587 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12588 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12589 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012590
Kailang Yanga361d842007-06-05 12:30:55 +020012591 { }
12592};
12593
12594/*
12595 * generic initialization of ADC, input mixers and output mixers
12596 */
12597static struct hda_verb alc268_volume_init_verbs[] = {
12598 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012599 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12600 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012601
12602 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12603 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12604 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12605 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12606 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12607
Kailang Yanga361d842007-06-05 12:30:55 +020012608 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012609 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12610 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12611
12612 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012613 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012614
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012615 /* set PCBEEP vol = 0, mute connections */
12616 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12617 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12618 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012619
12620 { }
12621};
12622
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012623static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12624 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12625 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12626 { } /* end */
12627};
12628
Kailang Yanga361d842007-06-05 12:30:55 +020012629static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12630 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12631 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012632 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012633 { } /* end */
12634};
12635
12636static struct snd_kcontrol_new alc268_capture_mixer[] = {
12637 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12638 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12639 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12640 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012641 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012642 { } /* end */
12643};
12644
12645static struct hda_input_mux alc268_capture_source = {
12646 .num_items = 4,
12647 .items = {
12648 { "Mic", 0x0 },
12649 { "Front Mic", 0x1 },
12650 { "Line", 0x2 },
12651 { "CD", 0x3 },
12652 },
12653};
12654
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012655static struct hda_input_mux alc268_acer_capture_source = {
12656 .num_items = 3,
12657 .items = {
12658 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012659 { "Internal Mic", 0x1 },
12660 { "Line", 0x2 },
12661 },
12662};
12663
12664static struct hda_input_mux alc268_acer_dmic_capture_source = {
12665 .num_items = 3,
12666 .items = {
12667 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012668 { "Internal Mic", 0x6 },
12669 { "Line", 0x2 },
12670 },
12671};
12672
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012673#ifdef CONFIG_SND_DEBUG
12674static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012675 /* Volume widgets */
12676 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12677 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12678 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12679 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12680 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12681 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12682 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12683 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12684 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12685 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12686 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12687 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12688 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012689 /* The below appears problematic on some hardwares */
12690 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012691 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12692 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12693 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12694 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12695
12696 /* Modes for retasking pin widgets */
12697 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12698 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12699 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12700 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12701
12702 /* Controls for GPIO pins, assuming they are configured as outputs */
12703 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12704 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12705 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12706 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12707
12708 /* Switches to allow the digital SPDIF output pin to be enabled.
12709 * The ALC268 does not have an SPDIF input.
12710 */
12711 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12712
12713 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12714 * this output to turn on an external amplifier.
12715 */
12716 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12717 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12718
12719 { } /* end */
12720};
12721#endif
12722
Kailang Yanga361d842007-06-05 12:30:55 +020012723/* create input playback/capture controls for the given pin */
12724static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12725 const char *ctlname, int idx)
12726{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012727 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012728 int err;
12729
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012730 switch (nid) {
12731 case 0x14:
12732 case 0x16:
12733 dac = 0x02;
12734 break;
12735 case 0x15:
Takashi Iwai4feabef2010-01-19 15:38:44 +010012736 case 0x21:
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012737 dac = 0x03;
12738 break;
12739 default:
12740 return 0;
12741 }
12742 if (spec->multiout.dac_nids[0] != dac &&
12743 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012744 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012745 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012746 HDA_OUTPUT));
12747 if (err < 0)
12748 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012749 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12750 }
12751
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012752 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012753 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020012754 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012755 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012756 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012757 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012758 if (err < 0)
12759 return err;
12760 return 0;
12761}
12762
12763/* add playback controls from the parsed DAC table */
12764static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12765 const struct auto_pin_cfg *cfg)
12766{
12767 hda_nid_t nid;
12768 int err;
12769
Kailang Yanga361d842007-06-05 12:30:55 +020012770 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012771
12772 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012773 if (nid) {
12774 const char *name;
12775 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12776 name = "Speaker";
12777 else
12778 name = "Front";
12779 err = alc268_new_analog_output(spec, nid, name, 0);
12780 if (err < 0)
12781 return err;
12782 }
Kailang Yanga361d842007-06-05 12:30:55 +020012783
12784 nid = cfg->speaker_pins[0];
12785 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012786 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020012787 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12788 if (err < 0)
12789 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012790 } else {
12791 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12792 if (err < 0)
12793 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012794 }
12795 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012796 if (nid) {
12797 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12798 if (err < 0)
12799 return err;
12800 }
Kailang Yanga361d842007-06-05 12:30:55 +020012801
12802 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12803 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012804 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012805 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012806 if (err < 0)
12807 return err;
12808 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012809 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012810}
12811
12812/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012813static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012814 const struct auto_pin_cfg *cfg)
12815{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012816 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012817}
12818
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012819static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12820 hda_nid_t nid, int pin_type)
12821{
12822 int idx;
12823
12824 alc_set_pin_output(codec, nid, pin_type);
12825 if (nid == 0x14 || nid == 0x16)
12826 idx = 0;
12827 else
12828 idx = 1;
12829 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12830}
12831
12832static void alc268_auto_init_multi_out(struct hda_codec *codec)
12833{
12834 struct alc_spec *spec = codec->spec;
12835 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12836 if (nid) {
12837 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12838 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12839 }
12840}
12841
12842static void alc268_auto_init_hp_out(struct hda_codec *codec)
12843{
12844 struct alc_spec *spec = codec->spec;
12845 hda_nid_t pin;
12846
12847 pin = spec->autocfg.hp_pins[0];
12848 if (pin)
12849 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12850 pin = spec->autocfg.speaker_pins[0];
12851 if (pin)
12852 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12853}
12854
Kailang Yanga361d842007-06-05 12:30:55 +020012855static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12856{
12857 struct alc_spec *spec = codec->spec;
12858 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12859 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12860 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12861 unsigned int dac_vol1, dac_vol2;
12862
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012863 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012864 snd_hda_codec_write(codec, speaker_nid, 0,
12865 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012866 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012867 snd_hda_codec_write(codec, 0x0f, 0,
12868 AC_VERB_SET_AMP_GAIN_MUTE,
12869 AMP_IN_UNMUTE(1));
12870 snd_hda_codec_write(codec, 0x10, 0,
12871 AC_VERB_SET_AMP_GAIN_MUTE,
12872 AMP_IN_UNMUTE(1));
12873 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012874 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012875 snd_hda_codec_write(codec, 0x0f, 0,
12876 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12877 snd_hda_codec_write(codec, 0x10, 0,
12878 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12879 }
12880
12881 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012882 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012883 dac_vol2 = AMP_OUT_ZERO;
12884 else if (line_nid == 0x15)
12885 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012886 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012887 dac_vol2 = AMP_OUT_ZERO;
12888 else if (hp_nid == 0x15)
12889 dac_vol1 = AMP_OUT_ZERO;
12890 if (line_nid != 0x16 || hp_nid != 0x16 ||
12891 spec->autocfg.line_out_pins[1] != 0x16 ||
12892 spec->autocfg.line_out_pins[2] != 0x16)
12893 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12894
12895 snd_hda_codec_write(codec, 0x02, 0,
12896 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12897 snd_hda_codec_write(codec, 0x03, 0,
12898 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12899}
12900
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012901/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012902#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12903#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012904#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012905#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12906
12907/*
12908 * BIOS auto configuration
12909 */
12910static int alc268_parse_auto_config(struct hda_codec *codec)
12911{
12912 struct alc_spec *spec = codec->spec;
12913 int err;
12914 static hda_nid_t alc268_ignore[] = { 0 };
12915
12916 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12917 alc268_ignore);
12918 if (err < 0)
12919 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012920 if (!spec->autocfg.line_outs) {
12921 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12922 spec->multiout.max_channels = 2;
12923 spec->no_analog = 1;
12924 goto dig_only;
12925 }
Kailang Yanga361d842007-06-05 12:30:55 +020012926 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012927 }
Kailang Yanga361d842007-06-05 12:30:55 +020012928 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12929 if (err < 0)
12930 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012931 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012932 if (err < 0)
12933 return err;
12934
12935 spec->multiout.max_channels = 2;
12936
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012937 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012938 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012939 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012940 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012941 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12942 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012943 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012944 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012945
Takashi Iwai892981f2009-03-02 08:04:35 +010012946 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012947 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012948
Takashi Iwaid88897e2008-10-31 15:01:37 +010012949 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012950 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012951 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012952
Takashi Iwai776e1842007-08-29 15:07:11 +020012953 err = alc_auto_add_mic_boost(codec);
12954 if (err < 0)
12955 return err;
12956
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012957 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12958
Kailang Yanga361d842007-06-05 12:30:55 +020012959 return 1;
12960}
12961
Kailang Yanga361d842007-06-05 12:30:55 +020012962#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12963
12964/* init callback for auto-configuration model -- overriding the default init */
12965static void alc268_auto_init(struct hda_codec *codec)
12966{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012967 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012968 alc268_auto_init_multi_out(codec);
12969 alc268_auto_init_hp_out(codec);
12970 alc268_auto_init_mono_speaker_out(codec);
12971 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012972 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012973 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012974}
12975
12976/*
12977 * configuration and preset
12978 */
12979static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012980 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012981 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012982 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012983 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012984 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012985 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012986 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012987 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012988#ifdef CONFIG_SND_DEBUG
12989 [ALC268_TEST] = "test",
12990#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012991 [ALC268_AUTO] = "auto",
12992};
12993
12994static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012995 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012996 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012997 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012998 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012999 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013000 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13001 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013002 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013003 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13004 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013005 /* almost compatible with toshiba but with optional digital outs;
13006 * auto-probing seems working fine
13007 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013008 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013009 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013010 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013011 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013012 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013013 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013014 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013015 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020013016 {}
13017};
13018
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013019/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13020static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13021 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13022 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13023 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13024 ALC268_TOSHIBA),
13025 {}
13026};
13027
Kailang Yanga361d842007-06-05 12:30:55 +020013028static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013029 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013030 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13031 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013032 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13033 alc267_quanta_il1_verbs },
13034 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13035 .dac_nids = alc268_dac_nids,
13036 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13037 .adc_nids = alc268_adc_nids_alt,
13038 .hp_nid = 0x03,
13039 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13040 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013041 .unsol_event = alc_sku_unsol_event,
13042 .setup = alc267_quanta_il1_setup,
13043 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013044 },
Kailang Yanga361d842007-06-05 12:30:55 +020013045 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013046 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13047 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013048 .init_verbs = { alc268_base_init_verbs },
13049 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13050 .dac_nids = alc268_dac_nids,
13051 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13052 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013053 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013054 .hp_nid = 0x03,
13055 .dig_out_nid = ALC268_DIGOUT_NID,
13056 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13057 .channel_mode = alc268_modes,
13058 .input_mux = &alc268_capture_source,
13059 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013060 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013061 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013062 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013063 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13064 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013065 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13066 .dac_nids = alc268_dac_nids,
13067 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13068 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013069 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013070 .hp_nid = 0x03,
13071 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13072 .channel_mode = alc268_modes,
13073 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013074 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013075 .setup = alc268_toshiba_setup,
13076 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013077 },
13078 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013079 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013080 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013081 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13082 alc268_acer_verbs },
13083 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13084 .dac_nids = alc268_dac_nids,
13085 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13086 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013087 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013088 .hp_nid = 0x02,
13089 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13090 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013091 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013092 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013093 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013094 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013095 [ALC268_ACER_DMIC] = {
13096 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13097 alc268_beep_mixer },
13098 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13099 alc268_acer_verbs },
13100 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13101 .dac_nids = alc268_dac_nids,
13102 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13103 .adc_nids = alc268_adc_nids_alt,
13104 .capsrc_nids = alc268_capsrc_nids,
13105 .hp_nid = 0x02,
13106 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13107 .channel_mode = alc268_modes,
13108 .input_mux = &alc268_acer_dmic_capture_source,
13109 .unsol_event = alc268_acer_unsol_event,
13110 .init_hook = alc268_acer_init_hook,
13111 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013112 [ALC268_ACER_ASPIRE_ONE] = {
13113 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013114 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013115 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013116 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13117 alc268_acer_aspire_one_verbs },
13118 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13119 .dac_nids = alc268_dac_nids,
13120 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13121 .adc_nids = alc268_adc_nids_alt,
13122 .capsrc_nids = alc268_capsrc_nids,
13123 .hp_nid = 0x03,
13124 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13125 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013126 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013127 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013128 .init_hook = alc268_acer_lc_init_hook,
13129 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013130 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013131 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13132 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013133 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13134 alc268_dell_verbs },
13135 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13136 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013137 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13138 .adc_nids = alc268_adc_nids_alt,
13139 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013140 .hp_nid = 0x02,
13141 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13142 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013143 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013144 .setup = alc268_dell_setup,
13145 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013146 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013147 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013148 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13149 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013150 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13151 alc268_toshiba_verbs },
13152 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13153 .dac_nids = alc268_dac_nids,
13154 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13155 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013156 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013157 .hp_nid = 0x03,
13158 .dig_out_nid = ALC268_DIGOUT_NID,
13159 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13160 .channel_mode = alc268_modes,
13161 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013162 .setup = alc268_toshiba_setup,
13163 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013164 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013165#ifdef CONFIG_SND_DEBUG
13166 [ALC268_TEST] = {
13167 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13168 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13169 alc268_volume_init_verbs },
13170 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13171 .dac_nids = alc268_dac_nids,
13172 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13173 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013174 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013175 .hp_nid = 0x03,
13176 .dig_out_nid = ALC268_DIGOUT_NID,
13177 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13178 .channel_mode = alc268_modes,
13179 .input_mux = &alc268_capture_source,
13180 },
13181#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013182};
13183
13184static int patch_alc268(struct hda_codec *codec)
13185{
13186 struct alc_spec *spec;
13187 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013188 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013189
Julia Lawallef86f582009-12-19 08:18:03 +010013190 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013191 if (spec == NULL)
13192 return -ENOMEM;
13193
13194 codec->spec = spec;
13195
13196 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13197 alc268_models,
13198 alc268_cfg_tbl);
13199
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013200 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13201 board_config = snd_hda_check_board_codec_sid_config(codec,
13202 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
13203
Kailang Yanga361d842007-06-05 12:30:55 +020013204 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013205 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13206 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013207 board_config = ALC268_AUTO;
13208 }
13209
13210 if (board_config == ALC268_AUTO) {
13211 /* automatic parse from the BIOS config */
13212 err = alc268_parse_auto_config(codec);
13213 if (err < 0) {
13214 alc_free(codec);
13215 return err;
13216 } else if (!err) {
13217 printk(KERN_INFO
13218 "hda_codec: Cannot set up configuration "
13219 "from BIOS. Using base mode...\n");
13220 board_config = ALC268_3ST;
13221 }
13222 }
13223
13224 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013225 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013226
Kailang Yanga361d842007-06-05 12:30:55 +020013227 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13228 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013229 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013230
Kailang Yanga361d842007-06-05 12:30:55 +020013231 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13232
Takashi Iwai22971e32009-02-10 11:56:44 +010013233 has_beep = 0;
13234 for (i = 0; i < spec->num_mixers; i++) {
13235 if (spec->mixers[i] == alc268_beep_mixer) {
13236 has_beep = 1;
13237 break;
13238 }
13239 }
13240
13241 if (has_beep) {
13242 err = snd_hda_attach_beep_device(codec, 0x1);
13243 if (err < 0) {
13244 alc_free(codec);
13245 return err;
13246 }
13247 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13248 /* override the amp caps for beep generator */
13249 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013250 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13251 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13252 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13253 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013254 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013255
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013256 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013257 /* check whether NID 0x07 is valid */
13258 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013259 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013260
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013261 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013262 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013263 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013264 if (spec->auto_mic ||
13265 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013266 spec->adc_nids = alc268_adc_nids_alt;
13267 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013268 if (spec->auto_mic)
13269 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013270 if (spec->auto_mic || spec->input_mux->num_items == 1)
13271 add_mixer(spec, alc268_capture_nosrc_mixer);
13272 else
13273 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013274 } else {
13275 spec->adc_nids = alc268_adc_nids;
13276 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013277 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013278 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013279 /* set default input source */
13280 for (i = 0; i < spec->num_adc_nids; i++)
13281 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13282 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013283 i < spec->num_mux_defs ?
13284 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013285 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013286 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013287
13288 spec->vmaster_nid = 0x02;
13289
Kailang Yanga361d842007-06-05 12:30:55 +020013290 codec->patch_ops = alc_patch_ops;
13291 if (board_config == ALC268_AUTO)
13292 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013293
Kailang Yanga361d842007-06-05 12:30:55 +020013294 return 0;
13295}
13296
13297/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013298 * ALC269 channel source setting (2 channel)
13299 */
13300#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13301
13302#define alc269_dac_nids alc260_dac_nids
13303
13304static hda_nid_t alc269_adc_nids[1] = {
13305 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013306 0x08,
13307};
13308
Takashi Iwaie01bf502008-08-21 16:25:07 +020013309static hda_nid_t alc269_capsrc_nids[1] = {
13310 0x23,
13311};
13312
Kailang Yang84898e82010-02-04 14:16:14 +010013313static hda_nid_t alc269vb_adc_nids[1] = {
13314 /* ADC1 */
13315 0x09,
13316};
13317
13318static hda_nid_t alc269vb_capsrc_nids[1] = {
13319 0x22,
13320};
13321
Takashi Iwaie01bf502008-08-21 16:25:07 +020013322/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
13323 * not a mux!
13324 */
13325
Kailang Yangf6a92242007-12-13 16:52:54 +010013326#define alc269_modes alc260_modes
13327#define alc269_capture_source alc880_lg_lw_capture_source
13328
13329static struct snd_kcontrol_new alc269_base_mixer[] = {
13330 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13331 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13332 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13333 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13335 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13336 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13337 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13338 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13339 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13340 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13341 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13342 { } /* end */
13343};
13344
Kailang Yang60db6b52008-08-26 13:13:00 +020013345static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13346 /* output mixer control */
13347 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13348 {
13349 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13350 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013351 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013352 .info = snd_hda_mixer_amp_switch_info,
13353 .get = snd_hda_mixer_amp_switch_get,
13354 .put = alc268_acer_master_sw_put,
13355 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13356 },
13357 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13358 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13359 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13360 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13361 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13362 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013363 { }
13364};
13365
Tony Vroon64154832008-11-06 15:08:49 +000013366static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13367 /* output mixer control */
13368 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13369 {
13370 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13371 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013372 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013373 .info = snd_hda_mixer_amp_switch_info,
13374 .get = snd_hda_mixer_amp_switch_get,
13375 .put = alc268_acer_master_sw_put,
13376 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13377 },
13378 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13379 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13380 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13381 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13382 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13383 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13384 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13385 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13386 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013387 { }
13388};
13389
Kailang Yang84898e82010-02-04 14:16:14 +010013390static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013391 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013392 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013393 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013394 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013395 { } /* end */
13396};
13397
Kailang Yang84898e82010-02-04 14:16:14 +010013398static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
13399 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13400 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13401 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13402 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13403 { } /* end */
13404};
13405
Kailang Yangf6a92242007-12-13 16:52:54 +010013406/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010013407static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
13408 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13409 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13410 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13411 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13412 { } /* end */
13413};
13414
13415static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020013416 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13417 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013418 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13419 { } /* end */
13420};
13421
Kailang Yang84898e82010-02-04 14:16:14 +010013422static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
13423 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13424 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13425 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13426 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13427 { } /* end */
13428};
13429
13430static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
13431 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13432 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13433 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13434 { } /* end */
13435};
13436
Takashi Iwai26f5df22008-11-03 17:39:46 +010013437/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010013438#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013439
Kailang Yang60db6b52008-08-26 13:13:00 +020013440static struct hda_verb alc269_quanta_fl1_verbs[] = {
13441 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13442 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13443 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13444 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13445 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13446 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13447 { }
13448};
13449
Tony Vroon64154832008-11-06 15:08:49 +000013450static struct hda_verb alc269_lifebook_verbs[] = {
13451 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13452 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13453 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13454 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13455 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13456 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13457 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13458 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13459 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13460 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13461 { }
13462};
13463
Kailang Yang60db6b52008-08-26 13:13:00 +020013464/* toggle speaker-output according to the hp-jack state */
13465static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13466{
13467 unsigned int present;
13468 unsigned char bits;
13469
Wu Fengguang864f92b2009-11-18 12:38:02 +080013470 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang60db6b52008-08-26 13:13:00 +020013471 bits = present ? AMP_IN_MUTE(0) : 0;
13472 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13473 AMP_IN_MUTE(0), bits);
13474 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13475 AMP_IN_MUTE(0), bits);
13476
13477 snd_hda_codec_write(codec, 0x20, 0,
13478 AC_VERB_SET_COEF_INDEX, 0x0c);
13479 snd_hda_codec_write(codec, 0x20, 0,
13480 AC_VERB_SET_PROC_COEF, 0x680);
13481
13482 snd_hda_codec_write(codec, 0x20, 0,
13483 AC_VERB_SET_COEF_INDEX, 0x0c);
13484 snd_hda_codec_write(codec, 0x20, 0,
13485 AC_VERB_SET_PROC_COEF, 0x480);
13486}
13487
Tony Vroon64154832008-11-06 15:08:49 +000013488/* toggle speaker-output according to the hp-jacks state */
13489static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13490{
13491 unsigned int present;
13492 unsigned char bits;
13493
13494 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013495 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013496
13497 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013498 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013499
13500 bits = present ? AMP_IN_MUTE(0) : 0;
13501 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13502 AMP_IN_MUTE(0), bits);
13503 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13504 AMP_IN_MUTE(0), bits);
13505
13506 snd_hda_codec_write(codec, 0x20, 0,
13507 AC_VERB_SET_COEF_INDEX, 0x0c);
13508 snd_hda_codec_write(codec, 0x20, 0,
13509 AC_VERB_SET_PROC_COEF, 0x680);
13510
13511 snd_hda_codec_write(codec, 0x20, 0,
13512 AC_VERB_SET_COEF_INDEX, 0x0c);
13513 snd_hda_codec_write(codec, 0x20, 0,
13514 AC_VERB_SET_PROC_COEF, 0x480);
13515}
13516
Tony Vroon64154832008-11-06 15:08:49 +000013517static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13518{
13519 unsigned int present_laptop;
13520 unsigned int present_dock;
13521
Wu Fengguang864f92b2009-11-18 12:38:02 +080013522 present_laptop = snd_hda_jack_detect(codec, 0x18);
13523 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013524
13525 /* Laptop mic port overrides dock mic port, design decision */
13526 if (present_dock)
13527 snd_hda_codec_write(codec, 0x23, 0,
13528 AC_VERB_SET_CONNECT_SEL, 0x3);
13529 if (present_laptop)
13530 snd_hda_codec_write(codec, 0x23, 0,
13531 AC_VERB_SET_CONNECT_SEL, 0x0);
13532 if (!present_dock && !present_laptop)
13533 snd_hda_codec_write(codec, 0x23, 0,
13534 AC_VERB_SET_CONNECT_SEL, 0x1);
13535}
13536
Kailang Yang60db6b52008-08-26 13:13:00 +020013537static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13538 unsigned int res)
13539{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013540 switch (res >> 26) {
13541 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013542 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013543 break;
13544 case ALC880_MIC_EVENT:
13545 alc_mic_automute(codec);
13546 break;
13547 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013548}
13549
Tony Vroon64154832008-11-06 15:08:49 +000013550static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13551 unsigned int res)
13552{
13553 if ((res >> 26) == ALC880_HP_EVENT)
13554 alc269_lifebook_speaker_automute(codec);
13555 if ((res >> 26) == ALC880_MIC_EVENT)
13556 alc269_lifebook_mic_autoswitch(codec);
13557}
13558
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013559static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13560{
13561 struct alc_spec *spec = codec->spec;
13562 spec->ext_mic.pin = 0x18;
13563 spec->ext_mic.mux_idx = 0;
13564 spec->int_mic.pin = 0x19;
13565 spec->int_mic.mux_idx = 1;
13566 spec->auto_mic = 1;
13567}
13568
Kailang Yang60db6b52008-08-26 13:13:00 +020013569static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13570{
13571 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013572 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013573}
13574
Tony Vroon64154832008-11-06 15:08:49 +000013575static void alc269_lifebook_init_hook(struct hda_codec *codec)
13576{
13577 alc269_lifebook_speaker_automute(codec);
13578 alc269_lifebook_mic_autoswitch(codec);
13579}
13580
Kailang Yang84898e82010-02-04 14:16:14 +010013581static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013582 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13583 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13584 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13585 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13586 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13587 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13588 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13589 {}
13590};
13591
Kailang Yang84898e82010-02-04 14:16:14 +010013592static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013593 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13594 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13595 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13596 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13597 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13598 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13599 {}
13600};
13601
Kailang Yang84898e82010-02-04 14:16:14 +010013602static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
13603 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13604 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
13605 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13606 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13607 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13608 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13609 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13610 {}
13611};
13612
13613static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
13614 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13615 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
13616 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13617 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13618 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13619 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13620 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13621 {}
13622};
13623
Kailang Yang60db6b52008-08-26 13:13:00 +020013624/* toggle speaker-output according to the hp-jack state */
13625static void alc269_speaker_automute(struct hda_codec *codec)
13626{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013627 struct alc_spec *spec = codec->spec;
13628 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013629 unsigned int present;
13630 unsigned char bits;
13631
Kailang Yangebb83ee2009-12-17 12:23:00 +010013632 present = snd_hda_jack_detect(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020013633 bits = present ? AMP_IN_MUTE(0) : 0;
13634 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13635 AMP_IN_MUTE(0), bits);
13636 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13637 AMP_IN_MUTE(0), bits);
13638}
13639
Kailang Yang60db6b52008-08-26 13:13:00 +020013640/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010013641static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013642 unsigned int res)
13643{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013644 switch (res >> 26) {
13645 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013646 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013647 break;
13648 case ALC880_MIC_EVENT:
13649 alc_mic_automute(codec);
13650 break;
13651 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013652}
13653
Kailang Yang84898e82010-02-04 14:16:14 +010013654static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013655{
13656 struct alc_spec *spec = codec->spec;
13657 spec->ext_mic.pin = 0x18;
13658 spec->ext_mic.mux_idx = 0;
13659 spec->int_mic.pin = 0x12;
13660 spec->int_mic.mux_idx = 5;
13661 spec->auto_mic = 1;
13662}
13663
Kailang Yang84898e82010-02-04 14:16:14 +010013664static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
13665{
13666 struct alc_spec *spec = codec->spec;
13667 spec->ext_mic.pin = 0x18;
13668 spec->ext_mic.mux_idx = 0;
13669 spec->int_mic.pin = 0x12;
13670 spec->int_mic.mux_idx = 6;
13671 spec->auto_mic = 1;
13672}
13673
13674static void alc269_laptop_amic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013675{
13676 struct alc_spec *spec = codec->spec;
13677 spec->ext_mic.pin = 0x18;
13678 spec->ext_mic.mux_idx = 0;
13679 spec->int_mic.pin = 0x19;
13680 spec->int_mic.mux_idx = 1;
13681 spec->auto_mic = 1;
13682}
13683
Kailang Yang84898e82010-02-04 14:16:14 +010013684static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013685{
13686 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013687 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013688}
13689
Kailang Yangf6a92242007-12-13 16:52:54 +010013690/*
13691 * generic initialization of ADC, input mixers and output mixers
13692 */
13693static struct hda_verb alc269_init_verbs[] = {
13694 /*
13695 * Unmute ADC0 and set the default input to mic-in
13696 */
Kailang Yang84898e82010-02-04 14:16:14 +010013697 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013698
13699 /*
Kailang Yang84898e82010-02-04 14:16:14 +010013700 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010013701 */
13702 /* set vol=0 to output mixers */
13703 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13704 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13705
13706 /* set up input amps for analog loopback */
13707 /* Amp Indices: DAC = 0, mixer = 1 */
13708 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13709 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13710 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13711 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13712 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13713 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13714
13715 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13716 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13717 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13718 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13719 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13720 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13721 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13722
13723 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13724 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010013725
Kailang Yang84898e82010-02-04 14:16:14 +010013726 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010013727 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13728 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010013729 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010013730
13731 /* set EAPD */
13732 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010013733 { }
13734};
13735
13736static struct hda_verb alc269vb_init_verbs[] = {
13737 /*
13738 * Unmute ADC0 and set the default input to mic-in
13739 */
13740 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13741
13742 /*
13743 * Set up output mixers (0x02 - 0x03)
13744 */
13745 /* set vol=0 to output mixers */
13746 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13747 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13748
13749 /* set up input amps for analog loopback */
13750 /* Amp Indices: DAC = 0, mixer = 1 */
13751 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13753 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13754 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13755 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13756 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13757
13758 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13759 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13760 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13761 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13762 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13763 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13764 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13765
13766 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13767 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13768
13769 /* FIXME: use Mux-type input source selection */
13770 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13771 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
13772 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
13773
13774 /* set EAPD */
13775 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010013776 { }
13777};
13778
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013779#define alc269_auto_create_multi_out_ctls \
13780 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013781#define alc269_auto_create_input_ctls \
13782 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013783
13784#ifdef CONFIG_SND_HDA_POWER_SAVE
13785#define alc269_loopbacks alc880_loopbacks
13786#endif
13787
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013788/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013789#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13790#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13791#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13792#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13793
Takashi Iwaif03d3112009-03-05 14:18:16 +010013794static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13795 .substreams = 1,
13796 .channels_min = 2,
13797 .channels_max = 8,
13798 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13799 /* NID is set in alc_build_pcms */
13800 .ops = {
13801 .open = alc880_playback_pcm_open,
13802 .prepare = alc880_playback_pcm_prepare,
13803 .cleanup = alc880_playback_pcm_cleanup
13804 },
13805};
13806
13807static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13808 .substreams = 1,
13809 .channels_min = 2,
13810 .channels_max = 2,
13811 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13812 /* NID is set in alc_build_pcms */
13813};
13814
Kailang Yangf6a92242007-12-13 16:52:54 +010013815/*
13816 * BIOS auto configuration
13817 */
13818static int alc269_parse_auto_config(struct hda_codec *codec)
13819{
13820 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013821 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013822 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
Kailang Yang84898e82010-02-04 14:16:14 +010013823 hda_nid_t real_capsrc_nids;
Kailang Yangf6a92242007-12-13 16:52:54 +010013824
13825 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13826 alc269_ignore);
13827 if (err < 0)
13828 return err;
13829
13830 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13831 if (err < 0)
13832 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013833 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013834 if (err < 0)
13835 return err;
13836
13837 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13838
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013839 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013840 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13841
Takashi Iwai603c4012008-07-30 15:01:44 +020013842 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013843 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013844
Kailang Yang84898e82010-02-04 14:16:14 +010013845 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
13846 add_verb(spec, alc269vb_init_verbs);
13847 real_capsrc_nids = alc269vb_capsrc_nids[0];
13848 alc_ssid_check(codec, 0x21, 0x1b, 0x14);
13849 } else {
13850 add_verb(spec, alc269_init_verbs);
13851 real_capsrc_nids = alc269_capsrc_nids[0];
13852 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13853 }
13854
Kailang Yangf6a92242007-12-13 16:52:54 +010013855 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013856 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013857 /* set default input source */
Kailang Yang84898e82010-02-04 14:16:14 +010013858 snd_hda_codec_write_cache(codec, real_capsrc_nids,
Takashi Iwaie01bf502008-08-21 16:25:07 +020013859 0, AC_VERB_SET_CONNECT_SEL,
13860 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013861
13862 err = alc_auto_add_mic_boost(codec);
13863 if (err < 0)
13864 return err;
13865
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013866 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013867 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013868
Kailang Yangf6a92242007-12-13 16:52:54 +010013869 return 1;
13870}
13871
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013872#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13873#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013874#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13875
13876
13877/* init callback for auto-configuration model -- overriding the default init */
13878static void alc269_auto_init(struct hda_codec *codec)
13879{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013880 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013881 alc269_auto_init_multi_out(codec);
13882 alc269_auto_init_hp_out(codec);
13883 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013884 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013885 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013886}
13887
13888/*
13889 * configuration and preset
13890 */
13891static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013892 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013893 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010013894 [ALC269_AMIC] = "laptop-amic",
13895 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000013896 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020013897 [ALC269_LIFEBOOK] = "lifebook",
13898 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010013899};
13900
13901static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013902 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013903 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010013904 ALC269_AMIC),
13905 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
13906 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
13907 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
13908 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
13909 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
13910 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
13911 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
13912 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
13913 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
13914 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
13915 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
13916 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
13917 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
13918 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
13919 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
13920 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
13921 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
13922 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
13923 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
13924 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
13925 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
13926 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
13927 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
13928 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
13929 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
13930 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
13931 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
13932 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
13933 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
13934 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
13935 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
13936 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
13937 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
13938 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
13939 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
13940 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020013941 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010013942 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020013943 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010013944 ALC269_DMIC),
13945 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
13946 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013947 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013948 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013949 {}
13950};
13951
13952static struct alc_config_preset alc269_presets[] = {
13953 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013954 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013955 .init_verbs = { alc269_init_verbs },
13956 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13957 .dac_nids = alc269_dac_nids,
13958 .hp_nid = 0x03,
13959 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13960 .channel_mode = alc269_modes,
13961 .input_mux = &alc269_capture_source,
13962 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013963 [ALC269_QUANTA_FL1] = {
13964 .mixers = { alc269_quanta_fl1_mixer },
13965 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13966 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13967 .dac_nids = alc269_dac_nids,
13968 .hp_nid = 0x03,
13969 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13970 .channel_mode = alc269_modes,
13971 .input_mux = &alc269_capture_source,
13972 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013973 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013974 .init_hook = alc269_quanta_fl1_init_hook,
13975 },
Kailang Yang84898e82010-02-04 14:16:14 +010013976 [ALC269_AMIC] = {
13977 .mixers = { alc269_laptop_mixer },
13978 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013979 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010013980 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020013981 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13982 .dac_nids = alc269_dac_nids,
13983 .hp_nid = 0x03,
13984 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13985 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010013986 .unsol_event = alc269_laptop_unsol_event,
13987 .setup = alc269_laptop_amic_setup,
13988 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013989 },
Kailang Yang84898e82010-02-04 14:16:14 +010013990 [ALC269_DMIC] = {
13991 .mixers = { alc269_laptop_mixer },
13992 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013993 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010013994 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020013995 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13996 .dac_nids = alc269_dac_nids,
13997 .hp_nid = 0x03,
13998 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13999 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014000 .unsol_event = alc269_laptop_unsol_event,
14001 .setup = alc269_laptop_dmic_setup,
14002 .init_hook = alc269_laptop_inithook,
14003 },
14004 [ALC269VB_AMIC] = {
14005 .mixers = { alc269vb_laptop_mixer },
14006 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14007 .init_verbs = { alc269vb_init_verbs,
14008 alc269vb_laptop_amic_init_verbs },
14009 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14010 .dac_nids = alc269_dac_nids,
14011 .hp_nid = 0x03,
14012 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14013 .channel_mode = alc269_modes,
14014 .unsol_event = alc269_laptop_unsol_event,
14015 .setup = alc269_laptop_amic_setup,
14016 .init_hook = alc269_laptop_inithook,
14017 },
14018 [ALC269VB_DMIC] = {
14019 .mixers = { alc269vb_laptop_mixer },
14020 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14021 .init_verbs = { alc269vb_init_verbs,
14022 alc269vb_laptop_dmic_init_verbs },
14023 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14024 .dac_nids = alc269_dac_nids,
14025 .hp_nid = 0x03,
14026 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14027 .channel_mode = alc269_modes,
14028 .unsol_event = alc269_laptop_unsol_event,
14029 .setup = alc269vb_laptop_dmic_setup,
14030 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014031 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014032 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014033 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014034 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014035 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014036 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014037 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14038 .dac_nids = alc269_dac_nids,
14039 .hp_nid = 0x03,
14040 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14041 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014042 .unsol_event = alc269_laptop_unsol_event,
14043 .setup = alc269_laptop_dmic_setup,
14044 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014045 },
Tony Vroon64154832008-11-06 15:08:49 +000014046 [ALC269_LIFEBOOK] = {
14047 .mixers = { alc269_lifebook_mixer },
14048 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14049 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14050 .dac_nids = alc269_dac_nids,
14051 .hp_nid = 0x03,
14052 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14053 .channel_mode = alc269_modes,
14054 .input_mux = &alc269_capture_source,
14055 .unsol_event = alc269_lifebook_unsol_event,
14056 .init_hook = alc269_lifebook_init_hook,
14057 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014058};
14059
14060static int patch_alc269(struct hda_codec *codec)
14061{
14062 struct alc_spec *spec;
14063 int board_config;
14064 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014065 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014066
14067 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14068 if (spec == NULL)
14069 return -ENOMEM;
14070
14071 codec->spec = spec;
14072
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020014073 alc_fix_pll_init(codec, 0x20, 0x04, 15);
14074
Kailang Yang274693f2009-12-03 10:07:50 +010014075 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
14076 kfree(codec->chip_name);
14077 codec->chip_name = kstrdup("ALC259", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010014078 if (!codec->chip_name) {
14079 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010014080 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010014081 }
Kailang Yang84898e82010-02-04 14:16:14 +010014082 is_alc269vb = 1;
Kailang Yang274693f2009-12-03 10:07:50 +010014083 }
14084
Kailang Yangf6a92242007-12-13 16:52:54 +010014085 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14086 alc269_models,
14087 alc269_cfg_tbl);
14088
14089 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014090 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14091 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014092 board_config = ALC269_AUTO;
14093 }
14094
14095 if (board_config == ALC269_AUTO) {
14096 /* automatic parse from the BIOS config */
14097 err = alc269_parse_auto_config(codec);
14098 if (err < 0) {
14099 alc_free(codec);
14100 return err;
14101 } else if (!err) {
14102 printk(KERN_INFO
14103 "hda_codec: Cannot set up configuration "
14104 "from BIOS. Using base mode...\n");
14105 board_config = ALC269_BASIC;
14106 }
14107 }
14108
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014109 err = snd_hda_attach_beep_device(codec, 0x1);
14110 if (err < 0) {
14111 alc_free(codec);
14112 return err;
14113 }
14114
Kailang Yangf6a92242007-12-13 16:52:54 +010014115 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014116 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014117
Kailang Yang84898e82010-02-04 14:16:14 +010014118 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014119 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14120 * fix the sample rate of analog I/O to 44.1kHz
14121 */
14122 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14123 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
14124 } else {
14125 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14126 spec->stream_analog_capture = &alc269_pcm_analog_capture;
14127 }
Kailang Yangf6a92242007-12-13 16:52:54 +010014128 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14129 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14130
Kailang Yang84898e82010-02-04 14:16:14 +010014131 if (!is_alc269vb) {
14132 spec->adc_nids = alc269_adc_nids;
14133 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14134 spec->capsrc_nids = alc269_capsrc_nids;
14135 } else {
14136 spec->adc_nids = alc269vb_adc_nids;
14137 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14138 spec->capsrc_nids = alc269vb_capsrc_nids;
14139 }
14140
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014141 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014142 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014143 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010014144
Takashi Iwai100d5eb2009-08-10 11:55:51 +020014145 spec->vmaster_nid = 0x02;
14146
Kailang Yangf6a92242007-12-13 16:52:54 +010014147 codec->patch_ops = alc_patch_ops;
14148 if (board_config == ALC269_AUTO)
14149 spec->init_hook = alc269_auto_init;
14150#ifdef CONFIG_SND_HDA_POWER_SAVE
14151 if (!spec->loopback.amplist)
14152 spec->loopback.amplist = alc269_loopbacks;
14153#endif
14154
14155 return 0;
14156}
14157
14158/*
Kailang Yangdf694da2005-12-05 19:42:22 +010014159 * ALC861 channel source setting (2/6 channel selection for 3-stack)
14160 */
14161
14162/*
14163 * set the path ways for 2 channel output
14164 * need to set the codec line out and mic 1 pin widgets to inputs
14165 */
14166static struct hda_verb alc861_threestack_ch2_init[] = {
14167 /* set pin widget 1Ah (line in) for input */
14168 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014169 /* set pin widget 18h (mic1/2) for input, for mic also enable
14170 * the vref
14171 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014172 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14173
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014174 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14175#if 0
14176 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14177 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14178#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014179 { } /* end */
14180};
14181/*
14182 * 6ch mode
14183 * need to set the codec line out and mic 1 pin widgets to outputs
14184 */
14185static struct hda_verb alc861_threestack_ch6_init[] = {
14186 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14187 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14188 /* set pin widget 18h (mic1) for output (CLFE)*/
14189 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14190
14191 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014192 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014193
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014194 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14195#if 0
14196 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14197 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14198#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014199 { } /* end */
14200};
14201
14202static struct hda_channel_mode alc861_threestack_modes[2] = {
14203 { 2, alc861_threestack_ch2_init },
14204 { 6, alc861_threestack_ch6_init },
14205};
Takashi Iwai22309c32006-08-09 16:57:28 +020014206/* Set mic1 as input and unmute the mixer */
14207static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
14208 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14209 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14210 { } /* end */
14211};
14212/* Set mic1 as output and mute mixer */
14213static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
14214 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14215 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14216 { } /* end */
14217};
14218
14219static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
14220 { 2, alc861_uniwill_m31_ch2_init },
14221 { 4, alc861_uniwill_m31_ch4_init },
14222};
Kailang Yangdf694da2005-12-05 19:42:22 +010014223
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014224/* Set mic1 and line-in as input and unmute the mixer */
14225static struct hda_verb alc861_asus_ch2_init[] = {
14226 /* set pin widget 1Ah (line in) for input */
14227 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014228 /* set pin widget 18h (mic1/2) for input, for mic also enable
14229 * the vref
14230 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014231 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14232
14233 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14234#if 0
14235 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14236 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14237#endif
14238 { } /* end */
14239};
14240/* Set mic1 nad line-in as output and mute mixer */
14241static struct hda_verb alc861_asus_ch6_init[] = {
14242 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14243 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14244 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14245 /* set pin widget 18h (mic1) for output (CLFE)*/
14246 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14247 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14248 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
14249 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
14250
14251 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14252#if 0
14253 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14254 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14255#endif
14256 { } /* end */
14257};
14258
14259static struct hda_channel_mode alc861_asus_modes[2] = {
14260 { 2, alc861_asus_ch2_init },
14261 { 6, alc861_asus_ch6_init },
14262};
14263
Kailang Yangdf694da2005-12-05 19:42:22 +010014264/* patch-ALC861 */
14265
14266static struct snd_kcontrol_new alc861_base_mixer[] = {
14267 /* output mixer control */
14268 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14269 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14270 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14271 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14272 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14273
14274 /*Input mixer control */
14275 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14276 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14277 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14278 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14279 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14280 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14281 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14282 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14283 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14284 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014285
Kailang Yangdf694da2005-12-05 19:42:22 +010014286 { } /* end */
14287};
14288
14289static struct snd_kcontrol_new alc861_3ST_mixer[] = {
14290 /* output mixer control */
14291 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14292 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14293 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14294 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14295 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14296
14297 /* Input mixer control */
14298 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14299 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14300 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14301 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14302 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14303 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14304 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14305 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14306 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14307 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014308
Kailang Yangdf694da2005-12-05 19:42:22 +010014309 {
14310 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14311 .name = "Channel Mode",
14312 .info = alc_ch_mode_info,
14313 .get = alc_ch_mode_get,
14314 .put = alc_ch_mode_put,
14315 .private_value = ARRAY_SIZE(alc861_threestack_modes),
14316 },
14317 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014318};
14319
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014320static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014321 /* output mixer control */
14322 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14323 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14324 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014325
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014326 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014327};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014328
Takashi Iwai22309c32006-08-09 16:57:28 +020014329static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
14330 /* output mixer control */
14331 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14332 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14333 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14334 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14335 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14336
14337 /* Input mixer control */
14338 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14339 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14340 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14341 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14342 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14343 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14344 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14345 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14346 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14347 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014348
Takashi Iwai22309c32006-08-09 16:57:28 +020014349 {
14350 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14351 .name = "Channel Mode",
14352 .info = alc_ch_mode_info,
14353 .get = alc_ch_mode_get,
14354 .put = alc_ch_mode_put,
14355 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
14356 },
14357 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014358};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014359
14360static struct snd_kcontrol_new alc861_asus_mixer[] = {
14361 /* output mixer control */
14362 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14363 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14364 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14365 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14366 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14367
14368 /* Input mixer control */
14369 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14370 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14371 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14372 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14373 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14374 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14375 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14376 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14377 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014378 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
14379
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014380 {
14381 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14382 .name = "Channel Mode",
14383 .info = alc_ch_mode_info,
14384 .get = alc_ch_mode_get,
14385 .put = alc_ch_mode_put,
14386 .private_value = ARRAY_SIZE(alc861_asus_modes),
14387 },
14388 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014389};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014390
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014391/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014392static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014393 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14394 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014395 { }
14396};
14397
Kailang Yangdf694da2005-12-05 19:42:22 +010014398/*
14399 * generic initialization of ADC, input mixers and output mixers
14400 */
14401static struct hda_verb alc861_base_init_verbs[] = {
14402 /*
14403 * Unmute ADC0 and set the default input to mic-in
14404 */
14405 /* port-A for surround (rear panel) */
14406 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14407 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
14408 /* port-B for mic-in (rear panel) with vref */
14409 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14410 /* port-C for line-in (rear panel) */
14411 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14412 /* port-D for Front */
14413 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14414 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14415 /* port-E for HP out (front panel) */
14416 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14417 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014418 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014419 /* port-F for mic-in (front panel) with vref */
14420 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14421 /* port-G for CLFE (rear panel) */
14422 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14423 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14424 /* port-H for side (rear panel) */
14425 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14426 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
14427 /* CD-in */
14428 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14429 /* route front mic to ADC1*/
14430 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14431 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014432
Kailang Yangdf694da2005-12-05 19:42:22 +010014433 /* Unmute DAC0~3 & spdif out*/
14434 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14435 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14436 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14437 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14438 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014439
Kailang Yangdf694da2005-12-05 19:42:22 +010014440 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14441 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14442 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14443 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14444 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014445
Kailang Yangdf694da2005-12-05 19:42:22 +010014446 /* Unmute Stereo Mixer 15 */
14447 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14449 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014450 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014451
14452 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14453 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14454 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14455 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14456 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14457 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14458 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14459 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014460 /* hp used DAC 3 (Front) */
14461 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014462 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14463
14464 { }
14465};
14466
14467static struct hda_verb alc861_threestack_init_verbs[] = {
14468 /*
14469 * Unmute ADC0 and set the default input to mic-in
14470 */
14471 /* port-A for surround (rear panel) */
14472 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14473 /* port-B for mic-in (rear panel) with vref */
14474 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14475 /* port-C for line-in (rear panel) */
14476 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14477 /* port-D for Front */
14478 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14479 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14480 /* port-E for HP out (front panel) */
14481 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14482 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014483 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014484 /* port-F for mic-in (front panel) with vref */
14485 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14486 /* port-G for CLFE (rear panel) */
14487 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14488 /* port-H for side (rear panel) */
14489 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14490 /* CD-in */
14491 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14492 /* route front mic to ADC1*/
14493 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14494 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14495 /* Unmute DAC0~3 & spdif out*/
14496 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14497 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14498 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14499 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14500 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014501
Kailang Yangdf694da2005-12-05 19:42:22 +010014502 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14503 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14504 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14505 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14506 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014507
Kailang Yangdf694da2005-12-05 19:42:22 +010014508 /* Unmute Stereo Mixer 15 */
14509 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14510 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14511 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014512 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014513
14514 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14515 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14516 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14517 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14518 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14519 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14520 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14521 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014522 /* hp used DAC 3 (Front) */
14523 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014524 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14525 { }
14526};
Takashi Iwai22309c32006-08-09 16:57:28 +020014527
14528static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14529 /*
14530 * Unmute ADC0 and set the default input to mic-in
14531 */
14532 /* port-A for surround (rear panel) */
14533 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14534 /* port-B for mic-in (rear panel) with vref */
14535 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14536 /* port-C for line-in (rear panel) */
14537 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14538 /* port-D for Front */
14539 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14540 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14541 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014542 /* this has to be set to VREF80 */
14543 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014544 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014545 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014546 /* port-F for mic-in (front panel) with vref */
14547 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14548 /* port-G for CLFE (rear panel) */
14549 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14550 /* port-H for side (rear panel) */
14551 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14552 /* CD-in */
14553 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14554 /* route front mic to ADC1*/
14555 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14556 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14557 /* Unmute DAC0~3 & spdif out*/
14558 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14559 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14560 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14561 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14562 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014563
Takashi Iwai22309c32006-08-09 16:57:28 +020014564 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14565 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14566 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14567 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14568 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014569
Takashi Iwai22309c32006-08-09 16:57:28 +020014570 /* Unmute Stereo Mixer 15 */
14571 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14572 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14573 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014574 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014575
14576 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14577 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14578 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14579 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14580 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14581 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14582 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14583 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014584 /* hp used DAC 3 (Front) */
14585 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014586 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14587 { }
14588};
14589
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014590static struct hda_verb alc861_asus_init_verbs[] = {
14591 /*
14592 * Unmute ADC0 and set the default input to mic-in
14593 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014594 /* port-A for surround (rear panel)
14595 * according to codec#0 this is the HP jack
14596 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014597 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14598 /* route front PCM to HP */
14599 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14600 /* port-B for mic-in (rear panel) with vref */
14601 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14602 /* port-C for line-in (rear panel) */
14603 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14604 /* port-D for Front */
14605 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14606 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14607 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014608 /* this has to be set to VREF80 */
14609 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014610 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014611 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014612 /* port-F for mic-in (front panel) with vref */
14613 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14614 /* port-G for CLFE (rear panel) */
14615 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14616 /* port-H for side (rear panel) */
14617 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14618 /* CD-in */
14619 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14620 /* route front mic to ADC1*/
14621 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14622 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14623 /* Unmute DAC0~3 & spdif out*/
14624 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14625 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14626 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14627 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14628 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14629 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14630 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14631 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14632 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14633 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014634
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014635 /* Unmute Stereo Mixer 15 */
14636 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14637 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14638 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014639 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014640
14641 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14642 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14643 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14644 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14645 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14646 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14647 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14648 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014649 /* hp used DAC 3 (Front) */
14650 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014651 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14652 { }
14653};
14654
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014655/* additional init verbs for ASUS laptops */
14656static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14657 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14658 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14659 { }
14660};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014661
Kailang Yangdf694da2005-12-05 19:42:22 +010014662/*
14663 * generic initialization of ADC, input mixers and output mixers
14664 */
14665static struct hda_verb alc861_auto_init_verbs[] = {
14666 /*
14667 * Unmute ADC0 and set the default input to mic-in
14668 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014669 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014670 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014671
Kailang Yangdf694da2005-12-05 19:42:22 +010014672 /* Unmute DAC0~3 & spdif out*/
14673 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14674 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14675 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14676 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14677 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014678
Kailang Yangdf694da2005-12-05 19:42:22 +010014679 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14680 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14681 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14682 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14683 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014684
Kailang Yangdf694da2005-12-05 19:42:22 +010014685 /* Unmute Stereo Mixer 15 */
14686 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14687 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14688 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14689 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14690
Takashi Iwai1c209302009-07-22 15:17:45 +020014691 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14692 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14693 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14694 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14695 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14696 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14697 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14698 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014699
14700 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14701 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014702 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14703 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014704 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14705 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014706 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14707 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014708
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014709 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014710
14711 { }
14712};
14713
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014714static struct hda_verb alc861_toshiba_init_verbs[] = {
14715 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014716
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014717 { }
14718};
14719
14720/* toggle speaker-output according to the hp-jack state */
14721static void alc861_toshiba_automute(struct hda_codec *codec)
14722{
Wu Fengguang864f92b2009-11-18 12:38:02 +080014723 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014724
Takashi Iwai47fd8302007-08-10 17:11:07 +020014725 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14726 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14727 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14728 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014729}
14730
14731static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14732 unsigned int res)
14733{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014734 if ((res >> 26) == ALC880_HP_EVENT)
14735 alc861_toshiba_automute(codec);
14736}
14737
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014738/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014739#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14740#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14741#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14742#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14743
14744
14745#define ALC861_DIGOUT_NID 0x07
14746
14747static struct hda_channel_mode alc861_8ch_modes[1] = {
14748 { 8, NULL }
14749};
14750
14751static hda_nid_t alc861_dac_nids[4] = {
14752 /* front, surround, clfe, side */
14753 0x03, 0x06, 0x05, 0x04
14754};
14755
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014756static hda_nid_t alc660_dac_nids[3] = {
14757 /* front, clfe, surround */
14758 0x03, 0x05, 0x06
14759};
14760
Kailang Yangdf694da2005-12-05 19:42:22 +010014761static hda_nid_t alc861_adc_nids[1] = {
14762 /* ADC0-2 */
14763 0x08,
14764};
14765
14766static struct hda_input_mux alc861_capture_source = {
14767 .num_items = 5,
14768 .items = {
14769 { "Mic", 0x0 },
14770 { "Front Mic", 0x3 },
14771 { "Line", 0x1 },
14772 { "CD", 0x4 },
14773 { "Mixer", 0x5 },
14774 },
14775};
14776
Takashi Iwai1c209302009-07-22 15:17:45 +020014777static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14778{
14779 struct alc_spec *spec = codec->spec;
14780 hda_nid_t mix, srcs[5];
14781 int i, j, num;
14782
14783 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14784 return 0;
14785 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14786 if (num < 0)
14787 return 0;
14788 for (i = 0; i < num; i++) {
14789 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014790 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014791 if (type != AC_WID_AUD_OUT)
14792 continue;
14793 for (j = 0; j < spec->multiout.num_dacs; j++)
14794 if (spec->multiout.dac_nids[j] == srcs[i])
14795 break;
14796 if (j >= spec->multiout.num_dacs)
14797 return srcs[i];
14798 }
14799 return 0;
14800}
14801
Kailang Yangdf694da2005-12-05 19:42:22 +010014802/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014803static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014804 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014805{
Takashi Iwai1c209302009-07-22 15:17:45 +020014806 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014807 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014808 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014809
14810 spec->multiout.dac_nids = spec->private_dac_nids;
14811 for (i = 0; i < cfg->line_outs; i++) {
14812 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014813 dac = alc861_look_for_dac(codec, nid);
14814 if (!dac)
14815 continue;
14816 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014817 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014818 return 0;
14819}
14820
Takashi Iwai1c209302009-07-22 15:17:45 +020014821static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14822 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014823{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020014824 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020014825 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14826}
14827
14828/* add playback controls from the parsed DAC table */
14829static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14830 const struct auto_pin_cfg *cfg)
14831{
14832 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014833 static const char *chname[4] = {
14834 "Front", "Surround", NULL /*CLFE*/, "Side"
14835 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014836 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014837 int i, err;
14838
14839 if (cfg->line_outs == 1) {
14840 const char *pfx = NULL;
14841 if (!cfg->hp_outs)
14842 pfx = "Master";
14843 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14844 pfx = "Speaker";
14845 if (pfx) {
14846 nid = spec->multiout.dac_nids[0];
14847 return alc861_create_out_sw(codec, pfx, nid, 3);
14848 }
14849 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014850
14851 for (i = 0; i < cfg->line_outs; i++) {
14852 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014853 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014854 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014855 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014856 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014857 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014858 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014859 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014860 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014861 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014862 return err;
14863 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014864 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014865 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014866 return err;
14867 }
14868 }
14869 return 0;
14870}
14871
Takashi Iwai1c209302009-07-22 15:17:45 +020014872static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014873{
Takashi Iwai1c209302009-07-22 15:17:45 +020014874 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014875 int err;
14876 hda_nid_t nid;
14877
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014878 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014879 return 0;
14880
14881 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014882 nid = alc861_look_for_dac(codec, pin);
14883 if (nid) {
14884 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14885 if (err < 0)
14886 return err;
14887 spec->multiout.hp_nid = nid;
14888 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014889 }
14890 return 0;
14891}
14892
14893/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014894static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014895 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014896{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014897 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014898}
14899
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014900static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14901 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014902 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014903{
Takashi Iwai1c209302009-07-22 15:17:45 +020014904 hda_nid_t mix, srcs[5];
14905 int i, num;
14906
Jacek Luczak564c5be2008-05-03 18:41:23 +020014907 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14908 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014909 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014910 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014911 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14912 return;
14913 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14914 if (num < 0)
14915 return;
14916 for (i = 0; i < num; i++) {
14917 unsigned int mute;
14918 if (srcs[i] == dac || srcs[i] == 0x15)
14919 mute = AMP_IN_UNMUTE(i);
14920 else
14921 mute = AMP_IN_MUTE(i);
14922 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14923 mute);
14924 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014925}
14926
14927static void alc861_auto_init_multi_out(struct hda_codec *codec)
14928{
14929 struct alc_spec *spec = codec->spec;
14930 int i;
14931
14932 for (i = 0; i < spec->autocfg.line_outs; i++) {
14933 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014934 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014935 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014936 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014937 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014938 }
14939}
14940
14941static void alc861_auto_init_hp_out(struct hda_codec *codec)
14942{
14943 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014944
Takashi Iwai15870f02009-10-05 08:25:13 +020014945 if (spec->autocfg.hp_outs)
14946 alc861_auto_set_output_and_unmute(codec,
14947 spec->autocfg.hp_pins[0],
14948 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014949 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020014950 if (spec->autocfg.speaker_outs)
14951 alc861_auto_set_output_and_unmute(codec,
14952 spec->autocfg.speaker_pins[0],
14953 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020014954 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014955}
14956
14957static void alc861_auto_init_analog_input(struct hda_codec *codec)
14958{
14959 struct alc_spec *spec = codec->spec;
14960 int i;
14961
14962 for (i = 0; i < AUTO_PIN_LAST; i++) {
14963 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014964 if (nid >= 0x0c && nid <= 0x11)
14965 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014966 }
14967}
14968
14969/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014970/* return 1 if successful, 0 if the proper config is not found,
14971 * or a negative error code
14972 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014973static int alc861_parse_auto_config(struct hda_codec *codec)
14974{
14975 struct alc_spec *spec = codec->spec;
14976 int err;
14977 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14978
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014979 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14980 alc861_ignore);
14981 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014982 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014983 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014984 return 0; /* can't find valid BIOS pin config */
14985
Takashi Iwai1c209302009-07-22 15:17:45 +020014986 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014987 if (err < 0)
14988 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014989 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014990 if (err < 0)
14991 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014992 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014993 if (err < 0)
14994 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014995 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014996 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014997 return err;
14998
14999 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15000
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015001 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015002 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
15003
Takashi Iwai603c4012008-07-30 15:01:44 +020015004 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015005 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015006
Takashi Iwaid88897e2008-10-31 15:01:37 +010015007 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015008
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015009 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015010 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015011
15012 spec->adc_nids = alc861_adc_nids;
15013 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015014 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015015
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015016 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
15017
Kailang Yangdf694da2005-12-05 19:42:22 +010015018 return 1;
15019}
15020
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015021/* additional initialization for auto-configuration model */
15022static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015023{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015024 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015025 alc861_auto_init_multi_out(codec);
15026 alc861_auto_init_hp_out(codec);
15027 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015028 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015029 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015030}
15031
Takashi Iwaicb53c622007-08-10 17:21:45 +020015032#ifdef CONFIG_SND_HDA_POWER_SAVE
15033static struct hda_amp_list alc861_loopbacks[] = {
15034 { 0x15, HDA_INPUT, 0 },
15035 { 0x15, HDA_INPUT, 1 },
15036 { 0x15, HDA_INPUT, 2 },
15037 { 0x15, HDA_INPUT, 3 },
15038 { } /* end */
15039};
15040#endif
15041
Kailang Yangdf694da2005-12-05 19:42:22 +010015042
15043/*
15044 * configuration and preset
15045 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015046static const char *alc861_models[ALC861_MODEL_LAST] = {
15047 [ALC861_3ST] = "3stack",
15048 [ALC660_3ST] = "3stack-660",
15049 [ALC861_3ST_DIG] = "3stack-dig",
15050 [ALC861_6ST_DIG] = "6stack-dig",
15051 [ALC861_UNIWILL_M31] = "uniwill-m31",
15052 [ALC861_TOSHIBA] = "toshiba",
15053 [ALC861_ASUS] = "asus",
15054 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15055 [ALC861_AUTO] = "auto",
15056};
15057
15058static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015059 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015060 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15061 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15062 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015063 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015064 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015065 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015066 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15067 * Any other models that need this preset?
15068 */
15069 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015070 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15071 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015072 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15073 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15074 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15075 /* FIXME: the below seems conflict */
15076 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15077 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15078 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015079 {}
15080};
15081
15082static struct alc_config_preset alc861_presets[] = {
15083 [ALC861_3ST] = {
15084 .mixers = { alc861_3ST_mixer },
15085 .init_verbs = { alc861_threestack_init_verbs },
15086 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15087 .dac_nids = alc861_dac_nids,
15088 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15089 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015090 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015091 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15092 .adc_nids = alc861_adc_nids,
15093 .input_mux = &alc861_capture_source,
15094 },
15095 [ALC861_3ST_DIG] = {
15096 .mixers = { alc861_base_mixer },
15097 .init_verbs = { alc861_threestack_init_verbs },
15098 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15099 .dac_nids = alc861_dac_nids,
15100 .dig_out_nid = ALC861_DIGOUT_NID,
15101 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15102 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015103 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015104 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15105 .adc_nids = alc861_adc_nids,
15106 .input_mux = &alc861_capture_source,
15107 },
15108 [ALC861_6ST_DIG] = {
15109 .mixers = { alc861_base_mixer },
15110 .init_verbs = { alc861_base_init_verbs },
15111 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15112 .dac_nids = alc861_dac_nids,
15113 .dig_out_nid = ALC861_DIGOUT_NID,
15114 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
15115 .channel_mode = alc861_8ch_modes,
15116 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15117 .adc_nids = alc861_adc_nids,
15118 .input_mux = &alc861_capture_source,
15119 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015120 [ALC660_3ST] = {
15121 .mixers = { alc861_3ST_mixer },
15122 .init_verbs = { alc861_threestack_init_verbs },
15123 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
15124 .dac_nids = alc660_dac_nids,
15125 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15126 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015127 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015128 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15129 .adc_nids = alc861_adc_nids,
15130 .input_mux = &alc861_capture_source,
15131 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015132 [ALC861_UNIWILL_M31] = {
15133 .mixers = { alc861_uniwill_m31_mixer },
15134 .init_verbs = { alc861_uniwill_m31_init_verbs },
15135 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15136 .dac_nids = alc861_dac_nids,
15137 .dig_out_nid = ALC861_DIGOUT_NID,
15138 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
15139 .channel_mode = alc861_uniwill_m31_modes,
15140 .need_dac_fix = 1,
15141 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15142 .adc_nids = alc861_adc_nids,
15143 .input_mux = &alc861_capture_source,
15144 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015145 [ALC861_TOSHIBA] = {
15146 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015147 .init_verbs = { alc861_base_init_verbs,
15148 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015149 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15150 .dac_nids = alc861_dac_nids,
15151 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15152 .channel_mode = alc883_3ST_2ch_modes,
15153 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15154 .adc_nids = alc861_adc_nids,
15155 .input_mux = &alc861_capture_source,
15156 .unsol_event = alc861_toshiba_unsol_event,
15157 .init_hook = alc861_toshiba_automute,
15158 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015159 [ALC861_ASUS] = {
15160 .mixers = { alc861_asus_mixer },
15161 .init_verbs = { alc861_asus_init_verbs },
15162 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15163 .dac_nids = alc861_dac_nids,
15164 .dig_out_nid = ALC861_DIGOUT_NID,
15165 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
15166 .channel_mode = alc861_asus_modes,
15167 .need_dac_fix = 1,
15168 .hp_nid = 0x06,
15169 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15170 .adc_nids = alc861_adc_nids,
15171 .input_mux = &alc861_capture_source,
15172 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015173 [ALC861_ASUS_LAPTOP] = {
15174 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
15175 .init_verbs = { alc861_asus_init_verbs,
15176 alc861_asus_laptop_init_verbs },
15177 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15178 .dac_nids = alc861_dac_nids,
15179 .dig_out_nid = ALC861_DIGOUT_NID,
15180 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15181 .channel_mode = alc883_3ST_2ch_modes,
15182 .need_dac_fix = 1,
15183 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15184 .adc_nids = alc861_adc_nids,
15185 .input_mux = &alc861_capture_source,
15186 },
15187};
Kailang Yangdf694da2005-12-05 19:42:22 +010015188
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015189/* Pin config fixes */
15190enum {
15191 PINFIX_FSC_AMILO_PI1505,
15192};
15193
15194static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
15195 { 0x0b, 0x0221101f }, /* HP */
15196 { 0x0f, 0x90170310 }, /* speaker */
15197 { }
15198};
15199
15200static const struct alc_fixup alc861_fixups[] = {
15201 [PINFIX_FSC_AMILO_PI1505] = {
15202 .pins = alc861_fsc_amilo_pi1505_pinfix
15203 },
15204};
15205
15206static struct snd_pci_quirk alc861_fixup_tbl[] = {
15207 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
15208 {}
15209};
Kailang Yangdf694da2005-12-05 19:42:22 +010015210
15211static int patch_alc861(struct hda_codec *codec)
15212{
15213 struct alc_spec *spec;
15214 int board_config;
15215 int err;
15216
Robert P. J. Daydc041e02006-12-19 14:44:15 +010015217 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010015218 if (spec == NULL)
15219 return -ENOMEM;
15220
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015221 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015222
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015223 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
15224 alc861_models,
15225 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015226
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015227 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015228 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15229 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010015230 board_config = ALC861_AUTO;
15231 }
15232
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015233 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups);
15234
Kailang Yangdf694da2005-12-05 19:42:22 +010015235 if (board_config == ALC861_AUTO) {
15236 /* automatic parse from the BIOS config */
15237 err = alc861_parse_auto_config(codec);
15238 if (err < 0) {
15239 alc_free(codec);
15240 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015241 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015242 printk(KERN_INFO
15243 "hda_codec: Cannot set up configuration "
15244 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010015245 board_config = ALC861_3ST_DIG;
15246 }
15247 }
15248
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015249 err = snd_hda_attach_beep_device(codec, 0x23);
15250 if (err < 0) {
15251 alc_free(codec);
15252 return err;
15253 }
15254
Kailang Yangdf694da2005-12-05 19:42:22 +010015255 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015256 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015257
Kailang Yangdf694da2005-12-05 19:42:22 +010015258 spec->stream_analog_playback = &alc861_pcm_analog_playback;
15259 spec->stream_analog_capture = &alc861_pcm_analog_capture;
15260
Kailang Yangdf694da2005-12-05 19:42:22 +010015261 spec->stream_digital_playback = &alc861_pcm_digital_playback;
15262 spec->stream_digital_capture = &alc861_pcm_digital_capture;
15263
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010015264 if (!spec->cap_mixer)
15265 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015266 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
15267
Takashi Iwai2134ea42008-01-10 16:53:55 +010015268 spec->vmaster_nid = 0x03;
15269
Kailang Yangdf694da2005-12-05 19:42:22 +010015270 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050015271 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015272 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015273#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015274 spec->power_hook = alc_power_eapd;
15275#endif
15276 }
15277#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015278 if (!spec->loopback.amplist)
15279 spec->loopback.amplist = alc861_loopbacks;
15280#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015281
Kailang Yangdf694da2005-12-05 19:42:22 +010015282 return 0;
15283}
15284
15285/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015286 * ALC861-VD support
15287 *
15288 * Based on ALC882
15289 *
15290 * In addition, an independent DAC
15291 */
15292#define ALC861VD_DIGOUT_NID 0x06
15293
15294static hda_nid_t alc861vd_dac_nids[4] = {
15295 /* front, surr, clfe, side surr */
15296 0x02, 0x03, 0x04, 0x05
15297};
15298
15299/* dac_nids for ALC660vd are in a different order - according to
15300 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015301 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015302 * of ALC660vd codecs, but for now there is only 3stack mixer
15303 * - and it is the same as in 861vd.
15304 * adc_nids in ALC660vd are (is) the same as in 861vd
15305 */
15306static hda_nid_t alc660vd_dac_nids[3] = {
15307 /* front, rear, clfe, rear_surr */
15308 0x02, 0x04, 0x03
15309};
15310
15311static hda_nid_t alc861vd_adc_nids[1] = {
15312 /* ADC0 */
15313 0x09,
15314};
15315
Takashi Iwaie1406342008-02-11 18:32:32 +010015316static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
15317
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015318/* input MUX */
15319/* FIXME: should be a matrix-type input source selection */
15320static struct hda_input_mux alc861vd_capture_source = {
15321 .num_items = 4,
15322 .items = {
15323 { "Mic", 0x0 },
15324 { "Front Mic", 0x1 },
15325 { "Line", 0x2 },
15326 { "CD", 0x4 },
15327 },
15328};
15329
Kailang Yang272a5272007-05-14 11:00:38 +020015330static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010015331 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020015332 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010015333 { "Ext Mic", 0x0 },
15334 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020015335 },
15336};
15337
Kailang Yangd1a991a2007-08-15 16:21:59 +020015338static struct hda_input_mux alc861vd_hp_capture_source = {
15339 .num_items = 2,
15340 .items = {
15341 { "Front Mic", 0x0 },
15342 { "ATAPI Mic", 0x1 },
15343 },
15344};
15345
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015346/*
15347 * 2ch mode
15348 */
15349static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
15350 { 2, NULL }
15351};
15352
15353/*
15354 * 6ch mode
15355 */
15356static struct hda_verb alc861vd_6stack_ch6_init[] = {
15357 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15358 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15359 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15360 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15361 { } /* end */
15362};
15363
15364/*
15365 * 8ch mode
15366 */
15367static struct hda_verb alc861vd_6stack_ch8_init[] = {
15368 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15369 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15370 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15371 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15372 { } /* end */
15373};
15374
15375static struct hda_channel_mode alc861vd_6stack_modes[2] = {
15376 { 6, alc861vd_6stack_ch6_init },
15377 { 8, alc861vd_6stack_ch8_init },
15378};
15379
15380static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
15381 {
15382 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15383 .name = "Channel Mode",
15384 .info = alc_ch_mode_info,
15385 .get = alc_ch_mode_get,
15386 .put = alc_ch_mode_put,
15387 },
15388 { } /* end */
15389};
15390
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015391/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15392 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15393 */
15394static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
15395 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15396 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15397
15398 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15399 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
15400
15401 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
15402 HDA_OUTPUT),
15403 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
15404 HDA_OUTPUT),
15405 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
15406 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
15407
15408 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
15409 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
15410
15411 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15412
15413 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15414 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15415 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15416
15417 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15418 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15419 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15420
15421 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15422 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15423
15424 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15425 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15426
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015427 { } /* end */
15428};
15429
15430static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
15431 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15432 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15433
15434 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15435
15436 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15437 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15438 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15439
15440 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15441 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15442 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15443
15444 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15445 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15446
15447 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15448 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15449
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015450 { } /* end */
15451};
15452
Kailang Yangbdd148a2007-05-08 15:19:08 +020015453static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
15454 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15455 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
15456 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15457
15458 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15459
15460 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15461 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15462 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15463
15464 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15465 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15466 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15467
15468 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15469 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15470
15471 { } /* end */
15472};
15473
Tobin Davisb419f342008-03-07 11:57:51 +010015474/* Pin assignment: Speaker=0x14, HP = 0x15,
15475 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015476 */
15477static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015478 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15479 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015480 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15481 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015482 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15483 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15484 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15485 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15486 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15487 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015488 { } /* end */
15489};
15490
Kailang Yangd1a991a2007-08-15 16:21:59 +020015491/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15492 * Front Mic=0x18, ATAPI Mic = 0x19,
15493 */
15494static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15495 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15496 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15497 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15498 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15499 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15500 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15501 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15502 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015503
Kailang Yangd1a991a2007-08-15 16:21:59 +020015504 { } /* end */
15505};
15506
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015507/*
15508 * generic initialization of ADC, input mixers and output mixers
15509 */
15510static struct hda_verb alc861vd_volume_init_verbs[] = {
15511 /*
15512 * Unmute ADC0 and set the default input to mic-in
15513 */
15514 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15515 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15516
15517 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15518 * the analog-loopback mixer widget
15519 */
15520 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015521 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15522 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15523 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15524 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15525 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015526
15527 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015528 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15529 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015531 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015532
15533 /*
15534 * Set up output mixers (0x02 - 0x05)
15535 */
15536 /* set vol=0 to output mixers */
15537 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15538 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15539 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15540 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15541
15542 /* set up input amps for analog loopback */
15543 /* Amp Indices: DAC = 0, mixer = 1 */
15544 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15545 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15546 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15547 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15548 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15549 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15550 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15551 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15552
15553 { }
15554};
15555
15556/*
15557 * 3-stack pin configuration:
15558 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15559 */
15560static struct hda_verb alc861vd_3stack_init_verbs[] = {
15561 /*
15562 * Set pin mode and muting
15563 */
15564 /* set front pin widgets 0x14 for output */
15565 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15566 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15567 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15568
15569 /* Mic (rear) pin: input vref at 80% */
15570 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15571 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15572 /* Front Mic pin: input vref at 80% */
15573 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15574 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15575 /* Line In pin: input */
15576 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15577 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15578 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15579 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15580 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15581 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15582 /* CD pin widget for input */
15583 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15584
15585 { }
15586};
15587
15588/*
15589 * 6-stack pin configuration:
15590 */
15591static struct hda_verb alc861vd_6stack_init_verbs[] = {
15592 /*
15593 * Set pin mode and muting
15594 */
15595 /* set front pin widgets 0x14 for output */
15596 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15597 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15598 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15599
15600 /* Rear Pin: output 1 (0x0d) */
15601 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15602 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15603 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15604 /* CLFE Pin: output 2 (0x0e) */
15605 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15606 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15607 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15608 /* Side Pin: output 3 (0x0f) */
15609 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15610 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15611 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15612
15613 /* Mic (rear) pin: input vref at 80% */
15614 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15615 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15616 /* Front Mic pin: input vref at 80% */
15617 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15618 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15619 /* Line In pin: input */
15620 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15621 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15622 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15623 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15624 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15625 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15626 /* CD pin widget for input */
15627 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15628
15629 { }
15630};
15631
Kailang Yangbdd148a2007-05-08 15:19:08 +020015632static struct hda_verb alc861vd_eapd_verbs[] = {
15633 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15634 { }
15635};
15636
Kailang Yangf9423e72008-05-27 12:32:25 +020015637static struct hda_verb alc660vd_eapd_verbs[] = {
15638 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15639 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15640 { }
15641};
15642
Kailang Yangbdd148a2007-05-08 15:19:08 +020015643static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15644 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15645 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15646 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15647 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015648 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015649 {}
15650};
15651
Kailang Yangbdd148a2007-05-08 15:19:08 +020015652static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15653{
15654 unsigned int present;
15655 unsigned char bits;
15656
Wu Fengguang864f92b2009-11-18 12:38:02 +080015657 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020015658 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080015659
Takashi Iwai47fd8302007-08-10 17:11:07 +020015660 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15661 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015662}
15663
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015664static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015665{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015666 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015667 spec->autocfg.hp_pins[0] = 0x1b;
15668 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015669}
15670
15671static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15672{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015673 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015674 alc861vd_lenovo_mic_automute(codec);
15675}
15676
15677static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15678 unsigned int res)
15679{
15680 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015681 case ALC880_MIC_EVENT:
15682 alc861vd_lenovo_mic_automute(codec);
15683 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015684 default:
15685 alc_automute_amp_unsol_event(codec, res);
15686 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015687 }
15688}
15689
Kailang Yang272a5272007-05-14 11:00:38 +020015690static struct hda_verb alc861vd_dallas_verbs[] = {
15691 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15692 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15693 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15694 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15695
15696 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15697 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15698 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15699 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15700 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15701 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15702 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15703 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015704
Kailang Yang272a5272007-05-14 11:00:38 +020015705 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15706 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15707 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15708 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15709 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15710 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15711 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15712 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15713
15714 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15715 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15716 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15717 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15718 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15719 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15720 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15721 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15722
15723 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15724 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15725 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15726 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15727
15728 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015729 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015730 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15731
15732 { } /* end */
15733};
15734
15735/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015736static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015737{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015738 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015739
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015740 spec->autocfg.hp_pins[0] = 0x15;
15741 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015742}
15743
Takashi Iwaicb53c622007-08-10 17:21:45 +020015744#ifdef CONFIG_SND_HDA_POWER_SAVE
15745#define alc861vd_loopbacks alc880_loopbacks
15746#endif
15747
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015748/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015749#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15750#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15751#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15752#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15753
15754/*
15755 * configuration and preset
15756 */
15757static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15758 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015759 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015760 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015761 [ALC861VD_3ST] = "3stack",
15762 [ALC861VD_3ST_DIG] = "3stack-digout",
15763 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015764 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015765 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015766 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015767 [ALC861VD_AUTO] = "auto",
15768};
15769
15770static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015771 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15772 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015773 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015774 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015775 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015776 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015777 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015778 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015779 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015780 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015781 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015782 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015783 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015784 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015785 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015786 {}
15787};
15788
15789static struct alc_config_preset alc861vd_presets[] = {
15790 [ALC660VD_3ST] = {
15791 .mixers = { alc861vd_3st_mixer },
15792 .init_verbs = { alc861vd_volume_init_verbs,
15793 alc861vd_3stack_init_verbs },
15794 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15795 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015796 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15797 .channel_mode = alc861vd_3stack_2ch_modes,
15798 .input_mux = &alc861vd_capture_source,
15799 },
Mike Crash6963f842007-06-25 12:12:51 +020015800 [ALC660VD_3ST_DIG] = {
15801 .mixers = { alc861vd_3st_mixer },
15802 .init_verbs = { alc861vd_volume_init_verbs,
15803 alc861vd_3stack_init_verbs },
15804 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15805 .dac_nids = alc660vd_dac_nids,
15806 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015807 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15808 .channel_mode = alc861vd_3stack_2ch_modes,
15809 .input_mux = &alc861vd_capture_source,
15810 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015811 [ALC861VD_3ST] = {
15812 .mixers = { alc861vd_3st_mixer },
15813 .init_verbs = { alc861vd_volume_init_verbs,
15814 alc861vd_3stack_init_verbs },
15815 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15816 .dac_nids = alc861vd_dac_nids,
15817 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15818 .channel_mode = alc861vd_3stack_2ch_modes,
15819 .input_mux = &alc861vd_capture_source,
15820 },
15821 [ALC861VD_3ST_DIG] = {
15822 .mixers = { alc861vd_3st_mixer },
15823 .init_verbs = { alc861vd_volume_init_verbs,
15824 alc861vd_3stack_init_verbs },
15825 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15826 .dac_nids = alc861vd_dac_nids,
15827 .dig_out_nid = ALC861VD_DIGOUT_NID,
15828 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15829 .channel_mode = alc861vd_3stack_2ch_modes,
15830 .input_mux = &alc861vd_capture_source,
15831 },
15832 [ALC861VD_6ST_DIG] = {
15833 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15834 .init_verbs = { alc861vd_volume_init_verbs,
15835 alc861vd_6stack_init_verbs },
15836 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15837 .dac_nids = alc861vd_dac_nids,
15838 .dig_out_nid = ALC861VD_DIGOUT_NID,
15839 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15840 .channel_mode = alc861vd_6stack_modes,
15841 .input_mux = &alc861vd_capture_source,
15842 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015843 [ALC861VD_LENOVO] = {
15844 .mixers = { alc861vd_lenovo_mixer },
15845 .init_verbs = { alc861vd_volume_init_verbs,
15846 alc861vd_3stack_init_verbs,
15847 alc861vd_eapd_verbs,
15848 alc861vd_lenovo_unsol_verbs },
15849 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15850 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015851 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15852 .channel_mode = alc861vd_3stack_2ch_modes,
15853 .input_mux = &alc861vd_capture_source,
15854 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015855 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015856 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015857 },
Kailang Yang272a5272007-05-14 11:00:38 +020015858 [ALC861VD_DALLAS] = {
15859 .mixers = { alc861vd_dallas_mixer },
15860 .init_verbs = { alc861vd_dallas_verbs },
15861 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15862 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015863 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15864 .channel_mode = alc861vd_3stack_2ch_modes,
15865 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015866 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015867 .setup = alc861vd_dallas_setup,
15868 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015869 },
15870 [ALC861VD_HP] = {
15871 .mixers = { alc861vd_hp_mixer },
15872 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15873 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15874 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015875 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015876 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15877 .channel_mode = alc861vd_3stack_2ch_modes,
15878 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015879 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015880 .setup = alc861vd_dallas_setup,
15881 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015882 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015883 [ALC660VD_ASUS_V1S] = {
15884 .mixers = { alc861vd_lenovo_mixer },
15885 .init_verbs = { alc861vd_volume_init_verbs,
15886 alc861vd_3stack_init_verbs,
15887 alc861vd_eapd_verbs,
15888 alc861vd_lenovo_unsol_verbs },
15889 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15890 .dac_nids = alc660vd_dac_nids,
15891 .dig_out_nid = ALC861VD_DIGOUT_NID,
15892 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15893 .channel_mode = alc861vd_3stack_2ch_modes,
15894 .input_mux = &alc861vd_capture_source,
15895 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015896 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015897 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015898 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015899};
15900
15901/*
15902 * BIOS auto configuration
15903 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015904static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15905 const struct auto_pin_cfg *cfg)
15906{
Takashi Iwai9c0afc82010-01-12 14:00:11 +010015907 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020015908}
15909
15910
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015911static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15912 hda_nid_t nid, int pin_type, int dac_idx)
15913{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015914 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015915}
15916
15917static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15918{
15919 struct alc_spec *spec = codec->spec;
15920 int i;
15921
15922 for (i = 0; i <= HDA_SIDE; i++) {
15923 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015924 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015925 if (nid)
15926 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015927 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015928 }
15929}
15930
15931
15932static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15933{
15934 struct alc_spec *spec = codec->spec;
15935 hda_nid_t pin;
15936
15937 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015938 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015939 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015940 pin = spec->autocfg.speaker_pins[0];
15941 if (pin)
15942 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015943}
15944
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015945#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15946
15947static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15948{
15949 struct alc_spec *spec = codec->spec;
15950 int i;
15951
15952 for (i = 0; i < AUTO_PIN_LAST; i++) {
15953 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015954 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015955 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015956 if (nid != ALC861VD_PIN_CD_NID &&
15957 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015958 snd_hda_codec_write(codec, nid, 0,
15959 AC_VERB_SET_AMP_GAIN_MUTE,
15960 AMP_OUT_MUTE);
15961 }
15962 }
15963}
15964
Takashi Iwaif511b012008-08-15 16:46:42 +020015965#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15966
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015967#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15968#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15969
15970/* add playback controls from the parsed DAC table */
15971/* Based on ALC880 version. But ALC861VD has separate,
15972 * different NIDs for mute/unmute switch and volume control */
15973static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15974 const struct auto_pin_cfg *cfg)
15975{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015976 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15977 hda_nid_t nid_v, nid_s;
15978 int i, err;
15979
15980 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015981 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015982 continue;
15983 nid_v = alc861vd_idx_to_mixer_vol(
15984 alc880_dac_to_idx(
15985 spec->multiout.dac_nids[i]));
15986 nid_s = alc861vd_idx_to_mixer_switch(
15987 alc880_dac_to_idx(
15988 spec->multiout.dac_nids[i]));
15989
15990 if (i == 2) {
15991 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015992 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15993 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015994 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15995 HDA_OUTPUT));
15996 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015997 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015998 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15999 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016000 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16001 HDA_OUTPUT));
16002 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016003 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016004 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16005 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016006 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16007 HDA_INPUT));
16008 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016009 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016010 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16011 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016012 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16013 HDA_INPUT));
16014 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016015 return err;
16016 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016017 const char *pfx;
16018 if (cfg->line_outs == 1 &&
16019 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16020 if (!cfg->hp_pins)
16021 pfx = "Speaker";
16022 else
16023 pfx = "PCM";
16024 } else
16025 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016026 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016027 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16028 HDA_OUTPUT));
16029 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016030 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016031 if (cfg->line_outs == 1 &&
16032 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16033 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016034 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016035 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016036 HDA_INPUT));
16037 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016038 return err;
16039 }
16040 }
16041 return 0;
16042}
16043
16044/* add playback controls for speaker and HP outputs */
16045/* Based on ALC880 version. But ALC861VD has separate,
16046 * different NIDs for mute/unmute switch and volume control */
16047static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16048 hda_nid_t pin, const char *pfx)
16049{
16050 hda_nid_t nid_v, nid_s;
16051 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016052
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016053 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016054 return 0;
16055
16056 if (alc880_is_fixed_pin(pin)) {
16057 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16058 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016059 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016060 spec->multiout.hp_nid = nid_v;
16061 else
16062 spec->multiout.extra_out_nid[0] = nid_v;
16063 /* control HP volume/switch on the output mixer amp */
16064 nid_v = alc861vd_idx_to_mixer_vol(
16065 alc880_fixed_pin_idx(pin));
16066 nid_s = alc861vd_idx_to_mixer_switch(
16067 alc880_fixed_pin_idx(pin));
16068
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016069 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016070 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16071 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016072 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016073 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016074 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16075 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016076 return err;
16077 } else if (alc880_is_multi_pin(pin)) {
16078 /* set manual connection */
16079 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016080 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016081 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16082 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016083 return err;
16084 }
16085 return 0;
16086}
16087
16088/* parse the BIOS configuration and set up the alc_spec
16089 * return 1 if successful, 0 if the proper config is not found,
16090 * or a negative error code
16091 * Based on ALC880 version - had to change it to override
16092 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16093static int alc861vd_parse_auto_config(struct hda_codec *codec)
16094{
16095 struct alc_spec *spec = codec->spec;
16096 int err;
16097 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16098
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016099 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16100 alc861vd_ignore);
16101 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016102 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016103 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016104 return 0; /* can't find valid BIOS pin config */
16105
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016106 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16107 if (err < 0)
16108 return err;
16109 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
16110 if (err < 0)
16111 return err;
16112 err = alc861vd_auto_create_extra_out(spec,
16113 spec->autocfg.speaker_pins[0],
16114 "Speaker");
16115 if (err < 0)
16116 return err;
16117 err = alc861vd_auto_create_extra_out(spec,
16118 spec->autocfg.hp_pins[0],
16119 "Headphone");
16120 if (err < 0)
16121 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016122 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016123 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016124 return err;
16125
16126 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16127
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016128 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016129 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
16130
Takashi Iwai603c4012008-07-30 15:01:44 +020016131 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016132 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016133
Takashi Iwaid88897e2008-10-31 15:01:37 +010016134 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016135
16136 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016137 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016138
Takashi Iwai776e1842007-08-29 15:07:11 +020016139 err = alc_auto_add_mic_boost(codec);
16140 if (err < 0)
16141 return err;
16142
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016143 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
16144
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016145 return 1;
16146}
16147
16148/* additional initialization for auto-configuration model */
16149static void alc861vd_auto_init(struct hda_codec *codec)
16150{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016151 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016152 alc861vd_auto_init_multi_out(codec);
16153 alc861vd_auto_init_hp_out(codec);
16154 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016155 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016156 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016157 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016158}
16159
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016160enum {
16161 ALC660VD_FIX_ASUS_GPIO1
16162};
16163
16164/* reset GPIO1 */
16165static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
16166 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
16167 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
16168 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
16169 { }
16170};
16171
16172static const struct alc_fixup alc861vd_fixups[] = {
16173 [ALC660VD_FIX_ASUS_GPIO1] = {
16174 .verbs = alc660vd_fix_asus_gpio1_verbs,
16175 },
16176};
16177
16178static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
16179 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
16180 {}
16181};
16182
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016183static int patch_alc861vd(struct hda_codec *codec)
16184{
16185 struct alc_spec *spec;
16186 int err, board_config;
16187
16188 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16189 if (spec == NULL)
16190 return -ENOMEM;
16191
16192 codec->spec = spec;
16193
16194 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
16195 alc861vd_models,
16196 alc861vd_cfg_tbl);
16197
16198 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016199 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16200 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016201 board_config = ALC861VD_AUTO;
16202 }
16203
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016204 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
16205
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016206 if (board_config == ALC861VD_AUTO) {
16207 /* automatic parse from the BIOS config */
16208 err = alc861vd_parse_auto_config(codec);
16209 if (err < 0) {
16210 alc_free(codec);
16211 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016212 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016213 printk(KERN_INFO
16214 "hda_codec: Cannot set up configuration "
16215 "from BIOS. Using base mode...\n");
16216 board_config = ALC861VD_3ST;
16217 }
16218 }
16219
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016220 err = snd_hda_attach_beep_device(codec, 0x23);
16221 if (err < 0) {
16222 alc_free(codec);
16223 return err;
16224 }
16225
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016226 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016227 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016228
Kailang Yang2f893282008-05-27 12:14:47 +020016229 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020016230 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010016231 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020016232 }
16233
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016234 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
16235 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
16236
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016237 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
16238 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16239
Takashi Iwaidd704692009-08-11 08:45:11 +020016240 if (!spec->adc_nids) {
16241 spec->adc_nids = alc861vd_adc_nids;
16242 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
16243 }
16244 if (!spec->capsrc_nids)
16245 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016246
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016247 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016248 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016249
Takashi Iwai2134ea42008-01-10 16:53:55 +010016250 spec->vmaster_nid = 0x02;
16251
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016252 codec->patch_ops = alc_patch_ops;
16253
16254 if (board_config == ALC861VD_AUTO)
16255 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016256#ifdef CONFIG_SND_HDA_POWER_SAVE
16257 if (!spec->loopback.amplist)
16258 spec->loopback.amplist = alc861vd_loopbacks;
16259#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016260
16261 return 0;
16262}
16263
16264/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016265 * ALC662 support
16266 *
16267 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
16268 * configuration. Each pin widget can choose any input DACs and a mixer.
16269 * Each ADC is connected from a mixer of all inputs. This makes possible
16270 * 6-channel independent captures.
16271 *
16272 * In addition, an independent DAC for the multi-playback (not used in this
16273 * driver yet).
16274 */
16275#define ALC662_DIGOUT_NID 0x06
16276#define ALC662_DIGIN_NID 0x0a
16277
16278static hda_nid_t alc662_dac_nids[4] = {
16279 /* front, rear, clfe, rear_surr */
16280 0x02, 0x03, 0x04
16281};
16282
Kailang Yang622e84c2009-04-21 07:39:04 +020016283static hda_nid_t alc272_dac_nids[2] = {
16284 0x02, 0x03
16285};
16286
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016287static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016288 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016289 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016290};
Takashi Iwaie1406342008-02-11 18:32:32 +010016291
Kailang Yang622e84c2009-04-21 07:39:04 +020016292static hda_nid_t alc272_adc_nids[1] = {
16293 /* ADC1-2 */
16294 0x08,
16295};
16296
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016297static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016298static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
16299
Takashi Iwaie1406342008-02-11 18:32:32 +010016300
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016301/* input MUX */
16302/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016303static struct hda_input_mux alc662_capture_source = {
16304 .num_items = 4,
16305 .items = {
16306 { "Mic", 0x0 },
16307 { "Front Mic", 0x1 },
16308 { "Line", 0x2 },
16309 { "CD", 0x4 },
16310 },
16311};
16312
16313static struct hda_input_mux alc662_lenovo_101e_capture_source = {
16314 .num_items = 2,
16315 .items = {
16316 { "Mic", 0x1 },
16317 { "Line", 0x2 },
16318 },
16319};
Kailang Yang291702f2007-10-16 14:28:03 +020016320
Kailang Yang6dda9f42008-05-27 12:05:31 +020016321static struct hda_input_mux alc663_capture_source = {
16322 .num_items = 3,
16323 .items = {
16324 { "Mic", 0x0 },
16325 { "Front Mic", 0x1 },
16326 { "Line", 0x2 },
16327 },
16328};
16329
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016330#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020016331static struct hda_input_mux alc272_nc10_capture_source = {
16332 .num_items = 16,
16333 .items = {
16334 { "Autoselect Mic", 0x0 },
16335 { "Internal Mic", 0x1 },
16336 { "In-0x02", 0x2 },
16337 { "In-0x03", 0x3 },
16338 { "In-0x04", 0x4 },
16339 { "In-0x05", 0x5 },
16340 { "In-0x06", 0x6 },
16341 { "In-0x07", 0x7 },
16342 { "In-0x08", 0x8 },
16343 { "In-0x09", 0x9 },
16344 { "In-0x0a", 0x0a },
16345 { "In-0x0b", 0x0b },
16346 { "In-0x0c", 0x0c },
16347 { "In-0x0d", 0x0d },
16348 { "In-0x0e", 0x0e },
16349 { "In-0x0f", 0x0f },
16350 },
16351};
16352#endif
16353
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016354/*
16355 * 2ch mode
16356 */
16357static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
16358 { 2, NULL }
16359};
16360
16361/*
16362 * 2ch mode
16363 */
16364static struct hda_verb alc662_3ST_ch2_init[] = {
16365 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
16366 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16367 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
16368 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16369 { } /* end */
16370};
16371
16372/*
16373 * 6ch mode
16374 */
16375static struct hda_verb alc662_3ST_ch6_init[] = {
16376 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16377 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16378 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
16379 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16380 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16381 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
16382 { } /* end */
16383};
16384
16385static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
16386 { 2, alc662_3ST_ch2_init },
16387 { 6, alc662_3ST_ch6_init },
16388};
16389
16390/*
16391 * 2ch mode
16392 */
16393static struct hda_verb alc662_sixstack_ch6_init[] = {
16394 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16395 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16396 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16397 { } /* end */
16398};
16399
16400/*
16401 * 6ch mode
16402 */
16403static struct hda_verb alc662_sixstack_ch8_init[] = {
16404 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16405 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16406 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16407 { } /* end */
16408};
16409
16410static struct hda_channel_mode alc662_5stack_modes[2] = {
16411 { 2, alc662_sixstack_ch6_init },
16412 { 6, alc662_sixstack_ch8_init },
16413};
16414
16415/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16416 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16417 */
16418
16419static struct snd_kcontrol_new alc662_base_mixer[] = {
16420 /* output mixer control */
16421 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016422 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016423 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016424 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016425 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16426 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016427 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16428 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016429 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16430
16431 /*Input mixer control */
16432 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
16433 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
16434 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
16435 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
16436 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
16437 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
16438 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
16439 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016440 { } /* end */
16441};
16442
16443static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
16444 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016445 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016446 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16447 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16448 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16449 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16450 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16451 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16452 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16453 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16454 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016455 { } /* end */
16456};
16457
16458static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
16459 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016460 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016461 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016462 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016463 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16464 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016465 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16466 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016467 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16468 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16469 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16470 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16471 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16473 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16474 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16475 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016476 { } /* end */
16477};
16478
16479static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16480 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16481 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016482 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16483 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016484 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16485 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16486 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16487 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16488 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016489 { } /* end */
16490};
16491
Kailang Yang291702f2007-10-16 14:28:03 +020016492static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016493 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16494 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016495
16496 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16497 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16498 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16499
16500 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16501 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16502 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16503 { } /* end */
16504};
16505
Kailang Yang8c427222008-01-10 13:03:59 +010016506static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016507 ALC262_HIPPO_MASTER_SWITCH,
16508 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016509 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016510 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16511 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016512 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16513 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16514 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16515 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16516 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16517 { } /* end */
16518};
16519
Kailang Yangf1d4e282008-08-26 14:03:29 +020016520static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16521 .ops = &snd_hda_bind_vol,
16522 .values = {
16523 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16524 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16525 0
16526 },
16527};
16528
16529static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16530 .ops = &snd_hda_bind_sw,
16531 .values = {
16532 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16533 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16534 0
16535 },
16536};
16537
Kailang Yang6dda9f42008-05-27 12:05:31 +020016538static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016539 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16540 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16541 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16542 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16543 { } /* end */
16544};
16545
16546static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16547 .ops = &snd_hda_bind_sw,
16548 .values = {
16549 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16550 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16551 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16552 0
16553 },
16554};
16555
16556static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16557 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16558 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16559 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16560 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16561 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16562 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16563
16564 { } /* end */
16565};
16566
16567static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16568 .ops = &snd_hda_bind_sw,
16569 .values = {
16570 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16571 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16572 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16573 0
16574 },
16575};
16576
16577static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16578 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16579 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16580 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16581 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16582 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16583 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16584 { } /* end */
16585};
16586
16587static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016588 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16589 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016590 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16591 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16592 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16593 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16594 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16595 { } /* end */
16596};
16597
16598static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16599 .ops = &snd_hda_bind_vol,
16600 .values = {
16601 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16602 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16603 0
16604 },
16605};
16606
16607static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16608 .ops = &snd_hda_bind_sw,
16609 .values = {
16610 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16611 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16612 0
16613 },
16614};
16615
16616static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16617 HDA_BIND_VOL("Master Playback Volume",
16618 &alc663_asus_two_bind_master_vol),
16619 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16620 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016621 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16622 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16623 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016624 { } /* end */
16625};
16626
16627static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16628 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16629 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16630 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16631 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16633 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016634 { } /* end */
16635};
16636
16637static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16638 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16639 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16640 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16641 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16642 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16643
16644 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16645 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16646 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16647 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16648 { } /* end */
16649};
16650
16651static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16652 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16653 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16654 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16655
16656 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16657 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16658 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16659 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16660 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16661 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16662 { } /* end */
16663};
16664
Kailang Yangebb83ee2009-12-17 12:23:00 +010016665static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
16666 .ops = &snd_hda_bind_sw,
16667 .values = {
16668 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16669 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16670 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16671 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16672 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16673 0
16674 },
16675};
16676
16677static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
16678 .ops = &snd_hda_bind_sw,
16679 .values = {
16680 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16681 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16682 0
16683 },
16684};
16685
16686static struct snd_kcontrol_new alc663_mode7_mixer[] = {
16687 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16688 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16689 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16690 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16691 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16692 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16693 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16694 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16695 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16696 { } /* end */
16697};
16698
16699static struct snd_kcontrol_new alc663_mode8_mixer[] = {
16700 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16701 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16702 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16703 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16704 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16705 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16706 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16707 { } /* end */
16708};
16709
16710
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016711static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16712 {
16713 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16714 .name = "Channel Mode",
16715 .info = alc_ch_mode_info,
16716 .get = alc_ch_mode_get,
16717 .put = alc_ch_mode_put,
16718 },
16719 { } /* end */
16720};
16721
16722static struct hda_verb alc662_init_verbs[] = {
16723 /* ADC: mute amp left and right */
16724 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16725 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016726
Kailang Yangb60dd392007-09-20 12:50:29 +020016727 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16728 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16729 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16730 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16731 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16732 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016733
16734 /* Front Pin: output 0 (0x0c) */
16735 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16736 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16737
16738 /* Rear Pin: output 1 (0x0d) */
16739 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16740 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16741
16742 /* CLFE Pin: output 2 (0x0e) */
16743 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16744 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16745
16746 /* Mic (rear) pin: input vref at 80% */
16747 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16748 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16749 /* Front Mic pin: input vref at 80% */
16750 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16751 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16752 /* Line In pin: input */
16753 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16754 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16755 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16756 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16757 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16758 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16759 /* CD pin widget for input */
16760 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16761
16762 /* FIXME: use matrix-type input source selection */
16763 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16764 /* Input mixer */
16765 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016766 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016767
16768 /* always trun on EAPD */
16769 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16770 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16771
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016772 { }
16773};
16774
Kailang Yangcec27c82010-02-04 14:18:18 +010016775static struct hda_verb alc663_init_verbs[] = {
16776 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16777 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16778 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16779 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16780 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16781 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16782 { }
16783};
16784
16785static struct hda_verb alc272_init_verbs[] = {
16786 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16787 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16788 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16789 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16790 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16791 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16792 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16793 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16794 { }
16795};
16796
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016797static struct hda_verb alc662_sue_init_verbs[] = {
16798 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16799 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016800 {}
16801};
16802
16803static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16804 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16805 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16806 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016807};
16808
Kailang Yang8c427222008-01-10 13:03:59 +010016809/* Set Unsolicited Event*/
16810static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16811 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16812 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16813 {}
16814};
16815
Kailang Yang6dda9f42008-05-27 12:05:31 +020016816static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016817 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16818 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016819 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16820 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016821 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16822 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16823 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016824 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16825 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16826 {}
16827};
16828
Kailang Yangf1d4e282008-08-26 14:03:29 +020016829static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16830 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16831 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16832 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16833 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16834 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16835 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16836 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16837 {}
16838};
16839
16840static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16841 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16842 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16843 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16844 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16845 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16846 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16847 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16848 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16849 {}
16850};
16851
16852static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16853 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16854 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16855 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16856 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16857 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16858 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16859 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16860 {}
16861};
16862
16863static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16864 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16865 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16866 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16867 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16868 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16869 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16870 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16871 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16872 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16873 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16874 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16875 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16876 {}
16877};
16878
16879static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16880 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16881 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16882 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16883 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16884 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16885 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16886 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16887 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16888 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16889 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16890 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16891 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16892 {}
16893};
16894
Kailang Yang6dda9f42008-05-27 12:05:31 +020016895static struct hda_verb alc663_g71v_init_verbs[] = {
16896 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16897 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16898 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16899
16900 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16901 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16902 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16903
16904 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16905 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16906 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16907 {}
16908};
16909
16910static struct hda_verb alc663_g50v_init_verbs[] = {
16911 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16912 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16913 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16914
16915 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16916 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16917 {}
16918};
16919
Kailang Yangf1d4e282008-08-26 14:03:29 +020016920static struct hda_verb alc662_ecs_init_verbs[] = {
16921 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16922 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16923 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16924 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16925 {}
16926};
16927
Kailang Yang622e84c2009-04-21 07:39:04 +020016928static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16929 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16930 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16931 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16932 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16933 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16934 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16935 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16936 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16937 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16938 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16939 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16940 {}
16941};
16942
16943static struct hda_verb alc272_dell_init_verbs[] = {
16944 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16945 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16946 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16947 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16948 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16949 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16950 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16951 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16952 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16953 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16954 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16955 {}
16956};
16957
Kailang Yangebb83ee2009-12-17 12:23:00 +010016958static struct hda_verb alc663_mode7_init_verbs[] = {
16959 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16960 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16961 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16962 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16963 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16964 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16965 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
16966 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16967 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16968 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16969 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16970 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16971 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16972 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16973 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16974 {}
16975};
16976
16977static struct hda_verb alc663_mode8_init_verbs[] = {
16978 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16979 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16980 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16981 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16982 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16983 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16984 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16985 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16986 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16987 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16988 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16989 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16990 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16991 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16992 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16993 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16994 {}
16995};
16996
Kailang Yangf1d4e282008-08-26 14:03:29 +020016997static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16998 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16999 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17000 { } /* end */
17001};
17002
Kailang Yang622e84c2009-04-21 07:39:04 +020017003static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17004 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17005 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17006 { } /* end */
17007};
17008
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017009static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17010{
17011 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017012 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017013
Wu Fengguang864f92b2009-11-18 12:38:02 +080017014 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017015 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017016
Takashi Iwai47fd8302007-08-10 17:11:07 +020017017 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17018 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017019}
17020
17021static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17022{
17023 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017024 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017025
Wu Fengguang864f92b2009-11-18 12:38:02 +080017026 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017027 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017028
Takashi Iwai47fd8302007-08-10 17:11:07 +020017029 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17030 HDA_AMP_MUTE, bits);
17031 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17032 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017033}
17034
17035static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17036 unsigned int res)
17037{
17038 if ((res >> 26) == ALC880_HP_EVENT)
17039 alc662_lenovo_101e_all_automute(codec);
17040 if ((res >> 26) == ALC880_FRONT_EVENT)
17041 alc662_lenovo_101e_ispeaker_automute(codec);
17042}
17043
Kailang Yang291702f2007-10-16 14:28:03 +020017044/* unsolicited event for HP jack sensing */
17045static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17046 unsigned int res)
17047{
Kailang Yang291702f2007-10-16 14:28:03 +020017048 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017049 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017050 else
17051 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017052}
17053
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017054static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017055{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017056 struct alc_spec *spec = codec->spec;
17057
17058 alc262_hippo1_setup(codec);
17059 spec->ext_mic.pin = 0x18;
17060 spec->ext_mic.mux_idx = 0;
17061 spec->int_mic.pin = 0x19;
17062 spec->int_mic.mux_idx = 1;
17063 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017064}
17065
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017066static void alc662_eeepc_inithook(struct hda_codec *codec)
17067{
17068 alc262_hippo_automute(codec);
17069 alc_mic_automute(codec);
17070}
17071
17072static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017073{
Takashi Iwai42171c12009-05-08 14:11:43 +020017074 struct alc_spec *spec = codec->spec;
17075
17076 spec->autocfg.hp_pins[0] = 0x14;
17077 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017078}
17079
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017080#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17081
Kailang Yang6dda9f42008-05-27 12:05:31 +020017082static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17083{
17084 unsigned int present;
17085 unsigned char bits;
17086
Wu Fengguang864f92b2009-11-18 12:38:02 +080017087 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017088 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017089 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17090 AMP_IN_MUTE(0), bits);
17091 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17092 AMP_IN_MUTE(0), bits);
17093}
17094
17095static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17096{
17097 unsigned int present;
17098 unsigned char bits;
17099
Wu Fengguang864f92b2009-11-18 12:38:02 +080017100 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017101 bits = present ? HDA_AMP_MUTE : 0;
17102 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17103 AMP_IN_MUTE(0), bits);
17104 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17105 AMP_IN_MUTE(0), bits);
17106 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
17107 AMP_IN_MUTE(0), bits);
17108 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
17109 AMP_IN_MUTE(0), bits);
17110}
17111
17112static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
17113{
17114 unsigned int present;
17115 unsigned char bits;
17116
Wu Fengguang864f92b2009-11-18 12:38:02 +080017117 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017118 bits = present ? HDA_AMP_MUTE : 0;
17119 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17120 AMP_IN_MUTE(0), bits);
17121 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17122 AMP_IN_MUTE(0), bits);
17123 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
17124 AMP_IN_MUTE(0), bits);
17125 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
17126 AMP_IN_MUTE(0), bits);
17127}
17128
17129static void alc662_f5z_speaker_automute(struct hda_codec *codec)
17130{
17131 unsigned int present;
17132 unsigned char bits;
17133
Wu Fengguang864f92b2009-11-18 12:38:02 +080017134 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017135 bits = present ? 0 : PIN_OUT;
17136 snd_hda_codec_write(codec, 0x14, 0,
17137 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
17138}
17139
17140static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
17141{
17142 unsigned int present1, present2;
17143
Wu Fengguang864f92b2009-11-18 12:38:02 +080017144 present1 = snd_hda_jack_detect(codec, 0x21);
17145 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017146
17147 if (present1 || present2) {
17148 snd_hda_codec_write_cache(codec, 0x14, 0,
17149 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17150 } else {
17151 snd_hda_codec_write_cache(codec, 0x14, 0,
17152 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17153 }
17154}
17155
17156static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
17157{
17158 unsigned int present1, present2;
17159
Wu Fengguang864f92b2009-11-18 12:38:02 +080017160 present1 = snd_hda_jack_detect(codec, 0x1b);
17161 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017162
17163 if (present1 || present2) {
17164 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17165 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
17166 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17167 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
17168 } else {
17169 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17170 AMP_IN_MUTE(0), 0);
17171 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17172 AMP_IN_MUTE(0), 0);
17173 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020017174}
17175
Kailang Yangebb83ee2009-12-17 12:23:00 +010017176static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
17177{
17178 unsigned int present1, present2;
17179
17180 present1 = snd_hda_codec_read(codec, 0x1b, 0,
17181 AC_VERB_GET_PIN_SENSE, 0)
17182 & AC_PINSENSE_PRESENCE;
17183 present2 = snd_hda_codec_read(codec, 0x21, 0,
17184 AC_VERB_GET_PIN_SENSE, 0)
17185 & AC_PINSENSE_PRESENCE;
17186
17187 if (present1 || present2) {
17188 snd_hda_codec_write_cache(codec, 0x14, 0,
17189 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17190 snd_hda_codec_write_cache(codec, 0x17, 0,
17191 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17192 } else {
17193 snd_hda_codec_write_cache(codec, 0x14, 0,
17194 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17195 snd_hda_codec_write_cache(codec, 0x17, 0,
17196 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17197 }
17198}
17199
17200static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
17201{
17202 unsigned int present1, present2;
17203
17204 present1 = snd_hda_codec_read(codec, 0x21, 0,
17205 AC_VERB_GET_PIN_SENSE, 0)
17206 & AC_PINSENSE_PRESENCE;
17207 present2 = snd_hda_codec_read(codec, 0x15, 0,
17208 AC_VERB_GET_PIN_SENSE, 0)
17209 & AC_PINSENSE_PRESENCE;
17210
17211 if (present1 || present2) {
17212 snd_hda_codec_write_cache(codec, 0x14, 0,
17213 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17214 snd_hda_codec_write_cache(codec, 0x17, 0,
17215 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17216 } else {
17217 snd_hda_codec_write_cache(codec, 0x14, 0,
17218 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17219 snd_hda_codec_write_cache(codec, 0x17, 0,
17220 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17221 }
17222}
17223
Kailang Yang6dda9f42008-05-27 12:05:31 +020017224static void alc663_m51va_unsol_event(struct hda_codec *codec,
17225 unsigned int res)
17226{
17227 switch (res >> 26) {
17228 case ALC880_HP_EVENT:
17229 alc663_m51va_speaker_automute(codec);
17230 break;
17231 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017232 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017233 break;
17234 }
17235}
17236
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017237static void alc663_m51va_setup(struct hda_codec *codec)
17238{
17239 struct alc_spec *spec = codec->spec;
17240 spec->ext_mic.pin = 0x18;
17241 spec->ext_mic.mux_idx = 0;
17242 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017243 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017244 spec->auto_mic = 1;
17245}
17246
Kailang Yang6dda9f42008-05-27 12:05:31 +020017247static void alc663_m51va_inithook(struct hda_codec *codec)
17248{
17249 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017250 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017251}
17252
Kailang Yangf1d4e282008-08-26 14:03:29 +020017253/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017254#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010017255
17256static void alc663_mode1_setup(struct hda_codec *codec)
17257{
17258 struct alc_spec *spec = codec->spec;
17259 spec->ext_mic.pin = 0x18;
17260 spec->ext_mic.mux_idx = 0;
17261 spec->int_mic.pin = 0x19;
17262 spec->int_mic.mux_idx = 1;
17263 spec->auto_mic = 1;
17264}
17265
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017266#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020017267
Kailang Yangf1d4e282008-08-26 14:03:29 +020017268/* ***************** Mode2 ******************************/
17269static void alc662_mode2_unsol_event(struct hda_codec *codec,
17270 unsigned int res)
17271{
17272 switch (res >> 26) {
17273 case ALC880_HP_EVENT:
17274 alc662_f5z_speaker_automute(codec);
17275 break;
17276 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017277 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017278 break;
17279 }
17280}
17281
Kailang Yangebb83ee2009-12-17 12:23:00 +010017282#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017283
Kailang Yangf1d4e282008-08-26 14:03:29 +020017284static void alc662_mode2_inithook(struct hda_codec *codec)
17285{
17286 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017287 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017288}
17289/* ***************** Mode3 ******************************/
17290static void alc663_mode3_unsol_event(struct hda_codec *codec,
17291 unsigned int res)
17292{
17293 switch (res >> 26) {
17294 case ALC880_HP_EVENT:
17295 alc663_two_hp_m1_speaker_automute(codec);
17296 break;
17297 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017298 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017299 break;
17300 }
17301}
17302
Kailang Yangebb83ee2009-12-17 12:23:00 +010017303#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017304
Kailang Yangf1d4e282008-08-26 14:03:29 +020017305static void alc663_mode3_inithook(struct hda_codec *codec)
17306{
17307 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017308 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017309}
17310/* ***************** Mode4 ******************************/
17311static void alc663_mode4_unsol_event(struct hda_codec *codec,
17312 unsigned int res)
17313{
17314 switch (res >> 26) {
17315 case ALC880_HP_EVENT:
17316 alc663_21jd_two_speaker_automute(codec);
17317 break;
17318 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017319 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017320 break;
17321 }
17322}
17323
Kailang Yangebb83ee2009-12-17 12:23:00 +010017324#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017325
Kailang Yangf1d4e282008-08-26 14:03:29 +020017326static void alc663_mode4_inithook(struct hda_codec *codec)
17327{
17328 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017329 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017330}
17331/* ***************** Mode5 ******************************/
17332static void alc663_mode5_unsol_event(struct hda_codec *codec,
17333 unsigned int res)
17334{
17335 switch (res >> 26) {
17336 case ALC880_HP_EVENT:
17337 alc663_15jd_two_speaker_automute(codec);
17338 break;
17339 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017340 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017341 break;
17342 }
17343}
17344
Kailang Yangebb83ee2009-12-17 12:23:00 +010017345#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017346
Kailang Yangf1d4e282008-08-26 14:03:29 +020017347static void alc663_mode5_inithook(struct hda_codec *codec)
17348{
17349 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017350 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017351}
17352/* ***************** Mode6 ******************************/
17353static void alc663_mode6_unsol_event(struct hda_codec *codec,
17354 unsigned int res)
17355{
17356 switch (res >> 26) {
17357 case ALC880_HP_EVENT:
17358 alc663_two_hp_m2_speaker_automute(codec);
17359 break;
17360 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017361 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017362 break;
17363 }
17364}
17365
Kailang Yangebb83ee2009-12-17 12:23:00 +010017366#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017367
Kailang Yangf1d4e282008-08-26 14:03:29 +020017368static void alc663_mode6_inithook(struct hda_codec *codec)
17369{
17370 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017371 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017372}
17373
Kailang Yangebb83ee2009-12-17 12:23:00 +010017374/* ***************** Mode7 ******************************/
17375static void alc663_mode7_unsol_event(struct hda_codec *codec,
17376 unsigned int res)
17377{
17378 switch (res >> 26) {
17379 case ALC880_HP_EVENT:
17380 alc663_two_hp_m7_speaker_automute(codec);
17381 break;
17382 case ALC880_MIC_EVENT:
17383 alc_mic_automute(codec);
17384 break;
17385 }
17386}
17387
17388#define alc663_mode7_setup alc663_mode1_setup
17389
17390static void alc663_mode7_inithook(struct hda_codec *codec)
17391{
17392 alc663_two_hp_m7_speaker_automute(codec);
17393 alc_mic_automute(codec);
17394}
17395
17396/* ***************** Mode8 ******************************/
17397static void alc663_mode8_unsol_event(struct hda_codec *codec,
17398 unsigned int res)
17399{
17400 switch (res >> 26) {
17401 case ALC880_HP_EVENT:
17402 alc663_two_hp_m8_speaker_automute(codec);
17403 break;
17404 case ALC880_MIC_EVENT:
17405 alc_mic_automute(codec);
17406 break;
17407 }
17408}
17409
17410#define alc663_mode8_setup alc663_m51va_setup
17411
17412static void alc663_mode8_inithook(struct hda_codec *codec)
17413{
17414 alc663_two_hp_m8_speaker_automute(codec);
17415 alc_mic_automute(codec);
17416}
17417
Kailang Yang6dda9f42008-05-27 12:05:31 +020017418static void alc663_g71v_hp_automute(struct hda_codec *codec)
17419{
17420 unsigned int present;
17421 unsigned char bits;
17422
Wu Fengguang864f92b2009-11-18 12:38:02 +080017423 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017424 bits = present ? HDA_AMP_MUTE : 0;
17425 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17426 HDA_AMP_MUTE, bits);
17427 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17428 HDA_AMP_MUTE, bits);
17429}
17430
17431static void alc663_g71v_front_automute(struct hda_codec *codec)
17432{
17433 unsigned int present;
17434 unsigned char bits;
17435
Wu Fengguang864f92b2009-11-18 12:38:02 +080017436 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017437 bits = present ? HDA_AMP_MUTE : 0;
17438 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17439 HDA_AMP_MUTE, bits);
17440}
17441
17442static void alc663_g71v_unsol_event(struct hda_codec *codec,
17443 unsigned int res)
17444{
17445 switch (res >> 26) {
17446 case ALC880_HP_EVENT:
17447 alc663_g71v_hp_automute(codec);
17448 break;
17449 case ALC880_FRONT_EVENT:
17450 alc663_g71v_front_automute(codec);
17451 break;
17452 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017453 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017454 break;
17455 }
17456}
17457
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017458#define alc663_g71v_setup alc663_m51va_setup
17459
Kailang Yang6dda9f42008-05-27 12:05:31 +020017460static void alc663_g71v_inithook(struct hda_codec *codec)
17461{
17462 alc663_g71v_front_automute(codec);
17463 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017464 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017465}
17466
17467static void alc663_g50v_unsol_event(struct hda_codec *codec,
17468 unsigned int res)
17469{
17470 switch (res >> 26) {
17471 case ALC880_HP_EVENT:
17472 alc663_m51va_speaker_automute(codec);
17473 break;
17474 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017475 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017476 break;
17477 }
17478}
17479
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017480#define alc663_g50v_setup alc663_m51va_setup
17481
Kailang Yang6dda9f42008-05-27 12:05:31 +020017482static void alc663_g50v_inithook(struct hda_codec *codec)
17483{
17484 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017485 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017486}
17487
Kailang Yangf1d4e282008-08-26 14:03:29 +020017488static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17489 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017490 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017491
17492 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17493 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17494 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17495
17496 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17497 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17498 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17499 { } /* end */
17500};
17501
Chris Pockelé9541ba12009-05-12 08:08:53 +020017502static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17503 /* Master Playback automatically created from Speaker and Headphone */
17504 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17505 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17506 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17507 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17508
17509 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17510 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17511 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17512
17513 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17514 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17515 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17516 { } /* end */
17517};
17518
Takashi Iwaicb53c622007-08-10 17:21:45 +020017519#ifdef CONFIG_SND_HDA_POWER_SAVE
17520#define alc662_loopbacks alc880_loopbacks
17521#endif
17522
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017523
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017524/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017525#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17526#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17527#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17528#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17529
17530/*
17531 * configuration and preset
17532 */
17533static const char *alc662_models[ALC662_MODEL_LAST] = {
17534 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17535 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17536 [ALC662_3ST_6ch] = "3stack-6ch",
17537 [ALC662_5ST_DIG] = "6stack-dig",
17538 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017539 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017540 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017541 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017542 [ALC663_ASUS_M51VA] = "m51va",
17543 [ALC663_ASUS_G71V] = "g71v",
17544 [ALC663_ASUS_H13] = "h13",
17545 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017546 [ALC663_ASUS_MODE1] = "asus-mode1",
17547 [ALC662_ASUS_MODE2] = "asus-mode2",
17548 [ALC663_ASUS_MODE3] = "asus-mode3",
17549 [ALC663_ASUS_MODE4] = "asus-mode4",
17550 [ALC663_ASUS_MODE5] = "asus-mode5",
17551 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017552 [ALC663_ASUS_MODE7] = "asus-mode7",
17553 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017554 [ALC272_DELL] = "dell",
17555 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017556 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017557 [ALC662_AUTO] = "auto",
17558};
17559
17560static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017561 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017562 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17563 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017564 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17565 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010017566 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017567 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17568 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17569 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17570 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017571 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17572 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017573 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017574 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17575 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17576 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17577 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17578 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017579 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017580 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17581 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017582 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17583 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17584 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17585 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017586 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017587 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17588 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17589 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017590 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17591 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17592 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17593 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017594 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017595 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17596 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017597 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017598 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17599 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17600 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017601 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010017602 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017603 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17604 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017605 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17606 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17607 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017608 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017609 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17610 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017611 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017612 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017613 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017614 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17615 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17616 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017617 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017618 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17619 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017620 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017621 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017622 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017623 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017624 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17625 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010017626 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017627 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030017628 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17629 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017630 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017631 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017632 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020017633 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020017634 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017635 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17636 ALC663_ASUS_H13),
David Santinoli7aee6742009-12-09 12:34:26 +010017637 SND_PCI_QUIRK(0x8086, 0xd604, "Intel mobo", ALC662_3ST_2ch_DIG),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017638 {}
17639};
17640
17641static struct alc_config_preset alc662_presets[] = {
17642 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017643 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017644 .init_verbs = { alc662_init_verbs },
17645 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17646 .dac_nids = alc662_dac_nids,
17647 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017648 .dig_in_nid = ALC662_DIGIN_NID,
17649 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17650 .channel_mode = alc662_3ST_2ch_modes,
17651 .input_mux = &alc662_capture_source,
17652 },
17653 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017654 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017655 .init_verbs = { alc662_init_verbs },
17656 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17657 .dac_nids = alc662_dac_nids,
17658 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017659 .dig_in_nid = ALC662_DIGIN_NID,
17660 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17661 .channel_mode = alc662_3ST_6ch_modes,
17662 .need_dac_fix = 1,
17663 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017664 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017665 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017666 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017667 .init_verbs = { alc662_init_verbs },
17668 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17669 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017670 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17671 .channel_mode = alc662_3ST_6ch_modes,
17672 .need_dac_fix = 1,
17673 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017674 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017675 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017676 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017677 .init_verbs = { alc662_init_verbs },
17678 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17679 .dac_nids = alc662_dac_nids,
17680 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017681 .dig_in_nid = ALC662_DIGIN_NID,
17682 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
17683 .channel_mode = alc662_5stack_modes,
17684 .input_mux = &alc662_capture_source,
17685 },
17686 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017687 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017688 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
17689 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17690 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017691 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17692 .channel_mode = alc662_3ST_2ch_modes,
17693 .input_mux = &alc662_lenovo_101e_capture_source,
17694 .unsol_event = alc662_lenovo_101e_unsol_event,
17695 .init_hook = alc662_lenovo_101e_all_automute,
17696 },
Kailang Yang291702f2007-10-16 14:28:03 +020017697 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017698 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020017699 .init_verbs = { alc662_init_verbs,
17700 alc662_eeepc_sue_init_verbs },
17701 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17702 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020017703 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17704 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020017705 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017706 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020017707 .init_hook = alc662_eeepc_inithook,
17708 },
Kailang Yang8c427222008-01-10 13:03:59 +010017709 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017710 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010017711 alc662_chmode_mixer },
17712 .init_verbs = { alc662_init_verbs,
17713 alc662_eeepc_ep20_sue_init_verbs },
17714 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17715 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010017716 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17717 .channel_mode = alc662_3ST_6ch_modes,
17718 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020017719 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017720 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010017721 .init_hook = alc662_eeepc_ep20_inithook,
17722 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017723 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017724 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017725 .init_verbs = { alc662_init_verbs,
17726 alc662_ecs_init_verbs },
17727 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17728 .dac_nids = alc662_dac_nids,
17729 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17730 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017731 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017732 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017733 .init_hook = alc662_eeepc_inithook,
17734 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017735 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017736 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017737 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17738 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17739 .dac_nids = alc662_dac_nids,
17740 .dig_out_nid = ALC662_DIGOUT_NID,
17741 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17742 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017743 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017744 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017745 .init_hook = alc663_m51va_inithook,
17746 },
17747 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017748 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017749 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17750 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17751 .dac_nids = alc662_dac_nids,
17752 .dig_out_nid = ALC662_DIGOUT_NID,
17753 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17754 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017755 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017756 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017757 .init_hook = alc663_g71v_inithook,
17758 },
17759 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017760 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017761 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17762 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17763 .dac_nids = alc662_dac_nids,
17764 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17765 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017766 .unsol_event = alc663_m51va_unsol_event,
17767 .init_hook = alc663_m51va_inithook,
17768 },
17769 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017770 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017771 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17772 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17773 .dac_nids = alc662_dac_nids,
17774 .dig_out_nid = ALC662_DIGOUT_NID,
17775 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17776 .channel_mode = alc662_3ST_6ch_modes,
17777 .input_mux = &alc663_capture_source,
17778 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017779 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017780 .init_hook = alc663_g50v_inithook,
17781 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017782 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017783 .mixers = { alc663_m51va_mixer },
17784 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017785 .init_verbs = { alc662_init_verbs,
17786 alc663_21jd_amic_init_verbs },
17787 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17788 .hp_nid = 0x03,
17789 .dac_nids = alc662_dac_nids,
17790 .dig_out_nid = ALC662_DIGOUT_NID,
17791 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17792 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017793 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017794 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017795 .init_hook = alc663_mode1_inithook,
17796 },
17797 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017798 .mixers = { alc662_1bjd_mixer },
17799 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017800 .init_verbs = { alc662_init_verbs,
17801 alc662_1bjd_amic_init_verbs },
17802 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17803 .dac_nids = alc662_dac_nids,
17804 .dig_out_nid = ALC662_DIGOUT_NID,
17805 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17806 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017807 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017808 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017809 .init_hook = alc662_mode2_inithook,
17810 },
17811 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017812 .mixers = { alc663_two_hp_m1_mixer },
17813 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017814 .init_verbs = { alc662_init_verbs,
17815 alc663_two_hp_amic_m1_init_verbs },
17816 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17817 .hp_nid = 0x03,
17818 .dac_nids = alc662_dac_nids,
17819 .dig_out_nid = ALC662_DIGOUT_NID,
17820 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17821 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017822 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017823 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017824 .init_hook = alc663_mode3_inithook,
17825 },
17826 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017827 .mixers = { alc663_asus_21jd_clfe_mixer },
17828 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017829 .init_verbs = { alc662_init_verbs,
17830 alc663_21jd_amic_init_verbs},
17831 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17832 .hp_nid = 0x03,
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 Yangf1d4e282008-08-26 14:03:29 +020017837 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017838 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017839 .init_hook = alc663_mode4_inithook,
17840 },
17841 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017842 .mixers = { alc663_asus_15jd_clfe_mixer },
17843 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017844 .init_verbs = { alc662_init_verbs,
17845 alc663_15jd_amic_init_verbs },
17846 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17847 .hp_nid = 0x03,
17848 .dac_nids = alc662_dac_nids,
17849 .dig_out_nid = ALC662_DIGOUT_NID,
17850 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17851 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017852 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017853 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017854 .init_hook = alc663_mode5_inithook,
17855 },
17856 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017857 .mixers = { alc663_two_hp_m2_mixer },
17858 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017859 .init_verbs = { alc662_init_verbs,
17860 alc663_two_hp_amic_m2_init_verbs },
17861 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17862 .hp_nid = 0x03,
17863 .dac_nids = alc662_dac_nids,
17864 .dig_out_nid = ALC662_DIGOUT_NID,
17865 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17866 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017867 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017868 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017869 .init_hook = alc663_mode6_inithook,
17870 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017871 [ALC663_ASUS_MODE7] = {
17872 .mixers = { alc663_mode7_mixer },
17873 .cap_mixer = alc662_auto_capture_mixer,
17874 .init_verbs = { alc662_init_verbs,
17875 alc663_mode7_init_verbs },
17876 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17877 .hp_nid = 0x03,
17878 .dac_nids = alc662_dac_nids,
17879 .dig_out_nid = ALC662_DIGOUT_NID,
17880 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17881 .channel_mode = alc662_3ST_2ch_modes,
17882 .unsol_event = alc663_mode7_unsol_event,
17883 .setup = alc663_mode7_setup,
17884 .init_hook = alc663_mode7_inithook,
17885 },
17886 [ALC663_ASUS_MODE8] = {
17887 .mixers = { alc663_mode8_mixer },
17888 .cap_mixer = alc662_auto_capture_mixer,
17889 .init_verbs = { alc662_init_verbs,
17890 alc663_mode8_init_verbs },
17891 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17892 .hp_nid = 0x03,
17893 .dac_nids = alc662_dac_nids,
17894 .dig_out_nid = ALC662_DIGOUT_NID,
17895 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17896 .channel_mode = alc662_3ST_2ch_modes,
17897 .unsol_event = alc663_mode8_unsol_event,
17898 .setup = alc663_mode8_setup,
17899 .init_hook = alc663_mode8_inithook,
17900 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017901 [ALC272_DELL] = {
17902 .mixers = { alc663_m51va_mixer },
17903 .cap_mixer = alc272_auto_capture_mixer,
17904 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17905 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17906 .dac_nids = alc662_dac_nids,
17907 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17908 .adc_nids = alc272_adc_nids,
17909 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17910 .capsrc_nids = alc272_capsrc_nids,
17911 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017912 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017913 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017914 .init_hook = alc663_m51va_inithook,
17915 },
17916 [ALC272_DELL_ZM1] = {
17917 .mixers = { alc663_m51va_mixer },
17918 .cap_mixer = alc662_auto_capture_mixer,
17919 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17920 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17921 .dac_nids = alc662_dac_nids,
17922 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17923 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017924 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017925 .capsrc_nids = alc662_capsrc_nids,
17926 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017927 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017928 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017929 .init_hook = alc663_m51va_inithook,
17930 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017931 [ALC272_SAMSUNG_NC10] = {
17932 .mixers = { alc272_nc10_mixer },
17933 .init_verbs = { alc662_init_verbs,
17934 alc663_21jd_amic_init_verbs },
17935 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17936 .dac_nids = alc272_dac_nids,
17937 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17938 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017939 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017940 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017941 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017942 .init_hook = alc663_mode4_inithook,
17943 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017944};
17945
17946
17947/*
17948 * BIOS auto configuration
17949 */
17950
Takashi Iwai7085ec12009-10-02 09:03:58 +020017951/* convert from MIX nid to DAC */
17952static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17953{
17954 if (nid == 0x0f)
17955 return 0x02;
17956 else if (nid >= 0x0c && nid <= 0x0e)
17957 return nid - 0x0c + 0x02;
17958 else
17959 return 0;
17960}
17961
17962/* get MIX nid connected to the given pin targeted to DAC */
17963static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17964 hda_nid_t dac)
17965{
17966 hda_nid_t mix[4];
17967 int i, num;
17968
17969 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17970 for (i = 0; i < num; i++) {
17971 if (alc662_mix_to_dac(mix[i]) == dac)
17972 return mix[i];
17973 }
17974 return 0;
17975}
17976
17977/* look for an empty DAC slot */
17978static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
17979{
17980 struct alc_spec *spec = codec->spec;
17981 hda_nid_t srcs[5];
17982 int i, j, num;
17983
17984 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
17985 if (num < 0)
17986 return 0;
17987 for (i = 0; i < num; i++) {
17988 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
17989 if (!nid)
17990 continue;
17991 for (j = 0; j < spec->multiout.num_dacs; j++)
17992 if (spec->multiout.dac_nids[j] == nid)
17993 break;
17994 if (j >= spec->multiout.num_dacs)
17995 return nid;
17996 }
17997 return 0;
17998}
17999
18000/* fill in the dac_nids table from the parsed pin configuration */
18001static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18002 const struct auto_pin_cfg *cfg)
18003{
18004 struct alc_spec *spec = codec->spec;
18005 int i;
18006 hda_nid_t dac;
18007
18008 spec->multiout.dac_nids = spec->private_dac_nids;
18009 for (i = 0; i < cfg->line_outs; i++) {
18010 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18011 if (!dac)
18012 continue;
18013 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18014 }
18015 return 0;
18016}
18017
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018018static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018019 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018020{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018021 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018022 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18023}
18024
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018025static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018026 hda_nid_t nid, unsigned int chs)
18027{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018028 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018029 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18030}
18031
18032#define alc662_add_stereo_vol(spec, pfx, nid) \
18033 alc662_add_vol_ctl(spec, pfx, nid, 3)
18034#define alc662_add_stereo_sw(spec, pfx, nid) \
18035 alc662_add_sw_ctl(spec, pfx, nid, 3)
18036
18037/* add playback controls from the parsed DAC table */
18038static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18039 const struct auto_pin_cfg *cfg)
18040{
18041 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018042 static const char *chname[4] = {
18043 "Front", "Surround", NULL /*CLFE*/, "Side"
18044 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018045 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018046 int i, err;
18047
18048 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018049 nid = spec->multiout.dac_nids[i];
18050 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018051 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018052 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18053 if (!mix)
18054 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018055 if (i == 2) {
18056 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018057 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018058 if (err < 0)
18059 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018060 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018061 if (err < 0)
18062 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018063 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018064 if (err < 0)
18065 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018066 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018067 if (err < 0)
18068 return err;
18069 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018070 const char *pfx;
18071 if (cfg->line_outs == 1 &&
18072 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018073 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018074 pfx = "Speaker";
18075 else
18076 pfx = "PCM";
18077 } else
18078 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018079 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018080 if (err < 0)
18081 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018082 if (cfg->line_outs == 1 &&
18083 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18084 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018085 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018086 if (err < 0)
18087 return err;
18088 }
18089 }
18090 return 0;
18091}
18092
18093/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018094/* return DAC nid if any new DAC is assigned */
18095static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018096 const char *pfx)
18097{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018098 struct alc_spec *spec = codec->spec;
18099 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018100 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018101
18102 if (!pin)
18103 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018104 nid = alc662_look_for_dac(codec, pin);
18105 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018106 /* the corresponding DAC is already occupied */
18107 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
18108 return 0; /* no way */
18109 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018110 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018111 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
18112 }
18113
18114 mix = alc662_dac_to_mix(codec, pin, nid);
18115 if (!mix)
18116 return 0;
18117 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
18118 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020018119 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018120 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
18121 if (err < 0)
18122 return err;
18123 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018124}
18125
18126/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020018127#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020018128 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018129
18130static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
18131 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018132 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018133{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018134 int i, num;
18135 hda_nid_t srcs[4];
18136
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018137 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018138 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018139 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
18140 if (num <= 1)
18141 return;
18142 for (i = 0; i < num; i++) {
18143 if (alc662_mix_to_dac(srcs[i]) != dac)
18144 continue;
18145 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
18146 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018147 }
18148}
18149
18150static void alc662_auto_init_multi_out(struct hda_codec *codec)
18151{
18152 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018153 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018154 int i;
18155
18156 for (i = 0; i <= HDA_SIDE; i++) {
18157 hda_nid_t nid = spec->autocfg.line_out_pins[i];
18158 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020018159 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018160 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018161 }
18162}
18163
18164static void alc662_auto_init_hp_out(struct hda_codec *codec)
18165{
18166 struct alc_spec *spec = codec->spec;
18167 hda_nid_t pin;
18168
18169 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018170 if (pin)
18171 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
18172 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018173 pin = spec->autocfg.speaker_pins[0];
18174 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018175 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
18176 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018177}
18178
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018179#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
18180
18181static void alc662_auto_init_analog_input(struct hda_codec *codec)
18182{
18183 struct alc_spec *spec = codec->spec;
18184 int i;
18185
18186 for (i = 0; i < AUTO_PIN_LAST; i++) {
18187 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020018188 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010018189 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010018190 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010018191 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018192 snd_hda_codec_write(codec, nid, 0,
18193 AC_VERB_SET_AMP_GAIN_MUTE,
18194 AMP_OUT_MUTE);
18195 }
18196 }
18197}
18198
Takashi Iwaif511b012008-08-15 16:46:42 +020018199#define alc662_auto_init_input_src alc882_auto_init_input_src
18200
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018201static int alc662_parse_auto_config(struct hda_codec *codec)
18202{
18203 struct alc_spec *spec = codec->spec;
18204 int err;
18205 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
18206
18207 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
18208 alc662_ignore);
18209 if (err < 0)
18210 return err;
18211 if (!spec->autocfg.line_outs)
18212 return 0; /* can't find valid BIOS pin config */
18213
Takashi Iwai7085ec12009-10-02 09:03:58 +020018214 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018215 if (err < 0)
18216 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018217 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018218 if (err < 0)
18219 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018220 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018221 spec->autocfg.speaker_pins[0],
18222 "Speaker");
18223 if (err < 0)
18224 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018225 if (err)
18226 spec->multiout.extra_out_nid[0] = err;
18227 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018228 "Headphone");
18229 if (err < 0)
18230 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018231 if (err)
18232 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018233 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018234 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018235 return err;
18236
18237 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18238
Takashi Iwai0852d7a2009-02-11 11:35:15 +010018239 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018240 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
18241
Takashi Iwai603c4012008-07-30 15:01:44 +020018242 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018243 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018244
18245 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018246 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018247
Kailang Yangcec27c82010-02-04 14:18:18 +010018248 add_verb(spec, alc662_init_verbs);
18249 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18250 codec->vendor_id == 0x10ec0665)
18251 add_verb(spec, alc663_init_verbs);
18252
18253 if (codec->vendor_id == 0x10ec0272)
18254 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020018255
18256 err = alc_auto_add_mic_boost(codec);
18257 if (err < 0)
18258 return err;
18259
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018260 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
18261
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018262 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018263}
18264
18265/* additional initialization for auto-configuration model */
18266static void alc662_auto_init(struct hda_codec *codec)
18267{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018268 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018269 alc662_auto_init_multi_out(codec);
18270 alc662_auto_init_hp_out(codec);
18271 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020018272 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018273 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018274 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018275}
18276
18277static int patch_alc662(struct hda_codec *codec)
18278{
18279 struct alc_spec *spec;
18280 int err, board_config;
18281
18282 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18283 if (!spec)
18284 return -ENOMEM;
18285
18286 codec->spec = spec;
18287
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018288 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18289
Kailang Yang274693f2009-12-03 10:07:50 +010018290 if (alc_read_coef_idx(codec, 0)==0x8020){
18291 kfree(codec->chip_name);
18292 codec->chip_name = kstrdup("ALC661", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018293 if (!codec->chip_name) {
18294 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018295 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018296 }
Kailang Yang274693f2009-12-03 10:07:50 +010018297 }
18298
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018299 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18300 alc662_models,
18301 alc662_cfg_tbl);
18302 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020018303 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18304 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018305 board_config = ALC662_AUTO;
18306 }
18307
18308 if (board_config == ALC662_AUTO) {
18309 /* automatic parse from the BIOS config */
18310 err = alc662_parse_auto_config(codec);
18311 if (err < 0) {
18312 alc_free(codec);
18313 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018314 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018315 printk(KERN_INFO
18316 "hda_codec: Cannot set up configuration "
18317 "from BIOS. Using base mode...\n");
18318 board_config = ALC662_3ST_2ch_DIG;
18319 }
18320 }
18321
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018322 err = snd_hda_attach_beep_device(codec, 0x1);
18323 if (err < 0) {
18324 alc_free(codec);
18325 return err;
18326 }
18327
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018328 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018329 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018330
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018331 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18332 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18333
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018334 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18335 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18336
Takashi Iwaidd704692009-08-11 08:45:11 +020018337 if (!spec->adc_nids) {
18338 spec->adc_nids = alc662_adc_nids;
18339 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
18340 }
18341 if (!spec->capsrc_nids)
18342 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018343
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018344 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018345 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018346
Kailang Yangcec27c82010-02-04 14:18:18 +010018347 switch (codec->vendor_id) {
18348 case 0x10ec0662:
18349 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18350 break;
18351 case 0x10ec0272:
18352 case 0x10ec0663:
18353 case 0x10ec0665:
18354 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
18355 break;
18356 case 0x10ec0273:
18357 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
18358 break;
18359 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010018360 spec->vmaster_nid = 0x02;
18361
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018362 codec->patch_ops = alc_patch_ops;
18363 if (board_config == ALC662_AUTO)
18364 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020018365#ifdef CONFIG_SND_HDA_POWER_SAVE
18366 if (!spec->loopback.amplist)
18367 spec->loopback.amplist = alc662_loopbacks;
18368#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018369
18370 return 0;
18371}
18372
Kailang Yang274693f2009-12-03 10:07:50 +010018373static int patch_alc888(struct hda_codec *codec)
18374{
18375 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
18376 kfree(codec->chip_name);
18377 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018378 if (!codec->chip_name) {
18379 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018380 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018381 }
18382 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018383 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018384 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018385}
18386
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018387/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070018388 * patch entries
18389 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018390static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070018391 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018392 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018393 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020018394 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018395 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018396 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020018397 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018398 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018399 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018400 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018401 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
18402 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
18403 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018404 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018405 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018406 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
18407 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018408 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010018409 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018410 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018411 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018412 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020018413 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018414 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020018415 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018416 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018417 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018418 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020018419 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018420 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018421 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018422 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018423 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018424 {} /* terminator */
18425};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018426
18427MODULE_ALIAS("snd-hda-codec-id:10ec*");
18428
18429MODULE_LICENSE("GPL");
18430MODULE_DESCRIPTION("Realtek HD-audio codec");
18431
18432static struct hda_codec_preset_list realtek_list = {
18433 .preset = snd_hda_preset_realtek,
18434 .owner = THIS_MODULE,
18435};
18436
18437static int __init patch_realtek_init(void)
18438{
18439 return snd_hda_add_codec_preset(&realtek_list);
18440}
18441
18442static void __exit patch_realtek_exit(void)
18443{
18444 snd_hda_delete_codec_preset(&realtek_list);
18445}
18446
18447module_init(patch_realtek_init)
18448module_exit(patch_realtek_exit)