blob: ca93c4cc144e0430fbe76a2863b7edffeb690c2e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090033#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010081 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010082#ifdef CONFIG_SND_DEBUG
83 ALC260_TEST,
84#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010085 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020086 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
Kailang Yangdf694da2005-12-05 19:42:22 +010089/* ALC262 models */
90enum {
91 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020092 ALC262_HIPPO,
93 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010094 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020095 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010096 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010098 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010099 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200100 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200101 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200102 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200103 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100104 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200105 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200106 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200107 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000108 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100109 ALC262_AUTO,
110 ALC262_MODEL_LAST /* last tag */
111};
112
Kailang Yanga361d842007-06-05 12:30:55 +0200113/* ALC268 models */
114enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200115 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200116 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200117 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200118 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100119 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200120 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100121 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100122 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100123#ifdef CONFIG_SND_DEBUG
124 ALC268_TEST,
125#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200126 ALC268_AUTO,
127 ALC268_MODEL_LAST /* last tag */
128};
129
Kailang Yangf6a92242007-12-13 16:52:54 +0100130/* ALC269 models */
131enum {
132 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200133 ALC269_QUANTA_FL1,
Kailang Yang84898e82010-02-04 14:16:14 +0100134 ALC269_AMIC,
135 ALC269_DMIC,
136 ALC269VB_AMIC,
137 ALC269VB_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100138 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000139 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100140 ALC269_AUTO,
141 ALC269_MODEL_LAST /* last tag */
142};
143
Kailang Yangdf694da2005-12-05 19:42:22 +0100144/* ALC861 models */
145enum {
146 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200147 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100148 ALC861_3ST_DIG,
149 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200150 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200151 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200152 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100153 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100154 ALC861_AUTO,
155 ALC861_MODEL_LAST,
156};
157
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100158/* ALC861-VD models */
159enum {
160 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200161 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100162 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100163 ALC861VD_3ST,
164 ALC861VD_3ST_DIG,
165 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200166 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200167 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200168 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100169 ALC861VD_AUTO,
170 ALC861VD_MODEL_LAST,
171};
172
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200173/* ALC662 models */
174enum {
175 ALC662_3ST_2ch_DIG,
176 ALC662_3ST_6ch_DIG,
177 ALC662_3ST_6ch,
178 ALC662_5ST_DIG,
179 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200180 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100181 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200182 ALC663_ASUS_M51VA,
183 ALC663_ASUS_G71V,
184 ALC663_ASUS_H13,
185 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200186 ALC662_ECS,
187 ALC663_ASUS_MODE1,
188 ALC662_ASUS_MODE2,
189 ALC663_ASUS_MODE3,
190 ALC663_ASUS_MODE4,
191 ALC663_ASUS_MODE5,
192 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100193 ALC663_ASUS_MODE7,
194 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200195 ALC272_DELL,
196 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200197 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200198 ALC662_AUTO,
199 ALC662_MODEL_LAST,
200};
201
Kailang Yangdf694da2005-12-05 19:42:22 +0100202/* ALC882 models */
203enum {
204 ALC882_3ST_DIG,
205 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200206 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200207 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200208 ALC882_TARGA,
209 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200210 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100211 ALC885_MACPRO,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -0800212 ALC885_MBA21,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200213 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200214 ALC885_MB5,
Luke Yelaviche458b1f2010-02-12 16:28:29 +1100215 ALC885_MACMINI3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200216 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800217 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200218 ALC883_3ST_2ch_DIG,
219 ALC883_3ST_6ch_DIG,
220 ALC883_3ST_6ch,
221 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200222 ALC883_TARGA_DIG,
223 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200224 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200225 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200226 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800227 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100228 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200229 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200230 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200231 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200232 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100233 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200234 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200235 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200236 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200237 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200238 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200239 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100240 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100241 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430242 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100243 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100244 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800245 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200246 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200247 ALC889A_INTEL,
248 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200249 ALC888_ASUS_M90V,
250 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200251 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100252 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200253 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200254 ALC882_AUTO,
255 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200256};
257
Kailang Yangdf694da2005-12-05 19:42:22 +0100258/* for GPIO Poll */
259#define GPIO_MASK 0x03
260
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200261/* extra amp-initialization sequence types */
262enum {
263 ALC_INIT_NONE,
264 ALC_INIT_DEFAULT,
265 ALC_INIT_GPIO1,
266 ALC_INIT_GPIO2,
267 ALC_INIT_GPIO3,
268};
269
Takashi Iwai6c819492009-08-10 18:47:44 +0200270struct alc_mic_route {
271 hda_nid_t pin;
272 unsigned char mux_idx;
273 unsigned char amix_idx;
274};
275
276#define MUX_IDX_UNDEF ((unsigned char)-1)
277
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278struct alc_spec {
279 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100280 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100282 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100283 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200285 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200286 * don't forget NULL
287 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200288 */
289 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200291 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 struct hda_pcm_stream *stream_analog_playback;
293 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100294 struct hda_pcm_stream *stream_analog_alt_playback;
295 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200297 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 struct hda_pcm_stream *stream_digital_playback;
299 struct hda_pcm_stream *stream_digital_capture;
300
301 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200302 struct hda_multi_out multiout; /* playback set-up
303 * max_channels, dacs must be set
304 * dig_out_nid and hp_nid are optional
305 */
Takashi Iwai63300792008-01-24 15:31:36 +0100306 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100307 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100308 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
310 /* capture */
311 unsigned int num_adc_nids;
312 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100313 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200314 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315
316 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200317 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 const struct hda_input_mux *input_mux;
319 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200320 struct alc_mic_route ext_mic;
321 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
323 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100324 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200326 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200327 int const_channel_count;
328 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329
330 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100331 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200332
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200333 /* dynamic controls, init_verbs and input_mux */
334 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200335 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200336 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200337 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200338 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
339 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100340
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100341 /* hooks */
342 void (*init_hook)(struct hda_codec *codec);
343 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100344#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500345 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100346#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100347
Takashi Iwai834be882006-03-01 14:16:17 +0100348 /* for pin sensing */
349 unsigned int sense_updated: 1;
350 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100351 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200352 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200353
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100354 /* other flags */
355 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200356 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100357
Takashi Iwai2134ea42008-01-10 16:53:55 +0100358 /* for virtual master */
359 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200360#ifdef CONFIG_SND_HDA_POWER_SAVE
361 struct hda_loopback_check loopback;
362#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200363
364 /* for PLL fix */
365 hda_nid_t pll_nid;
366 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100367};
368
369/*
370 * configuration template - to be copied to the spec instance
371 */
372struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200373 struct snd_kcontrol_new *mixers[5]; /* should be identical size
374 * with spec
375 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100376 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100377 const struct hda_verb *init_verbs[5];
378 unsigned int num_dacs;
379 hda_nid_t *dac_nids;
380 hda_nid_t dig_out_nid; /* optional */
381 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800382 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100383 unsigned int num_adc_nids;
384 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100385 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100386 hda_nid_t dig_in_nid;
387 unsigned int num_channel_mode;
388 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200389 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200390 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200391 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100392 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100393 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200394 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100395 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200396#ifdef CONFIG_SND_HDA_POWER_SAVE
397 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500398 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200399#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400};
401
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402
403/*
404 * input MUX handling
405 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200406static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
407 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408{
409 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
410 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200411 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
412 if (mux_idx >= spec->num_mux_defs)
413 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100414 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
415 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200416 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417}
418
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200419static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
420 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421{
422 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
423 struct alc_spec *spec = codec->spec;
424 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
425
426 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
427 return 0;
428}
429
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200430static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
431 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432{
433 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
434 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100435 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100437 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100438 hda_nid_t nid = spec->capsrc_nids ?
439 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200440 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441
Takashi Iwaicd896c32008-11-18 12:36:33 +0100442 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
443 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100444 if (!imux->num_items && mux_idx > 0)
445 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100446
Takashi Iwaia22d5432009-07-27 12:54:26 +0200447 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200448 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100449 /* Matrix-mixer style (e.g. ALC882) */
450 unsigned int *cur_val = &spec->cur_mux[adc_idx];
451 unsigned int i, idx;
452
453 idx = ucontrol->value.enumerated.item[0];
454 if (idx >= imux->num_items)
455 idx = imux->num_items - 1;
456 if (*cur_val == idx)
457 return 0;
458 for (i = 0; i < imux->num_items; i++) {
459 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
460 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
461 imux->items[i].index,
462 HDA_AMP_MUTE, v);
463 }
464 *cur_val = idx;
465 return 1;
466 } else {
467 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100468 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100469 &spec->cur_mux[adc_idx]);
470 }
471}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200472
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473/*
474 * channel mode setting
475 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200476static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
477 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478{
479 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
480 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100481 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
482 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483}
484
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200485static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
486 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487{
488 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
489 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100490 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200491 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200492 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493}
494
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200495static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
496 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497{
498 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
499 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200500 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
501 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200502 &spec->ext_channel_count);
503 if (err >= 0 && !spec->const_channel_count) {
504 spec->multiout.max_channels = spec->ext_channel_count;
505 if (spec->need_dac_fix)
506 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
507 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200508 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509}
510
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100512 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200513 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100514 * being part of a format specifier. Maximum allowed length of a value is
515 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100516 *
517 * Note: some retasking pin complexes seem to ignore requests for input
518 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
519 * are requested. Therefore order this list so that this behaviour will not
520 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200521 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
522 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200523 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100524static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100525 "Mic 50pc bias", "Mic 80pc bias",
526 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100527};
528static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100529 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100530};
531/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200532 * in the pin being assumed to be exclusively an input or an output pin. In
533 * addition, "input" pins may or may not process the mic bias option
534 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
535 * accept requests for bias as of chip versions up to March 2006) and/or
536 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100537 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200538#define ALC_PIN_DIR_IN 0x00
539#define ALC_PIN_DIR_OUT 0x01
540#define ALC_PIN_DIR_INOUT 0x02
541#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
542#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100543
Kailang Yangea1fb292008-08-26 12:58:38 +0200544/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100545 * For each direction the minimum and maximum values are given.
546 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200547static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100548 { 0, 2 }, /* ALC_PIN_DIR_IN */
549 { 3, 4 }, /* ALC_PIN_DIR_OUT */
550 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200551 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
552 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100553};
554#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
555#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
556#define alc_pin_mode_n_items(_dir) \
557 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
558
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200559static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
560 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200561{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100562 unsigned int item_num = uinfo->value.enumerated.item;
563 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
564
565 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200566 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100567 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
568
569 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
570 item_num = alc_pin_mode_min(dir);
571 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200572 return 0;
573}
574
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200575static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
576 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200577{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100578 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200579 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
580 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100581 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200582 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200583 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
584 AC_VERB_GET_PIN_WIDGET_CONTROL,
585 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200586
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100587 /* Find enumerated value for current pinctl setting */
588 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200589 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100590 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200591 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100592 return 0;
593}
594
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200595static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
596 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100597{
598 signed int change;
599 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
600 hda_nid_t nid = kcontrol->private_value & 0xffff;
601 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
602 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200603 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
604 AC_VERB_GET_PIN_WIDGET_CONTROL,
605 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100606
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200607 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100608 val = alc_pin_mode_min(dir);
609
610 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100611 if (change) {
612 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200613 snd_hda_codec_write_cache(codec, nid, 0,
614 AC_VERB_SET_PIN_WIDGET_CONTROL,
615 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100616
Kailang Yangea1fb292008-08-26 12:58:38 +0200617 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100618 * for the requested pin mode. Enum values of 2 or less are
619 * input modes.
620 *
621 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200622 * reduces noise slightly (particularly on input) so we'll
623 * do it. However, having both input and output buffers
624 * enabled simultaneously doesn't seem to be problematic if
625 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100626 */
627 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200628 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
629 HDA_AMP_MUTE, HDA_AMP_MUTE);
630 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
631 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100632 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200633 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
634 HDA_AMP_MUTE, HDA_AMP_MUTE);
635 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
636 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100637 }
638 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200639 return change;
640}
641
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100642#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200643 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100644 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100645 .info = alc_pin_mode_info, \
646 .get = alc_pin_mode_get, \
647 .put = alc_pin_mode_put, \
648 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100649
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100650/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
651 * together using a mask with more than one bit set. This control is
652 * currently used only by the ALC260 test model. At this stage they are not
653 * needed for any "production" models.
654 */
655#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200656#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200657
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200658static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
659 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100660{
661 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
662 hda_nid_t nid = kcontrol->private_value & 0xffff;
663 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
664 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200665 unsigned int val = snd_hda_codec_read(codec, nid, 0,
666 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100667
668 *valp = (val & mask) != 0;
669 return 0;
670}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200671static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
672 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100673{
674 signed int change;
675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
676 hda_nid_t nid = kcontrol->private_value & 0xffff;
677 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
678 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200679 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
680 AC_VERB_GET_GPIO_DATA,
681 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100682
683 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200684 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
685 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100686 gpio_data &= ~mask;
687 else
688 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200689 snd_hda_codec_write_cache(codec, nid, 0,
690 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100691
692 return change;
693}
694#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
695 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100696 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100697 .info = alc_gpio_data_info, \
698 .get = alc_gpio_data_get, \
699 .put = alc_gpio_data_put, \
700 .private_value = nid | (mask<<16) }
701#endif /* CONFIG_SND_DEBUG */
702
Jonathan Woithe92621f12006-02-28 11:47:47 +0100703/* A switch control to allow the enabling of the digital IO pins on the
704 * ALC260. This is incredibly simplistic; the intention of this control is
705 * to provide something in the test model allowing digital outputs to be
706 * identified if present. If models are found which can utilise these
707 * outputs a more complete mixer control can be devised for those models if
708 * necessary.
709 */
710#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200711#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200712
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200713static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
714 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100715{
716 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
717 hda_nid_t nid = kcontrol->private_value & 0xffff;
718 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
719 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200720 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100721 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100722
723 *valp = (val & mask) != 0;
724 return 0;
725}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200726static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
727 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100728{
729 signed int change;
730 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
731 hda_nid_t nid = kcontrol->private_value & 0xffff;
732 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
733 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200734 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100735 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200736 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100737
738 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200739 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100740 if (val==0)
741 ctrl_data &= ~mask;
742 else
743 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200744 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
745 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100746
747 return change;
748}
749#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
750 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100751 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100752 .info = alc_spdif_ctrl_info, \
753 .get = alc_spdif_ctrl_get, \
754 .put = alc_spdif_ctrl_put, \
755 .private_value = nid | (mask<<16) }
756#endif /* CONFIG_SND_DEBUG */
757
Jonathan Woithef8225f62008-01-08 12:16:54 +0100758/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
759 * Again, this is only used in the ALC26x test models to help identify when
760 * the EAPD line must be asserted for features to work.
761 */
762#ifdef CONFIG_SND_DEBUG
763#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
764
765static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
766 struct snd_ctl_elem_value *ucontrol)
767{
768 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
769 hda_nid_t nid = kcontrol->private_value & 0xffff;
770 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
771 long *valp = ucontrol->value.integer.value;
772 unsigned int val = snd_hda_codec_read(codec, nid, 0,
773 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
774
775 *valp = (val & mask) != 0;
776 return 0;
777}
778
779static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
780 struct snd_ctl_elem_value *ucontrol)
781{
782 int change;
783 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
784 hda_nid_t nid = kcontrol->private_value & 0xffff;
785 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
786 long val = *ucontrol->value.integer.value;
787 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
788 AC_VERB_GET_EAPD_BTLENABLE,
789 0x00);
790
791 /* Set/unset the masked control bit(s) as needed */
792 change = (!val ? 0 : mask) != (ctrl_data & mask);
793 if (!val)
794 ctrl_data &= ~mask;
795 else
796 ctrl_data |= mask;
797 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
798 ctrl_data);
799
800 return change;
801}
802
803#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
804 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100805 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100806 .info = alc_eapd_ctrl_info, \
807 .get = alc_eapd_ctrl_get, \
808 .put = alc_eapd_ctrl_put, \
809 .private_value = nid | (mask<<16) }
810#endif /* CONFIG_SND_DEBUG */
811
Kailang Yangdf694da2005-12-05 19:42:22 +0100812/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100813 * set up the input pin config (depending on the given auto-pin type)
814 */
815static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
816 int auto_pin_type)
817{
818 unsigned int val = PIN_IN;
819
820 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
821 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100822 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100823 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
824 if (pincap & AC_PINCAP_VREF_80)
825 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200826 else if (pincap & AC_PINCAP_VREF_50)
827 val = PIN_VREF50;
828 else if (pincap & AC_PINCAP_VREF_100)
829 val = PIN_VREF100;
830 else if (pincap & AC_PINCAP_VREF_GRD)
831 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100832 }
833 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
834}
835
836/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100837 */
838static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
839{
840 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
841 return;
842 spec->mixers[spec->num_mixers++] = mix;
843}
844
845static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
846{
847 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
848 return;
849 spec->init_verbs[spec->num_init_verbs++] = verb;
850}
851
852/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100853 * set up from the preset table
854 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200855static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200856 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100857{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200858 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100859 int i;
860
861 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100862 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100863 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200864 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
865 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100866 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200867
Kailang Yangdf694da2005-12-05 19:42:22 +0100868 spec->channel_mode = preset->channel_mode;
869 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200870 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200871 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100872
Hector Martin3b315d72009-06-02 10:54:19 +0200873 if (preset->const_channel_count)
874 spec->multiout.max_channels = preset->const_channel_count;
875 else
876 spec->multiout.max_channels = spec->channel_mode[0].channels;
877 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100878
879 spec->multiout.num_dacs = preset->num_dacs;
880 spec->multiout.dac_nids = preset->dac_nids;
881 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800882 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100883 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200884
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200885 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200886 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200887 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100888 spec->input_mux = preset->input_mux;
889
890 spec->num_adc_nids = preset->num_adc_nids;
891 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100892 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100893 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100894
895 spec->unsol_event = preset->unsol_event;
896 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200897#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100898 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200899 spec->loopback.amplist = preset->loopbacks;
900#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200901
902 if (preset->setup)
903 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100904}
905
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200906/* Enable GPIO mask and set output */
907static struct hda_verb alc_gpio1_init_verbs[] = {
908 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
909 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
910 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
911 { }
912};
913
914static struct hda_verb alc_gpio2_init_verbs[] = {
915 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
916 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
917 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
918 { }
919};
920
Kailang Yangbdd148a2007-05-08 15:19:08 +0200921static struct hda_verb alc_gpio3_init_verbs[] = {
922 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
923 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
924 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
925 { }
926};
927
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200928/*
929 * Fix hardware PLL issue
930 * On some codecs, the analog PLL gating control must be off while
931 * the default value is 1.
932 */
933static void alc_fix_pll(struct hda_codec *codec)
934{
935 struct alc_spec *spec = codec->spec;
936 unsigned int val;
937
938 if (!spec->pll_nid)
939 return;
940 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
941 spec->pll_coef_idx);
942 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
943 AC_VERB_GET_PROC_COEF, 0);
944 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
945 spec->pll_coef_idx);
946 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
947 val & ~(1 << spec->pll_coef_bit));
948}
949
950static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
951 unsigned int coef_idx, unsigned int coef_bit)
952{
953 struct alc_spec *spec = codec->spec;
954 spec->pll_nid = nid;
955 spec->pll_coef_idx = coef_idx;
956 spec->pll_coef_bit = coef_bit;
957 alc_fix_pll(codec);
958}
959
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200960static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200961{
962 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200963 unsigned int nid = spec->autocfg.hp_pins[0];
964 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200965
Takashi Iwaiad87c642009-11-02 14:23:15 +0100966 if (!nid)
967 return;
Wu Fengguang864f92b2009-11-18 12:38:02 +0800968 spec->jack_present = snd_hda_jack_detect(codec, nid);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200969 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
970 nid = spec->autocfg.speaker_pins[i];
971 if (!nid)
972 break;
973 snd_hda_codec_write(codec, nid, 0,
974 AC_VERB_SET_PIN_WIDGET_CONTROL,
975 spec->jack_present ? 0 : PIN_OUT);
976 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200977}
978
Takashi Iwai6c819492009-08-10 18:47:44 +0200979static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
980 hda_nid_t nid)
981{
982 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
983 int i, nums;
984
985 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
986 for (i = 0; i < nums; i++)
987 if (conn[i] == nid)
988 return i;
989 return -1;
990}
991
Kailang Yang7fb0d782008-10-15 11:12:35 +0200992static void alc_mic_automute(struct hda_codec *codec)
993{
994 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +0200995 struct alc_mic_route *dead, *alive;
996 unsigned int present, type;
997 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200998
Takashi Iwaib59bdf32009-08-11 09:47:30 +0200999 if (!spec->auto_mic)
1000 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001001 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1002 return;
1003 if (snd_BUG_ON(!spec->adc_nids))
1004 return;
1005
1006 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1007
Wu Fengguang864f92b2009-11-18 12:38:02 +08001008 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001009 if (present) {
1010 alive = &spec->ext_mic;
1011 dead = &spec->int_mic;
1012 } else {
1013 alive = &spec->int_mic;
1014 dead = &spec->ext_mic;
1015 }
1016
Takashi Iwai6c819492009-08-10 18:47:44 +02001017 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1018 if (type == AC_WID_AUD_MIX) {
1019 /* Matrix-mixer style (e.g. ALC882) */
1020 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1021 alive->mux_idx,
1022 HDA_AMP_MUTE, 0);
1023 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1024 dead->mux_idx,
1025 HDA_AMP_MUTE, HDA_AMP_MUTE);
1026 } else {
1027 /* MUX style (e.g. ALC880) */
1028 snd_hda_codec_write_cache(codec, cap_nid, 0,
1029 AC_VERB_SET_CONNECT_SEL,
1030 alive->mux_idx);
1031 }
1032
1033 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001034}
1035
Kailang Yangc9b58002007-10-16 14:30:01 +02001036/* unsolicited event for HP jack sensing */
1037static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1038{
1039 if (codec->vendor_id == 0x10ec0880)
1040 res >>= 28;
1041 else
1042 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001043 switch (res) {
1044 case ALC880_HP_EVENT:
1045 alc_automute_pin(codec);
1046 break;
1047 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001048 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001049 break;
1050 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001051}
1052
1053static void alc_inithook(struct hda_codec *codec)
1054{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001055 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001056 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001057}
1058
Kailang Yangf9423e72008-05-27 12:32:25 +02001059/* additional initialization for ALC888 variants */
1060static void alc888_coef_init(struct hda_codec *codec)
1061{
1062 unsigned int tmp;
1063
1064 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1065 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1066 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001067 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001068 /* alc888S-VC */
1069 snd_hda_codec_read(codec, 0x20, 0,
1070 AC_VERB_SET_PROC_COEF, 0x830);
1071 else
1072 /* alc888-VB */
1073 snd_hda_codec_read(codec, 0x20, 0,
1074 AC_VERB_SET_PROC_COEF, 0x3030);
1075}
1076
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001077static void alc889_coef_init(struct hda_codec *codec)
1078{
1079 unsigned int tmp;
1080
1081 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1082 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1083 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1084 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1085}
1086
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001087/* turn on/off EAPD control (only if available) */
1088static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1089{
1090 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1091 return;
1092 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1093 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1094 on ? 2 : 0);
1095}
1096
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001097static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001098{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001099 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001100
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001101 switch (type) {
1102 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001103 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1104 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001105 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001106 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1107 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001108 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001109 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1110 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001111 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001112 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001113 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001114 set_eapd(codec, 0x0f, 1);
1115 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001116 break;
1117 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001118 case 0x10ec0267:
1119 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001120 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001121 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001122 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001123 case 0x10ec0660:
1124 case 0x10ec0662:
1125 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001126 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001127 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001128 set_eapd(codec, 0x14, 1);
1129 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001130 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001131 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001132 switch (codec->vendor_id) {
1133 case 0x10ec0260:
1134 snd_hda_codec_write(codec, 0x1a, 0,
1135 AC_VERB_SET_COEF_INDEX, 7);
1136 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1137 AC_VERB_GET_PROC_COEF, 0);
1138 snd_hda_codec_write(codec, 0x1a, 0,
1139 AC_VERB_SET_COEF_INDEX, 7);
1140 snd_hda_codec_write(codec, 0x1a, 0,
1141 AC_VERB_SET_PROC_COEF,
1142 tmp | 0x2010);
1143 break;
1144 case 0x10ec0262:
1145 case 0x10ec0880:
1146 case 0x10ec0882:
1147 case 0x10ec0883:
1148 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001149 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001150 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001151 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001152 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001153 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001154 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001155 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001156#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001157 case 0x10ec0267:
1158 case 0x10ec0268:
1159 snd_hda_codec_write(codec, 0x20, 0,
1160 AC_VERB_SET_COEF_INDEX, 7);
1161 tmp = snd_hda_codec_read(codec, 0x20, 0,
1162 AC_VERB_GET_PROC_COEF, 0);
1163 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001164 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001165 snd_hda_codec_write(codec, 0x20, 0,
1166 AC_VERB_SET_PROC_COEF,
1167 tmp | 0x3000);
1168 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001169#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001170 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001171 break;
1172 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001173}
Kailang Yangea1fb292008-08-26 12:58:38 +02001174
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001175static void alc_init_auto_hp(struct hda_codec *codec)
1176{
1177 struct alc_spec *spec = codec->spec;
1178
1179 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001180 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001181
Kailang Yangc9b58002007-10-16 14:30:01 +02001182 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001183 if (spec->autocfg.line_out_pins[0] &&
1184 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001185 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001186 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001187 else
1188 return;
1189 }
1190
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001191 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1192 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001193 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1194 AC_VERB_SET_UNSOLICITED_ENABLE,
1195 AC_USRSP_EN | ALC880_HP_EVENT);
1196 spec->unsol_event = alc_sku_unsol_event;
1197}
1198
Takashi Iwai6c819492009-08-10 18:47:44 +02001199static void alc_init_auto_mic(struct hda_codec *codec)
1200{
1201 struct alc_spec *spec = codec->spec;
1202 struct auto_pin_cfg *cfg = &spec->autocfg;
1203 hda_nid_t fixed, ext;
1204 int i;
1205
1206 /* there must be only two mic inputs exclusively */
1207 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1208 if (cfg->input_pins[i])
1209 return;
1210
1211 fixed = ext = 0;
1212 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1213 hda_nid_t nid = cfg->input_pins[i];
1214 unsigned int defcfg;
1215 if (!nid)
1216 return;
1217 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1218 switch (get_defcfg_connect(defcfg)) {
1219 case AC_JACK_PORT_FIXED:
1220 if (fixed)
1221 return; /* already occupied */
1222 fixed = nid;
1223 break;
1224 case AC_JACK_PORT_COMPLEX:
1225 if (ext)
1226 return; /* already occupied */
1227 ext = nid;
1228 break;
1229 default:
1230 return; /* invalid entry */
1231 }
1232 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001233 if (!ext || !fixed)
1234 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001235 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1236 return; /* no unsol support */
1237 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1238 ext, fixed);
1239 spec->ext_mic.pin = ext;
1240 spec->int_mic.pin = fixed;
1241 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1242 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1243 spec->auto_mic = 1;
1244 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1245 AC_VERB_SET_UNSOLICITED_ENABLE,
1246 AC_USRSP_EN | ALC880_MIC_EVENT);
1247 spec->unsol_event = alc_sku_unsol_event;
1248}
1249
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001250/* check subsystem ID and set up device-specific initialization;
1251 * return 1 if initialized, 0 if invalid SSID
1252 */
1253/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1254 * 31 ~ 16 : Manufacture ID
1255 * 15 ~ 8 : SKU ID
1256 * 7 ~ 0 : Assembly ID
1257 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1258 */
1259static int alc_subsystem_id(struct hda_codec *codec,
1260 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001261 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001262{
1263 unsigned int ass, tmp, i;
1264 unsigned nid;
1265 struct alc_spec *spec = codec->spec;
1266
1267 ass = codec->subsystem_id & 0xffff;
1268 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1269 goto do_sku;
1270
1271 /* invalid SSID, check the special NID pin defcfg instead */
1272 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001273 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001274 * 29~21 : reserve
1275 * 20 : PCBEEP input
1276 * 19~16 : Check sum (15:1)
1277 * 15~1 : Custom
1278 * 0 : override
1279 */
1280 nid = 0x1d;
1281 if (codec->vendor_id == 0x10ec0260)
1282 nid = 0x17;
1283 ass = snd_hda_codec_get_pincfg(codec, nid);
1284 snd_printd("realtek: No valid SSID, "
1285 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001286 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001287 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001288 return 0;
1289 if ((ass >> 30) != 1) /* no physical connection */
1290 return 0;
1291
1292 /* check sum */
1293 tmp = 0;
1294 for (i = 1; i < 16; i++) {
1295 if ((ass >> i) & 1)
1296 tmp++;
1297 }
1298 if (((ass >> 16) & 0xf) != tmp)
1299 return 0;
1300do_sku:
1301 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1302 ass & 0xffff, codec->vendor_id);
1303 /*
1304 * 0 : override
1305 * 1 : Swap Jack
1306 * 2 : 0 --> Desktop, 1 --> Laptop
1307 * 3~5 : External Amplifier control
1308 * 7~6 : Reserved
1309 */
1310 tmp = (ass & 0x38) >> 3; /* external Amp control */
1311 switch (tmp) {
1312 case 1:
1313 spec->init_amp = ALC_INIT_GPIO1;
1314 break;
1315 case 3:
1316 spec->init_amp = ALC_INIT_GPIO2;
1317 break;
1318 case 7:
1319 spec->init_amp = ALC_INIT_GPIO3;
1320 break;
1321 case 5:
1322 spec->init_amp = ALC_INIT_DEFAULT;
1323 break;
1324 }
1325
1326 /* is laptop or Desktop and enable the function "Mute internal speaker
1327 * when the external headphone out jack is plugged"
1328 */
1329 if (!(ass & 0x8000))
1330 return 1;
1331 /*
1332 * 10~8 : Jack location
1333 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1334 * 14~13: Resvered
1335 * 15 : 1 --> enable the function "Mute internal speaker
1336 * when the external headphone out jack is plugged"
1337 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001338 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001339 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001340 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1341 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001342 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001343 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001344 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001345 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001346 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001347 else if (tmp == 3)
1348 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001349 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001350 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001351 for (i = 0; i < spec->autocfg.line_outs; i++)
1352 if (spec->autocfg.line_out_pins[i] == nid)
1353 return 1;
1354 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001355 }
1356
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001357 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001358 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001359 return 1;
1360}
Kailang Yangea1fb292008-08-26 12:58:38 +02001361
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001362static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001363 hda_nid_t porta, hda_nid_t porte,
1364 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001365{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001366 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001367 struct alc_spec *spec = codec->spec;
1368 snd_printd("realtek: "
1369 "Enable default setup for auto mode as fallback\n");
1370 spec->init_amp = ALC_INIT_DEFAULT;
1371 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001372 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001373 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001374}
1375
Takashi Iwai41e41f12005-06-08 14:48:49 +02001376/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001377 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001378 */
1379
1380struct alc_pincfg {
1381 hda_nid_t nid;
1382 u32 val;
1383};
1384
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001385struct alc_fixup {
1386 const struct alc_pincfg *pins;
1387 const struct hda_verb *verbs;
1388};
1389
1390static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001391 const struct snd_pci_quirk *quirk,
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001392 const struct alc_fixup *fix)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001393{
1394 const struct alc_pincfg *cfg;
1395
1396 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1397 if (!quirk)
1398 return;
1399
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001400 fix += quirk->value;
1401 cfg = fix->pins;
1402 if (cfg) {
1403 for (; cfg->nid; cfg++)
1404 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1405 }
1406 if (fix->verbs)
1407 add_verb(codec->spec, fix->verbs);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001408}
1409
Kailang Yang274693f2009-12-03 10:07:50 +01001410static int alc_read_coef_idx(struct hda_codec *codec,
1411 unsigned int coef_idx)
1412{
1413 unsigned int val;
1414 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1415 coef_idx);
1416 val = snd_hda_codec_read(codec, 0x20, 0,
1417 AC_VERB_GET_PROC_COEF, 0);
1418 return val;
1419}
1420
Takashi Iwaif95474e2007-07-10 00:47:43 +02001421/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001422 * ALC888
1423 */
1424
1425/*
1426 * 2ch mode
1427 */
1428static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1429/* Mic-in jack as mic in */
1430 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1431 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1432/* Line-in jack as Line in */
1433 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1434 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1435/* Line-Out as Front */
1436 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1437 { } /* end */
1438};
1439
1440/*
1441 * 4ch mode
1442 */
1443static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1444/* Mic-in jack as mic in */
1445 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1446 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1447/* Line-in jack as Surround */
1448 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1449 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1450/* Line-Out as Front */
1451 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1452 { } /* end */
1453};
1454
1455/*
1456 * 6ch mode
1457 */
1458static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1459/* Mic-in jack as CLFE */
1460 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1461 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1462/* Line-in jack as Surround */
1463 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1464 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1465/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1466 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1467 { } /* end */
1468};
1469
1470/*
1471 * 8ch mode
1472 */
1473static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1474/* Mic-in jack as CLFE */
1475 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1476 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1477/* Line-in jack as Surround */
1478 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1479 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1480/* Line-Out as Side */
1481 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1482 { } /* end */
1483};
1484
1485static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1486 { 2, alc888_4ST_ch2_intel_init },
1487 { 4, alc888_4ST_ch4_intel_init },
1488 { 6, alc888_4ST_ch6_intel_init },
1489 { 8, alc888_4ST_ch8_intel_init },
1490};
1491
1492/*
1493 * ALC888 Fujitsu Siemens Amillo xa3530
1494 */
1495
1496static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1497/* Front Mic: set to PIN_IN (empty by default) */
1498 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1499/* Connect Internal HP to Front */
1500 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1501 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1502 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1503/* Connect Bass HP to Front */
1504 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1505 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1506 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1507/* Connect Line-Out side jack (SPDIF) to Side */
1508 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1509 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1510 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1511/* Connect Mic jack to CLFE */
1512 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1513 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1514 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1515/* Connect Line-in jack to Surround */
1516 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1517 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1518 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1519/* Connect HP out jack to Front */
1520 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1521 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1522 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1523/* Enable unsolicited event for HP jack and Line-out jack */
1524 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1525 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1526 {}
1527};
1528
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001529static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001530{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001531 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001532 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001533 hda_nid_t nid;
1534 int i;
1535
1536 spec->jack_present = 0;
1537 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1538 nid = spec->autocfg.hp_pins[i];
1539 if (!nid)
1540 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001541 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001542 spec->jack_present = 1;
1543 break;
1544 }
1545 }
1546
1547 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001548 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001549 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1550 nid = spec->autocfg.speaker_pins[i];
1551 if (!nid)
1552 break;
1553 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1554 HDA_AMP_MUTE, mute);
1555 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001556}
1557
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001558static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1559 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001560{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001561 if (codec->vendor_id == 0x10ec0880)
1562 res >>= 28;
1563 else
1564 res >>= 26;
1565 if (res == ALC880_HP_EVENT)
1566 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001567}
1568
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001569static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001570{
1571 struct alc_spec *spec = codec->spec;
1572
1573 spec->autocfg.hp_pins[0] = 0x15;
1574 spec->autocfg.speaker_pins[0] = 0x14;
1575 spec->autocfg.speaker_pins[1] = 0x16;
1576 spec->autocfg.speaker_pins[2] = 0x17;
1577 spec->autocfg.speaker_pins[3] = 0x19;
1578 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001579}
1580
1581static void alc889_intel_init_hook(struct hda_codec *codec)
1582{
1583 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001584 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001585}
1586
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001587static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001588{
1589 struct alc_spec *spec = codec->spec;
1590
1591 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1592 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1593 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1594 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001595}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001596
1597/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001598 * ALC888 Acer Aspire 4930G model
1599 */
1600
1601static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1602/* Front Mic: set to PIN_IN (empty by default) */
1603 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1604/* Unselect Front Mic by default in input mixer 3 */
1605 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001606/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001607 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1608/* Connect Internal HP to front */
1609 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1610 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1611 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1612/* Connect HP out to front */
1613 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1614 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1615 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1616 { }
1617};
1618
Hector Martin3b315d72009-06-02 10:54:19 +02001619/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001620 * ALC888 Acer Aspire 6530G model
1621 */
1622
1623static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1624/* Bias voltage on for external mic port */
1625 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001626/* Front Mic: set to PIN_IN (empty by default) */
1627 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1628/* Unselect Front Mic by default in input mixer 3 */
1629 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001630/* Enable unsolicited event for HP jack */
1631 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1632/* Enable speaker output */
1633 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1634 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1635/* Enable headphone output */
1636 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1637 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1638 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1639 { }
1640};
1641
1642/*
Hector Martin018df412009-06-04 00:13:40 +02001643 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001644 */
1645
Hector Martin018df412009-06-04 00:13:40 +02001646static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001647/* Front Mic: set to PIN_IN (empty by default) */
1648 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1649/* Unselect Front Mic by default in input mixer 3 */
1650 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1651/* Enable unsolicited event for HP jack */
1652 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1653/* Connect Internal Front to Front */
1654 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1655 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1656 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1657/* Connect Internal Rear to Rear */
1658 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1659 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1660 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1661/* Connect Internal CLFE to CLFE */
1662 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1663 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1664 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1665/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001666 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001667 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1668 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1669/* Enable all DACs */
1670/* DAC DISABLE/MUTE 1? */
1671/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1672 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1673 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1674/* DAC DISABLE/MUTE 2? */
1675/* some bit here disables the other DACs. Init=0x4900 */
1676 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1677 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02001678/* DMIC fix
1679 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1680 * which makes the stereo useless. However, either the mic or the ALC889
1681 * makes the signal become a difference/sum signal instead of standard
1682 * stereo, which is annoying. So instead we flip this bit which makes the
1683 * codec replicate the sum signal to both channels, turning it into a
1684 * normal mono mic.
1685 */
1686/* DMIC_CONTROL? Init value = 0x0001 */
1687 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1688 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001689 { }
1690};
1691
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001692static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001693 /* Front mic only available on one ADC */
1694 {
1695 .num_items = 4,
1696 .items = {
1697 { "Mic", 0x0 },
1698 { "Line", 0x2 },
1699 { "CD", 0x4 },
1700 { "Front Mic", 0xb },
1701 },
1702 },
1703 {
1704 .num_items = 3,
1705 .items = {
1706 { "Mic", 0x0 },
1707 { "Line", 0x2 },
1708 { "CD", 0x4 },
1709 },
1710 }
1711};
1712
Tony Vroond2fd4b02009-06-21 00:40:10 +01001713static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1714 /* Interal mic only available on one ADC */
1715 {
Tony Vroon684a8842009-06-26 09:27:50 +01001716 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001717 .items = {
1718 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001719 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001720 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001721 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001722 { "Int Mic", 0xb },
1723 },
1724 },
1725 {
Tony Vroon684a8842009-06-26 09:27:50 +01001726 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001727 .items = {
1728 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001729 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001730 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001731 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001732 },
1733 }
1734};
1735
Hector Martin018df412009-06-04 00:13:40 +02001736static struct hda_input_mux alc889_capture_sources[3] = {
1737 /* Digital mic only available on first "ADC" */
1738 {
1739 .num_items = 5,
1740 .items = {
1741 { "Mic", 0x0 },
1742 { "Line", 0x2 },
1743 { "CD", 0x4 },
1744 { "Front Mic", 0xb },
1745 { "Input Mix", 0xa },
1746 },
1747 },
1748 {
1749 .num_items = 4,
1750 .items = {
1751 { "Mic", 0x0 },
1752 { "Line", 0x2 },
1753 { "CD", 0x4 },
1754 { "Input Mix", 0xa },
1755 },
1756 },
1757 {
1758 .num_items = 4,
1759 .items = {
1760 { "Mic", 0x0 },
1761 { "Line", 0x2 },
1762 { "CD", 0x4 },
1763 { "Input Mix", 0xa },
1764 },
1765 }
1766};
1767
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001768static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001769 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1770 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1771 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1772 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1773 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1774 HDA_OUTPUT),
1775 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1776 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1777 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1778 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1779 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1780 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1781 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1782 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1783 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1784 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1785 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1786 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001787 { } /* end */
1788};
1789
Hector Martin556eea92009-12-20 22:51:23 +01001790static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1791 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1792 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1793 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1794 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1795 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1796 HDA_OUTPUT),
1797 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1798 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1799 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1800 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1801 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1802 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1803 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1805 { } /* end */
1806};
1807
1808
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001809static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001810{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001811 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001812
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001813 spec->autocfg.hp_pins[0] = 0x15;
1814 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01001815 spec->autocfg.speaker_pins[1] = 0x16;
1816 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001817}
1818
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001819static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001820{
1821 struct alc_spec *spec = codec->spec;
1822
1823 spec->autocfg.hp_pins[0] = 0x15;
1824 spec->autocfg.speaker_pins[0] = 0x14;
1825 spec->autocfg.speaker_pins[1] = 0x16;
1826 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001827}
1828
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001829static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001830{
1831 struct alc_spec *spec = codec->spec;
1832
1833 spec->autocfg.hp_pins[0] = 0x15;
1834 spec->autocfg.speaker_pins[0] = 0x14;
1835 spec->autocfg.speaker_pins[1] = 0x16;
1836 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001837}
1838
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001839/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001840 * ALC880 3-stack model
1841 *
1842 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001843 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1844 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001845 */
1846
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001847static hda_nid_t alc880_dac_nids[4] = {
1848 /* front, rear, clfe, rear_surr */
1849 0x02, 0x05, 0x04, 0x03
1850};
1851
1852static hda_nid_t alc880_adc_nids[3] = {
1853 /* ADC0-2 */
1854 0x07, 0x08, 0x09,
1855};
1856
1857/* The datasheet says the node 0x07 is connected from inputs,
1858 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001859 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001860 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001861static hda_nid_t alc880_adc_nids_alt[2] = {
1862 /* ADC1-2 */
1863 0x08, 0x09,
1864};
1865
1866#define ALC880_DIGOUT_NID 0x06
1867#define ALC880_DIGIN_NID 0x0a
1868
1869static struct hda_input_mux alc880_capture_source = {
1870 .num_items = 4,
1871 .items = {
1872 { "Mic", 0x0 },
1873 { "Front Mic", 0x3 },
1874 { "Line", 0x2 },
1875 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001876 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001877};
1878
1879/* channel source setting (2/6 channel selection for 3-stack) */
1880/* 2ch mode */
1881static struct hda_verb alc880_threestack_ch2_init[] = {
1882 /* set line-in to input, mute it */
1883 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1884 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1885 /* set mic-in to input vref 80%, mute it */
1886 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1887 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001888 { } /* end */
1889};
1890
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001891/* 6ch mode */
1892static struct hda_verb alc880_threestack_ch6_init[] = {
1893 /* set line-in to output, unmute it */
1894 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1895 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1896 /* set mic-in to output, unmute it */
1897 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1898 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1899 { } /* end */
1900};
1901
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001902static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001903 { 2, alc880_threestack_ch2_init },
1904 { 6, alc880_threestack_ch6_init },
1905};
1906
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001907static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001908 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001909 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001910 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001911 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001912 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1913 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001914 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1915 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001916 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1917 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1918 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1919 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1920 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1922 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1923 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001924 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001925 {
1926 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1927 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001928 .info = alc_ch_mode_info,
1929 .get = alc_ch_mode_get,
1930 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001931 },
1932 { } /* end */
1933};
1934
1935/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001936static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1937 struct snd_ctl_elem_info *uinfo)
1938{
1939 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1940 struct alc_spec *spec = codec->spec;
1941 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001942
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001943 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001944 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1945 HDA_INPUT);
1946 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001947 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001948 return err;
1949}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001950
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001951static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1952 unsigned int size, unsigned int __user *tlv)
1953{
1954 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1955 struct alc_spec *spec = codec->spec;
1956 int err;
1957
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001958 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001959 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1960 HDA_INPUT);
1961 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001962 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001963 return err;
1964}
1965
1966typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1967 struct snd_ctl_elem_value *ucontrol);
1968
1969static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1970 struct snd_ctl_elem_value *ucontrol,
1971 getput_call_t func)
1972{
1973 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1974 struct alc_spec *spec = codec->spec;
1975 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1976 int err;
1977
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001978 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001979 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1980 3, 0, HDA_INPUT);
1981 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001982 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001983 return err;
1984}
1985
1986static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1987 struct snd_ctl_elem_value *ucontrol)
1988{
1989 return alc_cap_getput_caller(kcontrol, ucontrol,
1990 snd_hda_mixer_amp_volume_get);
1991}
1992
1993static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1994 struct snd_ctl_elem_value *ucontrol)
1995{
1996 return alc_cap_getput_caller(kcontrol, ucontrol,
1997 snd_hda_mixer_amp_volume_put);
1998}
1999
2000/* capture mixer elements */
2001#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2002
2003static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2004 struct snd_ctl_elem_value *ucontrol)
2005{
2006 return alc_cap_getput_caller(kcontrol, ucontrol,
2007 snd_hda_mixer_amp_switch_get);
2008}
2009
2010static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2011 struct snd_ctl_elem_value *ucontrol)
2012{
2013 return alc_cap_getput_caller(kcontrol, ucontrol,
2014 snd_hda_mixer_amp_switch_put);
2015}
2016
Takashi Iwaia23b6882009-03-23 15:21:36 +01002017#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002018 { \
2019 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2020 .name = "Capture Switch", \
2021 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2022 .count = num, \
2023 .info = alc_cap_sw_info, \
2024 .get = alc_cap_sw_get, \
2025 .put = alc_cap_sw_put, \
2026 }, \
2027 { \
2028 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2029 .name = "Capture Volume", \
2030 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2031 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2032 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2033 .count = num, \
2034 .info = alc_cap_vol_info, \
2035 .get = alc_cap_vol_get, \
2036 .put = alc_cap_vol_put, \
2037 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002038 }
2039
2040#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002041 { \
2042 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2043 /* .name = "Capture Source", */ \
2044 .name = "Input Source", \
2045 .count = num, \
2046 .info = alc_mux_enum_info, \
2047 .get = alc_mux_enum_get, \
2048 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002049 }
2050
2051#define DEFINE_CAPMIX(num) \
2052static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2053 _DEFINE_CAPMIX(num), \
2054 _DEFINE_CAPSRC(num), \
2055 { } /* end */ \
2056}
2057
2058#define DEFINE_CAPMIX_NOSRC(num) \
2059static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2060 _DEFINE_CAPMIX(num), \
2061 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002062}
2063
2064/* up to three ADCs */
2065DEFINE_CAPMIX(1);
2066DEFINE_CAPMIX(2);
2067DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002068DEFINE_CAPMIX_NOSRC(1);
2069DEFINE_CAPMIX_NOSRC(2);
2070DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002071
2072/*
2073 * ALC880 5-stack model
2074 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002075 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2076 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002077 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2078 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2079 */
2080
2081/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002082static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002083 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002084 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085 { } /* end */
2086};
2087
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002088/* channel source setting (6/8 channel selection for 5-stack) */
2089/* 6ch mode */
2090static struct hda_verb alc880_fivestack_ch6_init[] = {
2091 /* set line-in to input, mute it */
2092 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2093 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002094 { } /* end */
2095};
2096
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002097/* 8ch mode */
2098static struct hda_verb alc880_fivestack_ch8_init[] = {
2099 /* set line-in to output, unmute it */
2100 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2101 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2102 { } /* end */
2103};
2104
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002105static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002106 { 6, alc880_fivestack_ch6_init },
2107 { 8, alc880_fivestack_ch8_init },
2108};
2109
2110
2111/*
2112 * ALC880 6-stack model
2113 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002114 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2115 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002116 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2117 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2118 */
2119
2120static hda_nid_t alc880_6st_dac_nids[4] = {
2121 /* front, rear, clfe, rear_surr */
2122 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002123};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002124
2125static struct hda_input_mux alc880_6stack_capture_source = {
2126 .num_items = 4,
2127 .items = {
2128 { "Mic", 0x0 },
2129 { "Front Mic", 0x1 },
2130 { "Line", 0x2 },
2131 { "CD", 0x4 },
2132 },
2133};
2134
2135/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002136static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002137 { 8, NULL },
2138};
2139
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002140static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002141 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002142 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002143 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002144 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002145 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2146 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002147 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2148 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002149 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002150 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002151 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2152 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2153 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2154 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2155 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2156 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2157 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2158 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002159 {
2160 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2161 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002162 .info = alc_ch_mode_info,
2163 .get = alc_ch_mode_get,
2164 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002165 },
2166 { } /* end */
2167};
2168
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002169
2170/*
2171 * ALC880 W810 model
2172 *
2173 * W810 has rear IO for:
2174 * Front (DAC 02)
2175 * Surround (DAC 03)
2176 * Center/LFE (DAC 04)
2177 * Digital out (06)
2178 *
2179 * The system also has a pair of internal speakers, and a headphone jack.
2180 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002181 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002182 * There is a variable resistor to control the speaker or headphone
2183 * volume. This is a hardware-only device without a software API.
2184 *
2185 * Plugging headphones in will disable the internal speakers. This is
2186 * implemented in hardware, not via the driver using jack sense. In
2187 * a similar fashion, plugging into the rear socket marked "front" will
2188 * disable both the speakers and headphones.
2189 *
2190 * For input, there's a microphone jack, and an "audio in" jack.
2191 * These may not do anything useful with this driver yet, because I
2192 * haven't setup any initialization verbs for these yet...
2193 */
2194
2195static hda_nid_t alc880_w810_dac_nids[3] = {
2196 /* front, rear/surround, clfe */
2197 0x02, 0x03, 0x04
2198};
2199
2200/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002201static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002202 { 6, NULL }
2203};
2204
2205/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002206static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002207 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002208 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002209 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002210 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002211 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2212 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002213 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2214 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002215 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2216 { } /* end */
2217};
2218
2219
2220/*
2221 * Z710V model
2222 *
2223 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002224 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2225 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002226 */
2227
2228static hda_nid_t alc880_z71v_dac_nids[1] = {
2229 0x02
2230};
2231#define ALC880_Z71V_HP_DAC 0x03
2232
2233/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002234static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002235 { 2, NULL }
2236};
2237
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002238static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002239 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002240 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002241 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002242 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002243 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2244 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2245 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2246 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2247 { } /* end */
2248};
2249
2250
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002251/*
2252 * ALC880 F1734 model
2253 *
2254 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2255 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2256 */
2257
2258static hda_nid_t alc880_f1734_dac_nids[1] = {
2259 0x03
2260};
2261#define ALC880_F1734_HP_DAC 0x02
2262
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002263static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002264 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002265 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002266 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2267 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002268 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2269 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002270 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2271 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002272 { } /* end */
2273};
2274
Takashi Iwai937b4162008-02-11 14:52:36 +01002275static struct hda_input_mux alc880_f1734_capture_source = {
2276 .num_items = 2,
2277 .items = {
2278 { "Mic", 0x1 },
2279 { "CD", 0x4 },
2280 },
2281};
2282
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002283
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002284/*
2285 * ALC880 ASUS model
2286 *
2287 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2288 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2289 * Mic = 0x18, Line = 0x1a
2290 */
2291
2292#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2293#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2294
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002295static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002296 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002297 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002298 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002299 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002300 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2301 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002302 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2303 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002304 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2305 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2306 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2307 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2308 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2309 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002310 {
2311 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2312 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002313 .info = alc_ch_mode_info,
2314 .get = alc_ch_mode_get,
2315 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002316 },
2317 { } /* end */
2318};
2319
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002320/*
2321 * ALC880 ASUS W1V model
2322 *
2323 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2324 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2325 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2326 */
2327
2328/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002329static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002330 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2331 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002332 { } /* end */
2333};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002334
Kailang Yangdf694da2005-12-05 19:42:22 +01002335/* TCL S700 */
2336static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2337 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2338 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2339 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2340 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2341 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2342 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2343 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2344 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2345 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002346 { } /* end */
2347};
2348
Kailang Yangccc656c2006-10-17 12:32:26 +02002349/* Uniwill */
2350static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002351 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2352 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2353 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2354 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002355 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2356 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2357 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2358 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2359 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2360 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2361 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2362 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2363 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2364 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2365 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2366 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002367 {
2368 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2369 .name = "Channel Mode",
2370 .info = alc_ch_mode_info,
2371 .get = alc_ch_mode_get,
2372 .put = alc_ch_mode_put,
2373 },
2374 { } /* end */
2375};
2376
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002377static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2378 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2379 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2380 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2381 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2382 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2383 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2384 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2385 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2386 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2387 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2388 { } /* end */
2389};
2390
Kailang Yangccc656c2006-10-17 12:32:26 +02002391static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002392 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2393 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2394 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2395 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002396 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2397 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2398 { } /* end */
2399};
2400
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002402 * virtual master controls
2403 */
2404
2405/*
2406 * slave controls for virtual master
2407 */
2408static const char *alc_slave_vols[] = {
2409 "Front Playback Volume",
2410 "Surround Playback Volume",
2411 "Center Playback Volume",
2412 "LFE Playback Volume",
2413 "Side Playback Volume",
2414 "Headphone Playback Volume",
2415 "Speaker Playback Volume",
2416 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002417 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002418 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002419 NULL,
2420};
2421
2422static const char *alc_slave_sws[] = {
2423 "Front Playback Switch",
2424 "Surround Playback Switch",
2425 "Center Playback Switch",
2426 "LFE Playback Switch",
2427 "Side Playback Switch",
2428 "Headphone Playback Switch",
2429 "Speaker Playback Switch",
2430 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002431 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002432 "Line-Out Playback Switch",
2433 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002434 NULL,
2435};
2436
2437/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002438 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002440
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002441#define NID_MAPPING (-1)
2442
2443#define SUBDEV_SPEAKER_ (0 << 6)
2444#define SUBDEV_HP_ (1 << 6)
2445#define SUBDEV_LINE_ (2 << 6)
2446#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2447#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2448#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2449
Takashi Iwai603c4012008-07-30 15:01:44 +02002450static void alc_free_kctls(struct hda_codec *codec);
2451
Takashi Iwai67d634c2009-11-16 15:35:59 +01002452#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002453/* additional beep mixers; the actual parameters are overwritten at build */
2454static struct snd_kcontrol_new alc_beep_mixer[] = {
2455 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002456 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002457 { } /* end */
2458};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002459#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002460
Linus Torvalds1da177e2005-04-16 15:20:36 -07002461static int alc_build_controls(struct hda_codec *codec)
2462{
2463 struct alc_spec *spec = codec->spec;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002464 struct snd_kcontrol *kctl;
2465 struct snd_kcontrol_new *knew;
2466 int i, j, err;
2467 unsigned int u;
2468 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002469
2470 for (i = 0; i < spec->num_mixers; i++) {
2471 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2472 if (err < 0)
2473 return err;
2474 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002475 if (spec->cap_mixer) {
2476 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2477 if (err < 0)
2478 return err;
2479 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002480 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002481 err = snd_hda_create_spdif_out_ctls(codec,
2482 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002483 if (err < 0)
2484 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002485 if (!spec->no_analog) {
2486 err = snd_hda_create_spdif_share_sw(codec,
2487 &spec->multiout);
2488 if (err < 0)
2489 return err;
2490 spec->multiout.share_spdif = 1;
2491 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002492 }
2493 if (spec->dig_in_nid) {
2494 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2495 if (err < 0)
2496 return err;
2497 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002498
Takashi Iwai67d634c2009-11-16 15:35:59 +01002499#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002500 /* create beep controls if needed */
2501 if (spec->beep_amp) {
2502 struct snd_kcontrol_new *knew;
2503 for (knew = alc_beep_mixer; knew->name; knew++) {
2504 struct snd_kcontrol *kctl;
2505 kctl = snd_ctl_new1(knew, codec);
2506 if (!kctl)
2507 return -ENOMEM;
2508 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002509 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002510 if (err < 0)
2511 return err;
2512 }
2513 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002514#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002515
Takashi Iwai2134ea42008-01-10 16:53:55 +01002516 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002517 if (!spec->no_analog &&
2518 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002519 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002520 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002521 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002522 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002523 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002524 if (err < 0)
2525 return err;
2526 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002527 if (!spec->no_analog &&
2528 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002529 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2530 NULL, alc_slave_sws);
2531 if (err < 0)
2532 return err;
2533 }
2534
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002535 /* assign Capture Source enums to NID */
2536 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2537 if (!kctl)
2538 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2539 for (i = 0; kctl && i < kctl->count; i++) {
Takashi Iwaid1409ae2009-12-17 15:01:31 +01002540 hda_nid_t *nids = spec->capsrc_nids;
2541 if (!nids)
2542 nids = spec->adc_nids;
Takashi Iwai21949f02009-12-23 08:31:59 +01002543 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002544 if (err < 0)
2545 return err;
2546 }
2547 if (spec->cap_mixer) {
2548 const char *kname = kctl ? kctl->id.name : NULL;
2549 for (knew = spec->cap_mixer; knew->name; knew++) {
2550 if (kname && strcmp(knew->name, kname) == 0)
2551 continue;
2552 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2553 for (i = 0; kctl && i < kctl->count; i++) {
2554 err = snd_hda_add_nid(codec, kctl, i,
2555 spec->adc_nids[i]);
2556 if (err < 0)
2557 return err;
2558 }
2559 }
2560 }
2561
2562 /* other nid->control mapping */
2563 for (i = 0; i < spec->num_mixers; i++) {
2564 for (knew = spec->mixers[i]; knew->name; knew++) {
2565 if (knew->iface != NID_MAPPING)
2566 continue;
2567 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2568 if (kctl == NULL)
2569 continue;
2570 u = knew->subdevice;
2571 for (j = 0; j < 4; j++, u >>= 8) {
2572 nid = u & 0x3f;
2573 if (nid == 0)
2574 continue;
2575 switch (u & 0xc0) {
2576 case SUBDEV_SPEAKER_:
2577 nid = spec->autocfg.speaker_pins[nid];
2578 break;
2579 case SUBDEV_LINE_:
2580 nid = spec->autocfg.line_out_pins[nid];
2581 break;
2582 case SUBDEV_HP_:
2583 nid = spec->autocfg.hp_pins[nid];
2584 break;
2585 default:
2586 continue;
2587 }
2588 err = snd_hda_add_nid(codec, kctl, 0, nid);
2589 if (err < 0)
2590 return err;
2591 }
2592 u = knew->private_value;
2593 for (j = 0; j < 4; j++, u >>= 8) {
2594 nid = u & 0xff;
2595 if (nid == 0)
2596 continue;
2597 err = snd_hda_add_nid(codec, kctl, 0, nid);
2598 if (err < 0)
2599 return err;
2600 }
2601 }
2602 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01002603
2604 alc_free_kctls(codec); /* no longer needed */
2605
Linus Torvalds1da177e2005-04-16 15:20:36 -07002606 return 0;
2607}
2608
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002609
Linus Torvalds1da177e2005-04-16 15:20:36 -07002610/*
2611 * initialize the codec volumes, etc
2612 */
2613
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002614/*
2615 * generic initialization of ADC, input mixers and output mixers
2616 */
2617static struct hda_verb alc880_volume_init_verbs[] = {
2618 /*
2619 * Unmute ADC0-2 and set the default input to mic-in
2620 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002621 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002622 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002623 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002624 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002625 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002626 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002627
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002628 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2629 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002630 * Note: PASD motherboards uses the Line In 2 as the input for front
2631 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002632 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002633 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002634 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2635 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2636 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2637 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2638 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002641
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002642 /*
2643 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002644 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002645 /* set vol=0 to output mixers */
2646 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2647 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2648 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2649 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2650 /* set up input amps for analog loopback */
2651 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002652 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2653 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002654 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2655 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002656 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2657 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002658 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2659 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002660
2661 { }
2662};
2663
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002664/*
2665 * 3-stack pin configuration:
2666 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2667 */
2668static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2669 /*
2670 * preset connection lists of input pins
2671 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2672 */
2673 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2674 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2675 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2676
2677 /*
2678 * Set pin mode and muting
2679 */
2680 /* set front pin widgets 0x14 for output */
2681 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2682 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2683 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2684 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2685 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2686 /* Mic2 (as headphone out) for HP output */
2687 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2688 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2689 /* Line In pin widget for input */
2690 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2692 /* Line2 (as front mic) pin widget for input and vref at 80% */
2693 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2694 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2695 /* CD pin widget for input */
2696 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2697
2698 { }
2699};
2700
2701/*
2702 * 5-stack pin configuration:
2703 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2704 * line-in/side = 0x1a, f-mic = 0x1b
2705 */
2706static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2707 /*
2708 * preset connection lists of input pins
2709 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2710 */
2711 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2712 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2713
2714 /*
2715 * Set pin mode and muting
2716 */
2717 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002718 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2719 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2720 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2721 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002722 /* unmute pins for output (no gain on this amp) */
2723 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2724 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2725 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2726 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2727
Linus Torvalds1da177e2005-04-16 15:20:36 -07002728 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002729 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002730 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2731 /* Mic2 (as headphone out) for HP output */
2732 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002733 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002734 /* Line In pin widget for input */
2735 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2736 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2737 /* Line2 (as front mic) pin widget for input and vref at 80% */
2738 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2739 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2740 /* CD pin widget for input */
2741 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002742
2743 { }
2744};
2745
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002746/*
2747 * W810 pin configuration:
2748 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2749 */
2750static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002751 /* hphone/speaker input selector: front DAC */
2752 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2753
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002754 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2755 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2756 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2757 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2758 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2759 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2760
2761 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002762 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002763
Linus Torvalds1da177e2005-04-16 15:20:36 -07002764 { }
2765};
2766
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002767/*
2768 * Z71V pin configuration:
2769 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2770 */
2771static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002772 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002773 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002774 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002775 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002776
Takashi Iwai16ded522005-06-10 19:58:24 +02002777 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002778 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002779 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002780 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002781
2782 { }
2783};
2784
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002785/*
2786 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002787 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2788 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002789 */
2790static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2791 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2792
Takashi Iwai16ded522005-06-10 19:58:24 +02002793 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002794 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002795 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002796 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002797 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002798 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002799 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002800 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2801
Takashi Iwai16ded522005-06-10 19:58:24 +02002802 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002803 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002804 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002805 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002806 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002807 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002808 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002809 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002810 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002811
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002812 { }
2813};
Takashi Iwai16ded522005-06-10 19:58:24 +02002814
Kailang Yangccc656c2006-10-17 12:32:26 +02002815/*
2816 * Uniwill pin configuration:
2817 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2818 * line = 0x1a
2819 */
2820static struct hda_verb alc880_uniwill_init_verbs[] = {
2821 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2822
2823 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2824 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2825 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2826 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2827 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2828 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2829 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2830 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2831 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2832 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2833 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2834 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2835 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2836 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2837
2838 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2839 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2840 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2841 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2842 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2843 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2844 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2845 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2846 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2847
2848 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2849 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2850
2851 { }
2852};
2853
2854/*
2855* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002856* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002857 */
2858static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2859 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2860
2861 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2862 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2863 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2865 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2866 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2867 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2868 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2869 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2870 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2871 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2872 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2873
2874 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2875 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2876 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2877 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2878 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2879 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2880
2881 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2882 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2883
2884 { }
2885};
2886
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002887static struct hda_verb alc880_beep_init_verbs[] = {
2888 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2889 { }
2890};
2891
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002892/* auto-toggle front mic */
2893static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2894{
2895 unsigned int present;
2896 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002897
Wu Fengguang864f92b2009-11-18 12:38:02 +08002898 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002899 bits = present ? HDA_AMP_MUTE : 0;
2900 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002901}
2902
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002903static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002904{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002905 struct alc_spec *spec = codec->spec;
2906
2907 spec->autocfg.hp_pins[0] = 0x14;
2908 spec->autocfg.speaker_pins[0] = 0x15;
2909 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002910}
2911
2912static void alc880_uniwill_init_hook(struct hda_codec *codec)
2913{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002914 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002915 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002916}
2917
2918static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2919 unsigned int res)
2920{
2921 /* Looks like the unsol event is incompatible with the standard
2922 * definition. 4bit tag is placed at 28 bit!
2923 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002924 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002925 case ALC880_MIC_EVENT:
2926 alc880_uniwill_mic_automute(codec);
2927 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002928 default:
2929 alc_automute_amp_unsol_event(codec, res);
2930 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002931 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002932}
2933
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002934static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002935{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002936 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002937
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002938 spec->autocfg.hp_pins[0] = 0x14;
2939 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002940}
2941
2942static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2943{
2944 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002945
Kailang Yangccc656c2006-10-17 12:32:26 +02002946 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002947 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2948 present &= HDA_AMP_VOLMASK;
2949 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2950 HDA_AMP_VOLMASK, present);
2951 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2952 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002953}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002954
Kailang Yangccc656c2006-10-17 12:32:26 +02002955static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2956 unsigned int res)
2957{
2958 /* Looks like the unsol event is incompatible with the standard
2959 * definition. 4bit tag is placed at 28 bit!
2960 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002961 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002962 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002963 else
2964 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002965}
2966
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002967/*
2968 * F1734 pin configuration:
2969 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2970 */
2971static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002972 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002973 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2974 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2975 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2976 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2977
2978 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2979 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2980 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2981 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2982
2983 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2984 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002985 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002986 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2987 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2988 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2989 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2990 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2991 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002992
Takashi Iwai937b4162008-02-11 14:52:36 +01002993 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2994 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2995
Takashi Iwai16ded522005-06-10 19:58:24 +02002996 { }
2997};
2998
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002999/*
3000 * ASUS pin configuration:
3001 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3002 */
3003static struct hda_verb alc880_pin_asus_init_verbs[] = {
3004 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3005 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3006 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3007 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3008
3009 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3010 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3011 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3012 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3013 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3014 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3015 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3016 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3017
3018 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3019 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3020 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3021 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3022 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3023 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3024 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3025 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3026 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003027
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003028 { }
3029};
3030
3031/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003032#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3033#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003034#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003035
Kailang Yangdf694da2005-12-05 19:42:22 +01003036/* Clevo m520g init */
3037static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3038 /* headphone output */
3039 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3040 /* line-out */
3041 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3042 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3043 /* Line-in */
3044 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3045 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3046 /* CD */
3047 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3048 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3049 /* Mic1 (rear panel) */
3050 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3051 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3052 /* Mic2 (front panel) */
3053 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3054 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3055 /* headphone */
3056 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3057 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3058 /* change to EAPD mode */
3059 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3060 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3061
3062 { }
3063};
3064
3065static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003066 /* change to EAPD mode */
3067 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3068 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3069
Kailang Yangdf694da2005-12-05 19:42:22 +01003070 /* Headphone output */
3071 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3072 /* Front output*/
3073 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3074 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3075
3076 /* Line In pin widget for input */
3077 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3078 /* CD pin widget for input */
3079 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3080 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3081 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3082
3083 /* change to EAPD mode */
3084 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3085 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3086
3087 { }
3088};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003089
3090/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003091 * LG m1 express dual
3092 *
3093 * Pin assignment:
3094 * Rear Line-In/Out (blue): 0x14
3095 * Build-in Mic-In: 0x15
3096 * Speaker-out: 0x17
3097 * HP-Out (green): 0x1b
3098 * Mic-In/Out (red): 0x19
3099 * SPDIF-Out: 0x1e
3100 */
3101
3102/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3103static hda_nid_t alc880_lg_dac_nids[3] = {
3104 0x05, 0x02, 0x03
3105};
3106
3107/* seems analog CD is not working */
3108static struct hda_input_mux alc880_lg_capture_source = {
3109 .num_items = 3,
3110 .items = {
3111 { "Mic", 0x1 },
3112 { "Line", 0x5 },
3113 { "Internal Mic", 0x6 },
3114 },
3115};
3116
3117/* 2,4,6 channel modes */
3118static struct hda_verb alc880_lg_ch2_init[] = {
3119 /* set line-in and mic-in to input */
3120 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3121 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3122 { }
3123};
3124
3125static struct hda_verb alc880_lg_ch4_init[] = {
3126 /* set line-in to out and mic-in to input */
3127 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3128 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3129 { }
3130};
3131
3132static struct hda_verb alc880_lg_ch6_init[] = {
3133 /* set line-in and mic-in to output */
3134 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3135 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3136 { }
3137};
3138
3139static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3140 { 2, alc880_lg_ch2_init },
3141 { 4, alc880_lg_ch4_init },
3142 { 6, alc880_lg_ch6_init },
3143};
3144
3145static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003146 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3147 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003148 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3149 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3150 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3151 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3152 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3153 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3154 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3155 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3156 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3157 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3158 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3159 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3160 {
3161 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3162 .name = "Channel Mode",
3163 .info = alc_ch_mode_info,
3164 .get = alc_ch_mode_get,
3165 .put = alc_ch_mode_put,
3166 },
3167 { } /* end */
3168};
3169
3170static struct hda_verb alc880_lg_init_verbs[] = {
3171 /* set capture source to mic-in */
3172 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3173 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3174 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3175 /* mute all amp mixer inputs */
3176 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003177 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3178 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003179 /* line-in to input */
3180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3181 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3182 /* built-in mic */
3183 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3184 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3185 /* speaker-out */
3186 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3187 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3188 /* mic-in to input */
3189 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3190 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3191 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3192 /* HP-out */
3193 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3194 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3195 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3196 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003197 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003198 { }
3199};
3200
3201/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003202static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003203{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003204 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003205
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003206 spec->autocfg.hp_pins[0] = 0x1b;
3207 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003208}
3209
3210/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003211 * LG LW20
3212 *
3213 * Pin assignment:
3214 * Speaker-out: 0x14
3215 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003216 * Built-in Mic-In: 0x19
3217 * Line-In: 0x1b
3218 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003219 * SPDIF-Out: 0x1e
3220 */
3221
Takashi Iwaid6815182006-03-23 16:06:23 +01003222static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003223 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003224 .items = {
3225 { "Mic", 0x0 },
3226 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003227 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003228 },
3229};
3230
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003231#define alc880_lg_lw_modes alc880_threestack_modes
3232
Takashi Iwaid6815182006-03-23 16:06:23 +01003233static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003234 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3235 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3236 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3237 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3238 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3239 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3240 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3241 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3242 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3243 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003244 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3245 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3246 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3247 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003248 {
3249 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3250 .name = "Channel Mode",
3251 .info = alc_ch_mode_info,
3252 .get = alc_ch_mode_get,
3253 .put = alc_ch_mode_put,
3254 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003255 { } /* end */
3256};
3257
3258static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003259 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3260 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3261 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3262
Takashi Iwaid6815182006-03-23 16:06:23 +01003263 /* set capture source to mic-in */
3264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3265 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3266 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003267 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003268 /* speaker-out */
3269 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3270 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3271 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003272 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3273 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3274 /* mic-in to input */
3275 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3276 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3277 /* built-in mic */
3278 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3279 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3280 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003281 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003282 { }
3283};
3284
3285/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003286static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003287{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003288 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003289
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003290 spec->autocfg.hp_pins[0] = 0x1b;
3291 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003292}
3293
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003294static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3295 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3296 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3297 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3298 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3299 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3300 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3301 { } /* end */
3302};
3303
3304static struct hda_input_mux alc880_medion_rim_capture_source = {
3305 .num_items = 2,
3306 .items = {
3307 { "Mic", 0x0 },
3308 { "Internal Mic", 0x1 },
3309 },
3310};
3311
3312static struct hda_verb alc880_medion_rim_init_verbs[] = {
3313 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3314
3315 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3316 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3317
3318 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3319 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3320 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3321 /* Mic2 (as headphone out) for HP output */
3322 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3323 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3324 /* Internal Speaker */
3325 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3326 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3327
3328 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3329 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3330
3331 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3332 { }
3333};
3334
3335/* toggle speaker-output according to the hp-jack state */
3336static void alc880_medion_rim_automute(struct hda_codec *codec)
3337{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003338 struct alc_spec *spec = codec->spec;
3339 alc_automute_amp(codec);
3340 /* toggle EAPD */
3341 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003342 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3343 else
3344 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3345}
3346
3347static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3348 unsigned int res)
3349{
3350 /* Looks like the unsol event is incompatible with the standard
3351 * definition. 4bit tag is placed at 28 bit!
3352 */
3353 if ((res >> 28) == ALC880_HP_EVENT)
3354 alc880_medion_rim_automute(codec);
3355}
3356
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003357static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003358{
3359 struct alc_spec *spec = codec->spec;
3360
3361 spec->autocfg.hp_pins[0] = 0x14;
3362 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003363}
3364
Takashi Iwaicb53c622007-08-10 17:21:45 +02003365#ifdef CONFIG_SND_HDA_POWER_SAVE
3366static struct hda_amp_list alc880_loopbacks[] = {
3367 { 0x0b, HDA_INPUT, 0 },
3368 { 0x0b, HDA_INPUT, 1 },
3369 { 0x0b, HDA_INPUT, 2 },
3370 { 0x0b, HDA_INPUT, 3 },
3371 { 0x0b, HDA_INPUT, 4 },
3372 { } /* end */
3373};
3374
3375static struct hda_amp_list alc880_lg_loopbacks[] = {
3376 { 0x0b, HDA_INPUT, 1 },
3377 { 0x0b, HDA_INPUT, 6 },
3378 { 0x0b, HDA_INPUT, 7 },
3379 { } /* end */
3380};
3381#endif
3382
Takashi Iwaid6815182006-03-23 16:06:23 +01003383/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003384 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003385 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003386
Linus Torvalds1da177e2005-04-16 15:20:36 -07003387static int alc_init(struct hda_codec *codec)
3388{
3389 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003390 unsigned int i;
3391
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003392 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003393 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003394
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003395 for (i = 0; i < spec->num_init_verbs; i++)
3396 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003397
3398 if (spec->init_hook)
3399 spec->init_hook(codec);
3400
Linus Torvalds1da177e2005-04-16 15:20:36 -07003401 return 0;
3402}
3403
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003404static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3405{
3406 struct alc_spec *spec = codec->spec;
3407
3408 if (spec->unsol_event)
3409 spec->unsol_event(codec, res);
3410}
3411
Takashi Iwaicb53c622007-08-10 17:21:45 +02003412#ifdef CONFIG_SND_HDA_POWER_SAVE
3413static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3414{
3415 struct alc_spec *spec = codec->spec;
3416 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3417}
3418#endif
3419
Linus Torvalds1da177e2005-04-16 15:20:36 -07003420/*
3421 * Analog playback callbacks
3422 */
3423static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3424 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003425 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003426{
3427 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003428 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3429 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003430}
3431
3432static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3433 struct hda_codec *codec,
3434 unsigned int stream_tag,
3435 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003436 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003437{
3438 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003439 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3440 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003441}
3442
3443static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3444 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003445 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003446{
3447 struct alc_spec *spec = codec->spec;
3448 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3449}
3450
3451/*
3452 * Digital out
3453 */
3454static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3455 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003456 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003457{
3458 struct alc_spec *spec = codec->spec;
3459 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3460}
3461
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003462static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3463 struct hda_codec *codec,
3464 unsigned int stream_tag,
3465 unsigned int format,
3466 struct snd_pcm_substream *substream)
3467{
3468 struct alc_spec *spec = codec->spec;
3469 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3470 stream_tag, format, substream);
3471}
3472
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003473static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3474 struct hda_codec *codec,
3475 struct snd_pcm_substream *substream)
3476{
3477 struct alc_spec *spec = codec->spec;
3478 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3479}
3480
Linus Torvalds1da177e2005-04-16 15:20:36 -07003481static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3482 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003483 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003484{
3485 struct alc_spec *spec = codec->spec;
3486 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3487}
3488
3489/*
3490 * Analog capture
3491 */
Takashi Iwai63300792008-01-24 15:31:36 +01003492static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003493 struct hda_codec *codec,
3494 unsigned int stream_tag,
3495 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003496 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003497{
3498 struct alc_spec *spec = codec->spec;
3499
Takashi Iwai63300792008-01-24 15:31:36 +01003500 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003501 stream_tag, 0, format);
3502 return 0;
3503}
3504
Takashi Iwai63300792008-01-24 15:31:36 +01003505static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003506 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003507 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003508{
3509 struct alc_spec *spec = codec->spec;
3510
Takashi Iwai888afa12008-03-18 09:57:50 +01003511 snd_hda_codec_cleanup_stream(codec,
3512 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003513 return 0;
3514}
3515
3516
3517/*
3518 */
3519static struct hda_pcm_stream alc880_pcm_analog_playback = {
3520 .substreams = 1,
3521 .channels_min = 2,
3522 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003523 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003524 .ops = {
3525 .open = alc880_playback_pcm_open,
3526 .prepare = alc880_playback_pcm_prepare,
3527 .cleanup = alc880_playback_pcm_cleanup
3528 },
3529};
3530
3531static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003532 .substreams = 1,
3533 .channels_min = 2,
3534 .channels_max = 2,
3535 /* NID is set in alc_build_pcms */
3536};
3537
3538static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3539 .substreams = 1,
3540 .channels_min = 2,
3541 .channels_max = 2,
3542 /* NID is set in alc_build_pcms */
3543};
3544
3545static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3546 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003547 .channels_min = 2,
3548 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003549 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003550 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003551 .prepare = alc880_alt_capture_pcm_prepare,
3552 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003553 },
3554};
3555
3556static struct hda_pcm_stream alc880_pcm_digital_playback = {
3557 .substreams = 1,
3558 .channels_min = 2,
3559 .channels_max = 2,
3560 /* NID is set in alc_build_pcms */
3561 .ops = {
3562 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003563 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003564 .prepare = alc880_dig_playback_pcm_prepare,
3565 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003566 },
3567};
3568
3569static struct hda_pcm_stream alc880_pcm_digital_capture = {
3570 .substreams = 1,
3571 .channels_min = 2,
3572 .channels_max = 2,
3573 /* NID is set in alc_build_pcms */
3574};
3575
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003576/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003577static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003578 .substreams = 0,
3579 .channels_min = 0,
3580 .channels_max = 0,
3581};
3582
Linus Torvalds1da177e2005-04-16 15:20:36 -07003583static int alc_build_pcms(struct hda_codec *codec)
3584{
3585 struct alc_spec *spec = codec->spec;
3586 struct hda_pcm *info = spec->pcm_rec;
3587 int i;
3588
3589 codec->num_pcms = 1;
3590 codec->pcm_info = info;
3591
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003592 if (spec->no_analog)
3593 goto skip_analog;
3594
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003595 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3596 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003597 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003598
Takashi Iwai4a471b72005-12-07 13:56:29 +01003599 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003600 if (snd_BUG_ON(!spec->multiout.dac_nids))
3601 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003602 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3603 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3604 }
3605 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003606 if (snd_BUG_ON(!spec->adc_nids))
3607 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003608 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3609 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3610 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003611
Takashi Iwai4a471b72005-12-07 13:56:29 +01003612 if (spec->channel_mode) {
3613 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3614 for (i = 0; i < spec->num_channel_mode; i++) {
3615 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3616 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3617 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003618 }
3619 }
3620
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003621 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003622 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003623 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003624 snprintf(spec->stream_name_digital,
3625 sizeof(spec->stream_name_digital),
3626 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003627 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003628 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003629 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003630 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003631 if (spec->dig_out_type)
3632 info->pcm_type = spec->dig_out_type;
3633 else
3634 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003635 if (spec->multiout.dig_out_nid &&
3636 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003637 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3638 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3639 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003640 if (spec->dig_in_nid &&
3641 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003642 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3643 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3644 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003645 /* FIXME: do we need this for all Realtek codec models? */
3646 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003647 }
3648
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003649 if (spec->no_analog)
3650 return 0;
3651
Takashi Iwaie08a0072006-09-07 17:52:14 +02003652 /* If the use of more than one ADC is requested for the current
3653 * model, configure a second analog capture-only PCM.
3654 */
3655 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003656 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3657 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003658 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003659 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003660 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003661 if (spec->alt_dac_nid) {
3662 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3663 *spec->stream_analog_alt_playback;
3664 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3665 spec->alt_dac_nid;
3666 } else {
3667 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3668 alc_pcm_null_stream;
3669 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3670 }
3671 if (spec->num_adc_nids > 1) {
3672 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3673 *spec->stream_analog_alt_capture;
3674 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3675 spec->adc_nids[1];
3676 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3677 spec->num_adc_nids - 1;
3678 } else {
3679 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3680 alc_pcm_null_stream;
3681 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003682 }
3683 }
3684
Linus Torvalds1da177e2005-04-16 15:20:36 -07003685 return 0;
3686}
3687
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003688static inline void alc_shutup(struct hda_codec *codec)
3689{
3690 snd_hda_shutup_pins(codec);
3691}
3692
Takashi Iwai603c4012008-07-30 15:01:44 +02003693static void alc_free_kctls(struct hda_codec *codec)
3694{
3695 struct alc_spec *spec = codec->spec;
3696
3697 if (spec->kctls.list) {
3698 struct snd_kcontrol_new *kctl = spec->kctls.list;
3699 int i;
3700 for (i = 0; i < spec->kctls.used; i++)
3701 kfree(kctl[i].name);
3702 }
3703 snd_array_free(&spec->kctls);
3704}
3705
Linus Torvalds1da177e2005-04-16 15:20:36 -07003706static void alc_free(struct hda_codec *codec)
3707{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003708 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003709
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003710 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003711 return;
3712
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003713 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02003714 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003715 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003716 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003717}
3718
Hector Martinf5de24b2009-12-20 22:51:31 +01003719#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05003720static void alc_power_eapd(struct hda_codec *codec)
3721{
3722 /* We currently only handle front, HP */
3723 switch (codec->vendor_id) {
3724 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003725 set_eapd(codec, 0x0f, 0);
3726 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003727 break;
3728 case 0x10ec0262:
3729 case 0x10ec0267:
3730 case 0x10ec0268:
3731 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003732 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05003733 case 0x10ec0272:
3734 case 0x10ec0660:
3735 case 0x10ec0662:
3736 case 0x10ec0663:
3737 case 0x10ec0862:
3738 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003739 set_eapd(codec, 0x14, 0);
3740 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003741 break;
3742 }
3743}
3744
Hector Martinf5de24b2009-12-20 22:51:31 +01003745static int alc_suspend(struct hda_codec *codec, pm_message_t state)
3746{
3747 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003748 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003749 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05003750 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003751 return 0;
3752}
3753#endif
3754
Takashi Iwaie044c392008-10-27 16:56:24 +01003755#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003756static int alc_resume(struct hda_codec *codec)
3757{
Takashi Iwaie044c392008-10-27 16:56:24 +01003758 codec->patch_ops.init(codec);
3759 snd_hda_codec_resume_amp(codec);
3760 snd_hda_codec_resume_cache(codec);
3761 return 0;
3762}
Takashi Iwaie044c392008-10-27 16:56:24 +01003763#endif
3764
Linus Torvalds1da177e2005-04-16 15:20:36 -07003765/*
3766 */
3767static struct hda_codec_ops alc_patch_ops = {
3768 .build_controls = alc_build_controls,
3769 .build_pcms = alc_build_pcms,
3770 .init = alc_init,
3771 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003772 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003773#ifdef SND_HDA_NEEDS_RESUME
3774 .resume = alc_resume,
3775#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003776#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01003777 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003778 .check_power_status = alc_check_power_status,
3779#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05003780 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003781};
3782
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003783
3784/*
3785 * Test configuration for debugging
3786 *
3787 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3788 * enum controls.
3789 */
3790#ifdef CONFIG_SND_DEBUG
3791static hda_nid_t alc880_test_dac_nids[4] = {
3792 0x02, 0x03, 0x04, 0x05
3793};
3794
3795static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003796 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003797 .items = {
3798 { "In-1", 0x0 },
3799 { "In-2", 0x1 },
3800 { "In-3", 0x2 },
3801 { "In-4", 0x3 },
3802 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003803 { "Front", 0x5 },
3804 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003805 },
3806};
3807
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003808static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003809 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003810 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003811 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003812 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003813};
3814
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003815static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3816 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003817{
3818 static char *texts[] = {
3819 "N/A", "Line Out", "HP Out",
3820 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3821 };
3822 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3823 uinfo->count = 1;
3824 uinfo->value.enumerated.items = 8;
3825 if (uinfo->value.enumerated.item >= 8)
3826 uinfo->value.enumerated.item = 7;
3827 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3828 return 0;
3829}
3830
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003831static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3832 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003833{
3834 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3835 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3836 unsigned int pin_ctl, item = 0;
3837
3838 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3839 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3840 if (pin_ctl & AC_PINCTL_OUT_EN) {
3841 if (pin_ctl & AC_PINCTL_HP_EN)
3842 item = 2;
3843 else
3844 item = 1;
3845 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3846 switch (pin_ctl & AC_PINCTL_VREFEN) {
3847 case AC_PINCTL_VREF_HIZ: item = 3; break;
3848 case AC_PINCTL_VREF_50: item = 4; break;
3849 case AC_PINCTL_VREF_GRD: item = 5; break;
3850 case AC_PINCTL_VREF_80: item = 6; break;
3851 case AC_PINCTL_VREF_100: item = 7; break;
3852 }
3853 }
3854 ucontrol->value.enumerated.item[0] = item;
3855 return 0;
3856}
3857
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003858static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3859 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003860{
3861 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3862 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3863 static unsigned int ctls[] = {
3864 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3865 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3866 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3867 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3868 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3869 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3870 };
3871 unsigned int old_ctl, new_ctl;
3872
3873 old_ctl = snd_hda_codec_read(codec, nid, 0,
3874 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3875 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3876 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003877 int val;
3878 snd_hda_codec_write_cache(codec, nid, 0,
3879 AC_VERB_SET_PIN_WIDGET_CONTROL,
3880 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003881 val = ucontrol->value.enumerated.item[0] >= 3 ?
3882 HDA_AMP_MUTE : 0;
3883 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3884 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003885 return 1;
3886 }
3887 return 0;
3888}
3889
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003890static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3891 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003892{
3893 static char *texts[] = {
3894 "Front", "Surround", "CLFE", "Side"
3895 };
3896 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3897 uinfo->count = 1;
3898 uinfo->value.enumerated.items = 4;
3899 if (uinfo->value.enumerated.item >= 4)
3900 uinfo->value.enumerated.item = 3;
3901 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3902 return 0;
3903}
3904
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003905static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3906 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003907{
3908 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3909 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3910 unsigned int sel;
3911
3912 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3913 ucontrol->value.enumerated.item[0] = sel & 3;
3914 return 0;
3915}
3916
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003917static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3918 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003919{
3920 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3921 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3922 unsigned int sel;
3923
3924 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3925 if (ucontrol->value.enumerated.item[0] != sel) {
3926 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003927 snd_hda_codec_write_cache(codec, nid, 0,
3928 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003929 return 1;
3930 }
3931 return 0;
3932}
3933
3934#define PIN_CTL_TEST(xname,nid) { \
3935 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3936 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003937 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003938 .info = alc_test_pin_ctl_info, \
3939 .get = alc_test_pin_ctl_get, \
3940 .put = alc_test_pin_ctl_put, \
3941 .private_value = nid \
3942 }
3943
3944#define PIN_SRC_TEST(xname,nid) { \
3945 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3946 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003947 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003948 .info = alc_test_pin_src_info, \
3949 .get = alc_test_pin_src_get, \
3950 .put = alc_test_pin_src_put, \
3951 .private_value = nid \
3952 }
3953
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003954static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003955 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3956 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3957 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3958 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003959 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3960 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3961 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3962 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003963 PIN_CTL_TEST("Front Pin Mode", 0x14),
3964 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3965 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3966 PIN_CTL_TEST("Side Pin Mode", 0x17),
3967 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3968 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3969 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3970 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3971 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3972 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3973 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3974 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3975 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3976 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3977 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3978 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3979 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3980 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3981 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3982 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3983 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3984 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003985 {
3986 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3987 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003988 .info = alc_ch_mode_info,
3989 .get = alc_ch_mode_get,
3990 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003991 },
3992 { } /* end */
3993};
3994
3995static struct hda_verb alc880_test_init_verbs[] = {
3996 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003997 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3998 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3999 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4000 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4001 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4002 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4003 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4004 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004005 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004006 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4007 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4008 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4009 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004010 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004011 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4012 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4013 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4014 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004015 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004016 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4017 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4018 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4019 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004020 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004021 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4022 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004023 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4024 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4025 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004026 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004027 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4028 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4029 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4030 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004031 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004033 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004034 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004035 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004036 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004037 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004038 /* Analog input/passthru */
4039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4042 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004044 { }
4045};
4046#endif
4047
Linus Torvalds1da177e2005-04-16 15:20:36 -07004048/*
4049 */
4050
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004051static const char *alc880_models[ALC880_MODEL_LAST] = {
4052 [ALC880_3ST] = "3stack",
4053 [ALC880_TCL_S700] = "tcl",
4054 [ALC880_3ST_DIG] = "3stack-digout",
4055 [ALC880_CLEVO] = "clevo",
4056 [ALC880_5ST] = "5stack",
4057 [ALC880_5ST_DIG] = "5stack-digout",
4058 [ALC880_W810] = "w810",
4059 [ALC880_Z71V] = "z71v",
4060 [ALC880_6ST] = "6stack",
4061 [ALC880_6ST_DIG] = "6stack-digout",
4062 [ALC880_ASUS] = "asus",
4063 [ALC880_ASUS_W1V] = "asus-w1v",
4064 [ALC880_ASUS_DIG] = "asus-dig",
4065 [ALC880_ASUS_DIG2] = "asus-dig2",
4066 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004067 [ALC880_UNIWILL_P53] = "uniwill-p53",
4068 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004069 [ALC880_F1734] = "F1734",
4070 [ALC880_LG] = "lg",
4071 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004072 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004073#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004074 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004075#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004076 [ALC880_AUTO] = "auto",
4077};
4078
4079static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004080 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004081 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4082 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4083 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4084 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4085 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4086 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4087 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4088 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004089 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4090 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004091 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4092 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4093 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4094 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4095 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4096 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4097 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4098 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4099 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4100 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004101 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004102 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4103 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4104 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004105 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004106 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004107 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4108 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004109 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4110 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004111 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4112 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4113 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4114 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004115 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4116 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004117 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004118 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004119 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004120 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004121 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4122 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004123 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004124 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004125 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004126 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004127 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004128 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004129 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004130 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004131 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004132 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4133 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004134 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004135 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4136 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4137 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4138 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004139 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4140 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004141 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004142 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004143 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4144 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004145 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4146 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4147 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004148 /* default Intel */
4149 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004150 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4151 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004152 {}
4153};
4154
Takashi Iwai16ded522005-06-10 19:58:24 +02004155/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004156 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004157 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004158static struct alc_config_preset alc880_presets[] = {
4159 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004160 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004161 .init_verbs = { alc880_volume_init_verbs,
4162 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004163 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004164 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004165 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4166 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004167 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004168 .input_mux = &alc880_capture_source,
4169 },
4170 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004171 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004172 .init_verbs = { alc880_volume_init_verbs,
4173 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004174 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004175 .dac_nids = alc880_dac_nids,
4176 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004177 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4178 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004179 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004180 .input_mux = &alc880_capture_source,
4181 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004182 [ALC880_TCL_S700] = {
4183 .mixers = { alc880_tcl_s700_mixer },
4184 .init_verbs = { alc880_volume_init_verbs,
4185 alc880_pin_tcl_S700_init_verbs,
4186 alc880_gpio2_init_verbs },
4187 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4188 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004189 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4190 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004191 .hp_nid = 0x03,
4192 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4193 .channel_mode = alc880_2_jack_modes,
4194 .input_mux = &alc880_capture_source,
4195 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004196 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004197 .mixers = { alc880_three_stack_mixer,
4198 alc880_five_stack_mixer},
4199 .init_verbs = { alc880_volume_init_verbs,
4200 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004201 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4202 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004203 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4204 .channel_mode = alc880_fivestack_modes,
4205 .input_mux = &alc880_capture_source,
4206 },
4207 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004208 .mixers = { alc880_three_stack_mixer,
4209 alc880_five_stack_mixer },
4210 .init_verbs = { alc880_volume_init_verbs,
4211 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004212 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4213 .dac_nids = alc880_dac_nids,
4214 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004215 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4216 .channel_mode = alc880_fivestack_modes,
4217 .input_mux = &alc880_capture_source,
4218 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004219 [ALC880_6ST] = {
4220 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004221 .init_verbs = { alc880_volume_init_verbs,
4222 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004223 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4224 .dac_nids = alc880_6st_dac_nids,
4225 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4226 .channel_mode = alc880_sixstack_modes,
4227 .input_mux = &alc880_6stack_capture_source,
4228 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004229 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004230 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004231 .init_verbs = { alc880_volume_init_verbs,
4232 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004233 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4234 .dac_nids = alc880_6st_dac_nids,
4235 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004236 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4237 .channel_mode = alc880_sixstack_modes,
4238 .input_mux = &alc880_6stack_capture_source,
4239 },
4240 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004241 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004242 .init_verbs = { alc880_volume_init_verbs,
4243 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004244 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004245 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4246 .dac_nids = alc880_w810_dac_nids,
4247 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004248 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4249 .channel_mode = alc880_w810_modes,
4250 .input_mux = &alc880_capture_source,
4251 },
4252 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004253 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004254 .init_verbs = { alc880_volume_init_verbs,
4255 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004256 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4257 .dac_nids = alc880_z71v_dac_nids,
4258 .dig_out_nid = ALC880_DIGOUT_NID,
4259 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004260 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4261 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004262 .input_mux = &alc880_capture_source,
4263 },
4264 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004265 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004266 .init_verbs = { alc880_volume_init_verbs,
4267 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004268 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4269 .dac_nids = alc880_f1734_dac_nids,
4270 .hp_nid = 0x02,
4271 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4272 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004273 .input_mux = &alc880_f1734_capture_source,
4274 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004275 .setup = alc880_uniwill_p53_setup,
4276 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004277 },
4278 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004279 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004280 .init_verbs = { alc880_volume_init_verbs,
4281 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004282 alc880_gpio1_init_verbs },
4283 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4284 .dac_nids = alc880_asus_dac_nids,
4285 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4286 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004287 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004288 .input_mux = &alc880_capture_source,
4289 },
4290 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004291 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004292 .init_verbs = { alc880_volume_init_verbs,
4293 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004294 alc880_gpio1_init_verbs },
4295 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4296 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004297 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004298 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4299 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004300 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004301 .input_mux = &alc880_capture_source,
4302 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004303 [ALC880_ASUS_DIG2] = {
4304 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004305 .init_verbs = { alc880_volume_init_verbs,
4306 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004307 alc880_gpio2_init_verbs }, /* use GPIO2 */
4308 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4309 .dac_nids = alc880_asus_dac_nids,
4310 .dig_out_nid = ALC880_DIGOUT_NID,
4311 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4312 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004313 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004314 .input_mux = &alc880_capture_source,
4315 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004316 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004317 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004318 .init_verbs = { alc880_volume_init_verbs,
4319 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004320 alc880_gpio1_init_verbs },
4321 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4322 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004323 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004324 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4325 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004326 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004327 .input_mux = &alc880_capture_source,
4328 },
4329 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004330 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004331 .init_verbs = { alc880_volume_init_verbs,
4332 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004333 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4334 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004335 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004336 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4337 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004338 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004339 .input_mux = &alc880_capture_source,
4340 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004341 [ALC880_UNIWILL] = {
4342 .mixers = { alc880_uniwill_mixer },
4343 .init_verbs = { alc880_volume_init_verbs,
4344 alc880_uniwill_init_verbs },
4345 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4346 .dac_nids = alc880_asus_dac_nids,
4347 .dig_out_nid = ALC880_DIGOUT_NID,
4348 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4349 .channel_mode = alc880_threestack_modes,
4350 .need_dac_fix = 1,
4351 .input_mux = &alc880_capture_source,
4352 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004353 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004354 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004355 },
4356 [ALC880_UNIWILL_P53] = {
4357 .mixers = { alc880_uniwill_p53_mixer },
4358 .init_verbs = { alc880_volume_init_verbs,
4359 alc880_uniwill_p53_init_verbs },
4360 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4361 .dac_nids = alc880_asus_dac_nids,
4362 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004363 .channel_mode = alc880_threestack_modes,
4364 .input_mux = &alc880_capture_source,
4365 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004366 .setup = alc880_uniwill_p53_setup,
4367 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004368 },
4369 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004370 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004371 .init_verbs = { alc880_volume_init_verbs,
4372 alc880_uniwill_p53_init_verbs,
4373 alc880_beep_init_verbs },
4374 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4375 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004376 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004377 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4378 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004379 .input_mux = &alc880_capture_source,
4380 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004381 .setup = alc880_uniwill_p53_setup,
4382 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004383 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004384 [ALC880_CLEVO] = {
4385 .mixers = { alc880_three_stack_mixer },
4386 .init_verbs = { alc880_volume_init_verbs,
4387 alc880_pin_clevo_init_verbs },
4388 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4389 .dac_nids = alc880_dac_nids,
4390 .hp_nid = 0x03,
4391 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4392 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004393 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004394 .input_mux = &alc880_capture_source,
4395 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004396 [ALC880_LG] = {
4397 .mixers = { alc880_lg_mixer },
4398 .init_verbs = { alc880_volume_init_verbs,
4399 alc880_lg_init_verbs },
4400 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4401 .dac_nids = alc880_lg_dac_nids,
4402 .dig_out_nid = ALC880_DIGOUT_NID,
4403 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4404 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004405 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004406 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004407 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004408 .setup = alc880_lg_setup,
4409 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004410#ifdef CONFIG_SND_HDA_POWER_SAVE
4411 .loopbacks = alc880_lg_loopbacks,
4412#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004413 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004414 [ALC880_LG_LW] = {
4415 .mixers = { alc880_lg_lw_mixer },
4416 .init_verbs = { alc880_volume_init_verbs,
4417 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004418 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004419 .dac_nids = alc880_dac_nids,
4420 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004421 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4422 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004423 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004424 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004425 .setup = alc880_lg_lw_setup,
4426 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004427 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004428 [ALC880_MEDION_RIM] = {
4429 .mixers = { alc880_medion_rim_mixer },
4430 .init_verbs = { alc880_volume_init_verbs,
4431 alc880_medion_rim_init_verbs,
4432 alc_gpio2_init_verbs },
4433 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4434 .dac_nids = alc880_dac_nids,
4435 .dig_out_nid = ALC880_DIGOUT_NID,
4436 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4437 .channel_mode = alc880_2_jack_modes,
4438 .input_mux = &alc880_medion_rim_capture_source,
4439 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004440 .setup = alc880_medion_rim_setup,
4441 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004442 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004443#ifdef CONFIG_SND_DEBUG
4444 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004445 .mixers = { alc880_test_mixer },
4446 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004447 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4448 .dac_nids = alc880_test_dac_nids,
4449 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004450 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4451 .channel_mode = alc880_test_modes,
4452 .input_mux = &alc880_test_capture_source,
4453 },
4454#endif
4455};
4456
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004457/*
4458 * Automatic parse of I/O pins from the BIOS configuration
4459 */
4460
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004461enum {
4462 ALC_CTL_WIDGET_VOL,
4463 ALC_CTL_WIDGET_MUTE,
4464 ALC_CTL_BIND_MUTE,
4465};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004466static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004467 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4468 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004469 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004470};
4471
4472/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004473static int add_control(struct alc_spec *spec, int type, const char *name,
4474 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004475{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004476 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004477
Takashi Iwai603c4012008-07-30 15:01:44 +02004478 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4479 knew = snd_array_new(&spec->kctls);
4480 if (!knew)
4481 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004482 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004483 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004484 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004485 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004486 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004487 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004488 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004489 return 0;
4490}
4491
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004492static int add_control_with_pfx(struct alc_spec *spec, int type,
4493 const char *pfx, const char *dir,
4494 const char *sfx, unsigned long val)
4495{
4496 char name[32];
4497 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4498 return add_control(spec, type, name, val);
4499}
4500
4501#define add_pb_vol_ctrl(spec, type, pfx, val) \
4502 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4503#define add_pb_sw_ctrl(spec, type, pfx, val) \
4504 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4505
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004506#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4507#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4508#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4509#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004510#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4511#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4512#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4513#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4514#define ALC880_PIN_CD_NID 0x1c
4515
4516/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004517static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4518 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004519{
4520 hda_nid_t nid;
4521 int assigned[4];
4522 int i, j;
4523
4524 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004525 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004526
4527 /* check the pins hardwired to audio widget */
4528 for (i = 0; i < cfg->line_outs; i++) {
4529 nid = cfg->line_out_pins[i];
4530 if (alc880_is_fixed_pin(nid)) {
4531 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004532 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004533 assigned[idx] = 1;
4534 }
4535 }
4536 /* left pins can be connect to any audio widget */
4537 for (i = 0; i < cfg->line_outs; i++) {
4538 nid = cfg->line_out_pins[i];
4539 if (alc880_is_fixed_pin(nid))
4540 continue;
4541 /* search for an empty channel */
4542 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004543 if (!assigned[j]) {
4544 spec->multiout.dac_nids[i] =
4545 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004546 assigned[j] = 1;
4547 break;
4548 }
4549 }
4550 }
4551 spec->multiout.num_dacs = cfg->line_outs;
4552 return 0;
4553}
4554
4555/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004556static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4557 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004558{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004559 static const char *chname[4] = {
4560 "Front", "Surround", NULL /*CLFE*/, "Side"
4561 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004562 hda_nid_t nid;
4563 int i, err;
4564
4565 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004566 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004567 continue;
4568 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4569 if (i == 2) {
4570 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004571 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4572 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004573 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4574 HDA_OUTPUT));
4575 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004576 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004577 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4578 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004579 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4580 HDA_OUTPUT));
4581 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004582 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004583 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4584 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004585 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4586 HDA_INPUT));
4587 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004588 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004589 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4590 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004591 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4592 HDA_INPUT));
4593 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004594 return err;
4595 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004596 const char *pfx;
4597 if (cfg->line_outs == 1 &&
4598 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4599 pfx = "Speaker";
4600 else
4601 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004602 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004603 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4604 HDA_OUTPUT));
4605 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004606 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004607 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004608 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4609 HDA_INPUT));
4610 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004611 return err;
4612 }
4613 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004614 return 0;
4615}
4616
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004617/* add playback controls for speaker and HP outputs */
4618static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4619 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004620{
4621 hda_nid_t nid;
4622 int err;
4623
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004624 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004625 return 0;
4626
4627 if (alc880_is_fixed_pin(pin)) {
4628 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004629 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004630 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004631 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004632 else
4633 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004634 /* control HP volume/switch on the output mixer amp */
4635 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004636 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004637 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4638 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004639 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004640 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004641 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4642 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004643 return err;
4644 } else if (alc880_is_multi_pin(pin)) {
4645 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004646 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004647 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004648 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4649 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004650 return err;
4651 }
4652 return 0;
4653}
4654
4655/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004656static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4657 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004658 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004659{
Kailang Yangdf694da2005-12-05 19:42:22 +01004660 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004661
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004662 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004663 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4664 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004665 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004666 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004667 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4668 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004669 return err;
4670 return 0;
4671}
4672
Takashi Iwai05f5f472009-08-25 13:10:18 +02004673static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004674{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004675 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4676 return (pincap & AC_PINCAP_IN) != 0;
4677}
4678
4679/* create playback/capture controls for input pins */
4680static int alc_auto_create_input_ctls(struct hda_codec *codec,
4681 const struct auto_pin_cfg *cfg,
4682 hda_nid_t mixer,
4683 hda_nid_t cap1, hda_nid_t cap2)
4684{
4685 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004686 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004687 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004688
4689 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004690 hda_nid_t pin;
4691
4692 pin = cfg->input_pins[i];
4693 if (!alc_is_input_pin(codec, pin))
4694 continue;
4695
4696 if (mixer) {
4697 idx = get_connection_index(codec, mixer, pin);
4698 if (idx >= 0) {
4699 err = new_analog_input(spec, pin,
4700 auto_pin_cfg_labels[i],
4701 idx, mixer);
4702 if (err < 0)
4703 return err;
4704 }
4705 }
4706
4707 if (!cap1)
4708 continue;
4709 idx = get_connection_index(codec, cap1, pin);
4710 if (idx < 0 && cap2)
4711 idx = get_connection_index(codec, cap2, pin);
4712 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004713 imux->items[imux->num_items].label =
4714 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004715 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004716 imux->num_items++;
4717 }
4718 }
4719 return 0;
4720}
4721
Takashi Iwai05f5f472009-08-25 13:10:18 +02004722static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4723 const struct auto_pin_cfg *cfg)
4724{
4725 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4726}
4727
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004728static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4729 unsigned int pin_type)
4730{
4731 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4732 pin_type);
4733 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004734 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4735 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004736}
4737
Kailang Yangdf694da2005-12-05 19:42:22 +01004738static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4739 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004740 int dac_idx)
4741{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004742 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004743 /* need the manual connection? */
4744 if (alc880_is_multi_pin(nid)) {
4745 struct alc_spec *spec = codec->spec;
4746 int idx = alc880_multi_pin_idx(nid);
4747 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4748 AC_VERB_SET_CONNECT_SEL,
4749 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4750 }
4751}
4752
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004753static int get_pin_type(int line_out_type)
4754{
4755 if (line_out_type == AUTO_PIN_HP_OUT)
4756 return PIN_HP;
4757 else
4758 return PIN_OUT;
4759}
4760
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004761static void alc880_auto_init_multi_out(struct hda_codec *codec)
4762{
4763 struct alc_spec *spec = codec->spec;
4764 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004765
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004766 for (i = 0; i < spec->autocfg.line_outs; i++) {
4767 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004768 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4769 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004770 }
4771}
4772
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004773static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004774{
4775 struct alc_spec *spec = codec->spec;
4776 hda_nid_t pin;
4777
Takashi Iwai82bc9552006-03-21 11:24:42 +01004778 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004779 if (pin) /* connect to front */
4780 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004781 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004782 if (pin) /* connect to front */
4783 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4784}
4785
4786static void alc880_auto_init_analog_input(struct hda_codec *codec)
4787{
4788 struct alc_spec *spec = codec->spec;
4789 int i;
4790
4791 for (i = 0; i < AUTO_PIN_LAST; i++) {
4792 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004793 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004794 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004795 if (nid != ALC880_PIN_CD_NID &&
4796 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004797 snd_hda_codec_write(codec, nid, 0,
4798 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004799 AMP_OUT_MUTE);
4800 }
4801 }
4802}
4803
4804/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004805/* return 1 if successful, 0 if the proper config is not found,
4806 * or a negative error code
4807 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004808static int alc880_parse_auto_config(struct hda_codec *codec)
4809{
4810 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004811 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004812 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004813
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004814 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4815 alc880_ignore);
4816 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004817 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004818 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004819 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004820
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004821 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4822 if (err < 0)
4823 return err;
4824 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4825 if (err < 0)
4826 return err;
4827 err = alc880_auto_create_extra_out(spec,
4828 spec->autocfg.speaker_pins[0],
4829 "Speaker");
4830 if (err < 0)
4831 return err;
4832 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4833 "Headphone");
4834 if (err < 0)
4835 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004836 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004837 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004838 return err;
4839
4840 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4841
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004842 /* check multiple SPDIF-out (for recent codecs) */
4843 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4844 hda_nid_t dig_nid;
4845 err = snd_hda_get_connections(codec,
4846 spec->autocfg.dig_out_pins[i],
4847 &dig_nid, 1);
4848 if (err < 0)
4849 continue;
4850 if (!i)
4851 spec->multiout.dig_out_nid = dig_nid;
4852 else {
4853 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004854 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004855 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004856 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004857 }
4858 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004859 if (spec->autocfg.dig_in_pin)
4860 spec->dig_in_nid = ALC880_DIGIN_NID;
4861
Takashi Iwai603c4012008-07-30 15:01:44 +02004862 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004863 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004864
Takashi Iwaid88897e2008-10-31 15:01:37 +01004865 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004866
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004867 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004868 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004869
Kailang Yang6227cdc2010-02-25 08:36:52 +01004870 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004871
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004872 return 1;
4873}
4874
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004875/* additional initialization for auto-configuration model */
4876static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004877{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004878 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004879 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004880 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004881 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004882 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004883 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004884}
4885
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004886/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4887 * one of two digital mic pins, e.g. on ALC272
4888 */
4889static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004890{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004891 struct alc_spec *spec = codec->spec;
4892 int i;
4893
4894 for (i = 0; i < spec->num_adc_nids; i++) {
4895 hda_nid_t cap = spec->capsrc_nids ?
4896 spec->capsrc_nids[i] : spec->adc_nids[i];
4897 int iidx, eidx;
4898
4899 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4900 if (iidx < 0)
4901 continue;
4902 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4903 if (eidx < 0)
4904 continue;
4905 spec->int_mic.mux_idx = iidx;
4906 spec->ext_mic.mux_idx = eidx;
4907 if (spec->capsrc_nids)
4908 spec->capsrc_nids += i;
4909 spec->adc_nids += i;
4910 spec->num_adc_nids = 1;
4911 return;
4912 }
4913 snd_printd(KERN_INFO "hda_codec: %s: "
4914 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4915 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4916 spec->auto_mic = 0; /* disable auto-mic to be sure */
4917}
4918
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004919/* choose the ADC/MUX containing the input pin and initialize the setup */
4920static void fixup_single_adc(struct hda_codec *codec)
4921{
4922 struct alc_spec *spec = codec->spec;
Frederik Deweerdtd2db09b2010-03-05 16:34:31 +01004923 hda_nid_t pin = 0;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004924 int i;
4925
4926 /* search for the input pin; there must be only one */
4927 for (i = 0; i < AUTO_PIN_LAST; i++) {
4928 if (spec->autocfg.input_pins[i]) {
4929 pin = spec->autocfg.input_pins[i];
4930 break;
4931 }
4932 }
4933 if (!pin)
4934 return;
4935
4936 /* set the default connection to that pin */
4937 for (i = 0; i < spec->num_adc_nids; i++) {
4938 hda_nid_t cap = spec->capsrc_nids ?
4939 spec->capsrc_nids[i] : spec->adc_nids[i];
4940 int idx;
4941
4942 idx = get_connection_index(codec, cap, pin);
4943 if (idx < 0)
4944 continue;
4945 /* use only this ADC */
4946 if (spec->capsrc_nids)
4947 spec->capsrc_nids += i;
4948 spec->adc_nids += i;
4949 spec->num_adc_nids = 1;
4950 /* select or unmute this route */
4951 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
4952 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
4953 HDA_AMP_MUTE, 0);
4954 } else {
4955 snd_hda_codec_write_cache(codec, cap, 0,
4956 AC_VERB_SET_CONNECT_SEL, idx);
4957 }
4958 return;
4959 }
4960}
4961
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004962static void set_capture_mixer(struct hda_codec *codec)
4963{
4964 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004965 static struct snd_kcontrol_new *caps[2][3] = {
4966 { alc_capture_mixer_nosrc1,
4967 alc_capture_mixer_nosrc2,
4968 alc_capture_mixer_nosrc3 },
4969 { alc_capture_mixer1,
4970 alc_capture_mixer2,
4971 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004972 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004973 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004974 int mux = 0;
4975 if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004976 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004977 else if (spec->input_mux) {
4978 if (spec->input_mux->num_items > 1)
4979 mux = 1;
4980 else if (spec->input_mux->num_items == 1)
4981 fixup_single_adc(codec);
4982 }
Takashi Iwaia23b6882009-03-23 15:21:36 +01004983 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4984 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004985}
4986
Takashi Iwai66946352010-03-29 17:21:45 +02004987/* fill adc_nids (and capsrc_nids) containing all active input pins */
4988static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
4989 int num_nids)
4990{
4991 struct alc_spec *spec = codec->spec;
4992 int n;
4993 hda_nid_t fallback_adc = 0, fallback_cap = 0;
4994
4995 for (n = 0; n < num_nids; n++) {
4996 hda_nid_t adc, cap;
4997 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
4998 int nconns, i, j;
4999
5000 adc = nids[n];
5001 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5002 continue;
5003 cap = adc;
5004 nconns = snd_hda_get_connections(codec, cap, conn,
5005 ARRAY_SIZE(conn));
5006 if (nconns == 1) {
5007 cap = conn[0];
5008 nconns = snd_hda_get_connections(codec, cap, conn,
5009 ARRAY_SIZE(conn));
5010 }
5011 if (nconns <= 0)
5012 continue;
5013 if (!fallback_adc) {
5014 fallback_adc = adc;
5015 fallback_cap = cap;
5016 }
5017 for (i = 0; i < AUTO_PIN_LAST; i++) {
5018 hda_nid_t nid = spec->autocfg.input_pins[i];
5019 if (!nid)
5020 continue;
5021 for (j = 0; j < nconns; j++) {
5022 if (conn[j] == nid)
5023 break;
5024 }
5025 if (j >= nconns)
5026 break;
5027 }
5028 if (i >= AUTO_PIN_LAST) {
5029 int num_adcs = spec->num_adc_nids;
5030 spec->private_adc_nids[num_adcs] = adc;
5031 spec->private_capsrc_nids[num_adcs] = cap;
5032 spec->num_adc_nids++;
5033 spec->adc_nids = spec->private_adc_nids;
5034 if (adc != cap)
5035 spec->capsrc_nids = spec->private_capsrc_nids;
5036 }
5037 }
5038 if (!spec->num_adc_nids) {
5039 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005040 " using fallback 0x%x\n",
5041 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005042 spec->private_adc_nids[0] = fallback_adc;
5043 spec->adc_nids = spec->private_adc_nids;
5044 if (fallback_adc != fallback_cap) {
5045 spec->private_capsrc_nids[0] = fallback_cap;
5046 spec->capsrc_nids = spec->private_adc_nids;
5047 }
5048 }
5049}
5050
Takashi Iwai67d634c2009-11-16 15:35:59 +01005051#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005052#define set_beep_amp(spec, nid, idx, dir) \
5053 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01005054#else
5055#define set_beep_amp(spec, nid, idx, dir) /* NOP */
5056#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005057
5058/*
5059 * OK, here we have finally the patch for ALC880
5060 */
5061
Linus Torvalds1da177e2005-04-16 15:20:36 -07005062static int patch_alc880(struct hda_codec *codec)
5063{
5064 struct alc_spec *spec;
5065 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005066 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005067
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005068 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005069 if (spec == NULL)
5070 return -ENOMEM;
5071
5072 codec->spec = spec;
5073
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005074 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5075 alc880_models,
5076 alc880_cfg_tbl);
5077 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005078 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5079 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005080 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005081 }
5082
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005083 if (board_config == ALC880_AUTO) {
5084 /* automatic parse from the BIOS config */
5085 err = alc880_parse_auto_config(codec);
5086 if (err < 0) {
5087 alc_free(codec);
5088 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005089 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005090 printk(KERN_INFO
5091 "hda_codec: Cannot set up configuration "
5092 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005093 board_config = ALC880_3ST;
5094 }
5095 }
5096
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005097 err = snd_hda_attach_beep_device(codec, 0x1);
5098 if (err < 0) {
5099 alc_free(codec);
5100 return err;
5101 }
5102
Kailang Yangdf694da2005-12-05 19:42:22 +01005103 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005104 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005105
Linus Torvalds1da177e2005-04-16 15:20:36 -07005106 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5107 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005108 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005109
Linus Torvalds1da177e2005-04-16 15:20:36 -07005110 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5111 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5112
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005113 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005114 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005115 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005116 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005117 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005118 if (wcap != AC_WID_AUD_IN) {
5119 spec->adc_nids = alc880_adc_nids_alt;
5120 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005121 } else {
5122 spec->adc_nids = alc880_adc_nids;
5123 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005124 }
5125 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005126 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005127 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005128
Takashi Iwai2134ea42008-01-10 16:53:55 +01005129 spec->vmaster_nid = 0x0c;
5130
Linus Torvalds1da177e2005-04-16 15:20:36 -07005131 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005132 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005133 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005134#ifdef CONFIG_SND_HDA_POWER_SAVE
5135 if (!spec->loopback.amplist)
5136 spec->loopback.amplist = alc880_loopbacks;
5137#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005138
5139 return 0;
5140}
5141
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005142
Linus Torvalds1da177e2005-04-16 15:20:36 -07005143/*
5144 * ALC260 support
5145 */
5146
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005147static hda_nid_t alc260_dac_nids[1] = {
5148 /* front */
5149 0x02,
5150};
5151
5152static hda_nid_t alc260_adc_nids[1] = {
5153 /* ADC0 */
5154 0x04,
5155};
5156
Kailang Yangdf694da2005-12-05 19:42:22 +01005157static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005158 /* ADC1 */
5159 0x05,
5160};
5161
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005162/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5163 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5164 */
5165static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005166 /* ADC0, ADC1 */
5167 0x04, 0x05
5168};
5169
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005170#define ALC260_DIGOUT_NID 0x03
5171#define ALC260_DIGIN_NID 0x06
5172
5173static struct hda_input_mux alc260_capture_source = {
5174 .num_items = 4,
5175 .items = {
5176 { "Mic", 0x0 },
5177 { "Front Mic", 0x1 },
5178 { "Line", 0x2 },
5179 { "CD", 0x4 },
5180 },
5181};
5182
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005183/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005184 * headphone jack and the internal CD lines since these are the only pins at
5185 * which audio can appear. For flexibility, also allow the option of
5186 * recording the mixer output on the second ADC (ADC0 doesn't have a
5187 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005188 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005189static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5190 {
5191 .num_items = 3,
5192 .items = {
5193 { "Mic/Line", 0x0 },
5194 { "CD", 0x4 },
5195 { "Headphone", 0x2 },
5196 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005197 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005198 {
5199 .num_items = 4,
5200 .items = {
5201 { "Mic/Line", 0x0 },
5202 { "CD", 0x4 },
5203 { "Headphone", 0x2 },
5204 { "Mixer", 0x5 },
5205 },
5206 },
5207
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005208};
5209
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005210/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5211 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005212 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005213static struct hda_input_mux alc260_acer_capture_sources[2] = {
5214 {
5215 .num_items = 4,
5216 .items = {
5217 { "Mic", 0x0 },
5218 { "Line", 0x2 },
5219 { "CD", 0x4 },
5220 { "Headphone", 0x5 },
5221 },
5222 },
5223 {
5224 .num_items = 5,
5225 .items = {
5226 { "Mic", 0x0 },
5227 { "Line", 0x2 },
5228 { "CD", 0x4 },
5229 { "Headphone", 0x6 },
5230 { "Mixer", 0x5 },
5231 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005232 },
5233};
Michael Schwingencc959482009-02-22 18:58:45 +01005234
5235/* Maxdata Favorit 100XS */
5236static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5237 {
5238 .num_items = 2,
5239 .items = {
5240 { "Line/Mic", 0x0 },
5241 { "CD", 0x4 },
5242 },
5243 },
5244 {
5245 .num_items = 3,
5246 .items = {
5247 { "Line/Mic", 0x0 },
5248 { "CD", 0x4 },
5249 { "Mixer", 0x5 },
5250 },
5251 },
5252};
5253
Linus Torvalds1da177e2005-04-16 15:20:36 -07005254/*
5255 * This is just place-holder, so there's something for alc_build_pcms to look
5256 * at when it calculates the maximum number of channels. ALC260 has no mixer
5257 * element which allows changing the channel mode, so the verb list is
5258 * never used.
5259 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005260static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005261 { 2, NULL },
5262};
5263
Kailang Yangdf694da2005-12-05 19:42:22 +01005264
5265/* Mixer combinations
5266 *
5267 * basic: base_output + input + pc_beep + capture
5268 * HP: base_output + input + capture_alt
5269 * HP_3013: hp_3013 + input + capture
5270 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005271 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005272 */
5273
5274static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005275 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005276 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005277 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5278 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5279 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5280 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5281 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005282};
Kailang Yangdf694da2005-12-05 19:42:22 +01005283
5284static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005285 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5286 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5287 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5288 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5289 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5290 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5291 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5292 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005293 { } /* end */
5294};
5295
Takashi Iwaibec15c32008-01-28 18:16:30 +01005296/* update HP, line and mono out pins according to the master switch */
5297static void alc260_hp_master_update(struct hda_codec *codec,
5298 hda_nid_t hp, hda_nid_t line,
5299 hda_nid_t mono)
5300{
5301 struct alc_spec *spec = codec->spec;
5302 unsigned int val = spec->master_sw ? PIN_HP : 0;
5303 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005304 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005305 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005306 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005307 val);
5308 /* mono (speaker) depending on the HP jack sense */
5309 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005310 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005311 val);
5312}
5313
5314static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5315 struct snd_ctl_elem_value *ucontrol)
5316{
5317 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5318 struct alc_spec *spec = codec->spec;
5319 *ucontrol->value.integer.value = spec->master_sw;
5320 return 0;
5321}
5322
5323static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5324 struct snd_ctl_elem_value *ucontrol)
5325{
5326 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5327 struct alc_spec *spec = codec->spec;
5328 int val = !!*ucontrol->value.integer.value;
5329 hda_nid_t hp, line, mono;
5330
5331 if (val == spec->master_sw)
5332 return 0;
5333 spec->master_sw = val;
5334 hp = (kcontrol->private_value >> 16) & 0xff;
5335 line = (kcontrol->private_value >> 8) & 0xff;
5336 mono = kcontrol->private_value & 0xff;
5337 alc260_hp_master_update(codec, hp, line, mono);
5338 return 1;
5339}
5340
5341static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5342 {
5343 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5344 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005345 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005346 .info = snd_ctl_boolean_mono_info,
5347 .get = alc260_hp_master_sw_get,
5348 .put = alc260_hp_master_sw_put,
5349 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5350 },
5351 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5352 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5353 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5354 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5355 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5356 HDA_OUTPUT),
5357 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5358 { } /* end */
5359};
5360
5361static struct hda_verb alc260_hp_unsol_verbs[] = {
5362 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5363 {},
5364};
5365
5366static void alc260_hp_automute(struct hda_codec *codec)
5367{
5368 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005369
Wu Fengguang864f92b2009-11-18 12:38:02 +08005370 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005371 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5372}
5373
5374static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5375{
5376 if ((res >> 26) == ALC880_HP_EVENT)
5377 alc260_hp_automute(codec);
5378}
5379
Kailang Yangdf694da2005-12-05 19:42:22 +01005380static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005381 {
5382 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5383 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005384 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005385 .info = snd_ctl_boolean_mono_info,
5386 .get = alc260_hp_master_sw_get,
5387 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005388 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005389 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005390 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5391 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5392 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5393 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5394 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5395 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005396 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5397 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005398 { } /* end */
5399};
5400
Kailang Yang3f878302008-08-26 13:02:23 +02005401static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5402 .ops = &snd_hda_bind_vol,
5403 .values = {
5404 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5405 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5406 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5407 0
5408 },
5409};
5410
5411static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5412 .ops = &snd_hda_bind_sw,
5413 .values = {
5414 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5415 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5416 0
5417 },
5418};
5419
5420static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5421 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5422 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5423 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5424 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5425 { } /* end */
5426};
5427
Takashi Iwaibec15c32008-01-28 18:16:30 +01005428static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5429 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5430 {},
5431};
5432
5433static void alc260_hp_3013_automute(struct hda_codec *codec)
5434{
5435 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005436
Wu Fengguang864f92b2009-11-18 12:38:02 +08005437 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005438 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005439}
5440
5441static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5442 unsigned int res)
5443{
5444 if ((res >> 26) == ALC880_HP_EVENT)
5445 alc260_hp_3013_automute(codec);
5446}
5447
Kailang Yang3f878302008-08-26 13:02:23 +02005448static void alc260_hp_3012_automute(struct hda_codec *codec)
5449{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005450 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005451
Kailang Yang3f878302008-08-26 13:02:23 +02005452 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5453 bits);
5454 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5455 bits);
5456 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5457 bits);
5458}
5459
5460static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5461 unsigned int res)
5462{
5463 if ((res >> 26) == ALC880_HP_EVENT)
5464 alc260_hp_3012_automute(codec);
5465}
5466
5467/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005468 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5469 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005470static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005471 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005472 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005473 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005474 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5475 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5476 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5477 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005478 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005479 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5480 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005481 { } /* end */
5482};
5483
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005484/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5485 * versions of the ALC260 don't act on requests to enable mic bias from NID
5486 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5487 * datasheet doesn't mention this restriction. At this stage it's not clear
5488 * whether this behaviour is intentional or is a hardware bug in chip
5489 * revisions available in early 2006. Therefore for now allow the
5490 * "Headphone Jack Mode" control to span all choices, but if it turns out
5491 * that the lack of mic bias for this NID is intentional we could change the
5492 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5493 *
5494 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5495 * don't appear to make the mic bias available from the "line" jack, even
5496 * though the NID used for this jack (0x14) can supply it. The theory is
5497 * that perhaps Acer have included blocking capacitors between the ALC260
5498 * and the output jack. If this turns out to be the case for all such
5499 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5500 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005501 *
5502 * The C20x Tablet series have a mono internal speaker which is controlled
5503 * via the chip's Mono sum widget and pin complex, so include the necessary
5504 * controls for such models. On models without a "mono speaker" the control
5505 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005506 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005507static struct snd_kcontrol_new alc260_acer_mixer[] = {
5508 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5509 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005510 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005511 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005512 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005513 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005514 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005515 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5516 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5517 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5518 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5519 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5520 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5521 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5522 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005523 { } /* end */
5524};
5525
Michael Schwingencc959482009-02-22 18:58:45 +01005526/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5527 */
5528static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5529 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5530 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5531 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5532 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5533 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5534 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5535 { } /* end */
5536};
5537
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005538/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5539 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5540 */
5541static struct snd_kcontrol_new alc260_will_mixer[] = {
5542 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5543 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5544 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5545 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5546 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5547 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5548 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5549 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5550 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5551 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005552 { } /* end */
5553};
5554
5555/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5556 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5557 */
5558static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5559 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5560 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5561 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5562 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5563 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5564 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5565 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5566 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5567 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5568 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5569 { } /* end */
5570};
5571
Kailang Yangdf694da2005-12-05 19:42:22 +01005572/*
5573 * initialization verbs
5574 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005575static struct hda_verb alc260_init_verbs[] = {
5576 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005577 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005578 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005579 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005580 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005581 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005582 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005583 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005584 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005585 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005586 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005587 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005588 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005589 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005590 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005591 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005592 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005593 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5594 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005595 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005596 /* set connection select to line in (default select for this ADC) */
5597 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005598 /* mute capture amp left and right */
5599 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5600 /* set connection select to line in (default select for this ADC) */
5601 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005602 /* set vol=0 Line-Out mixer amp left and right */
5603 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5604 /* unmute pin widget amp left and right (no gain on this amp) */
5605 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5606 /* set vol=0 HP mixer amp left and right */
5607 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5608 /* unmute pin widget amp left and right (no gain on this amp) */
5609 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5610 /* set vol=0 Mono mixer amp left and right */
5611 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5612 /* unmute pin widget amp left and right (no gain on this amp) */
5613 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5614 /* unmute LINE-2 out pin */
5615 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005616 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5617 * Line In 2 = 0x03
5618 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005619 /* mute analog inputs */
5620 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5621 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5622 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5623 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5624 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005625 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005626 /* mute Front out path */
5627 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5628 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5629 /* mute Headphone out path */
5630 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5631 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5632 /* mute Mono out path */
5633 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5634 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005635 { }
5636};
5637
Takashi Iwai474167d2006-05-17 17:17:43 +02005638#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005639static struct hda_verb alc260_hp_init_verbs[] = {
5640 /* Headphone and output */
5641 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5642 /* mono output */
5643 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5644 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5645 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5646 /* Mic2 (front panel) pin widget for input and vref at 80% */
5647 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5648 /* Line In pin widget for input */
5649 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5650 /* Line-2 pin widget for output */
5651 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5652 /* CD pin widget for input */
5653 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5654 /* unmute amp left and right */
5655 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5656 /* set connection select to line in (default select for this ADC) */
5657 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5658 /* unmute Line-Out mixer amp left and right (volume = 0) */
5659 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5660 /* mute pin widget amp left and right (no gain on this amp) */
5661 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5662 /* unmute HP mixer amp left and right (volume = 0) */
5663 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5664 /* mute pin widget amp left and right (no gain on this amp) */
5665 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005666 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5667 * Line In 2 = 0x03
5668 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005669 /* mute analog inputs */
5670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5671 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5673 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005675 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5676 /* Unmute Front out path */
5677 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5678 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5679 /* Unmute Headphone out path */
5680 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5681 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5682 /* Unmute Mono out path */
5683 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5684 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5685 { }
5686};
Takashi Iwai474167d2006-05-17 17:17:43 +02005687#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005688
5689static struct hda_verb alc260_hp_3013_init_verbs[] = {
5690 /* Line out and output */
5691 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5692 /* mono output */
5693 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5694 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5695 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5696 /* Mic2 (front panel) pin widget for input and vref at 80% */
5697 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5698 /* Line In pin widget for input */
5699 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5700 /* Headphone pin widget for output */
5701 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5702 /* CD pin widget for input */
5703 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5704 /* unmute amp left and right */
5705 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5706 /* set connection select to line in (default select for this ADC) */
5707 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5708 /* unmute Line-Out mixer amp left and right (volume = 0) */
5709 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5710 /* mute pin widget amp left and right (no gain on this amp) */
5711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5712 /* unmute HP mixer amp left and right (volume = 0) */
5713 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5714 /* mute pin widget amp left and right (no gain on this amp) */
5715 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005716 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5717 * Line In 2 = 0x03
5718 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005719 /* mute analog inputs */
5720 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5721 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5722 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5723 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5724 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005725 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5726 /* Unmute Front out path */
5727 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5728 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5729 /* Unmute Headphone out path */
5730 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5731 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5732 /* Unmute Mono out path */
5733 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5734 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5735 { }
5736};
5737
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005738/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005739 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5740 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005741 */
5742static struct hda_verb alc260_fujitsu_init_verbs[] = {
5743 /* Disable all GPIOs */
5744 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5745 /* Internal speaker is connected to headphone pin */
5746 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5747 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5748 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005749 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5750 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5751 /* Ensure all other unused pins are disabled and muted. */
5752 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5753 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005754 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005755 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005756 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005757 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5758 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5759 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005760
Jonathan Woithef7ace402006-02-28 11:46:14 +01005761 /* Disable digital (SPDIF) pins */
5762 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5763 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005764
Kailang Yangea1fb292008-08-26 12:58:38 +02005765 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005766 * when acting as an output.
5767 */
5768 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5769
5770 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005771 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5772 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5773 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5774 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5775 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5776 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5777 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5778 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5779 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005780
Jonathan Woithef7ace402006-02-28 11:46:14 +01005781 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5782 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5783 /* Unmute Line1 pin widget output buffer since it starts as an output.
5784 * If the pin mode is changed by the user the pin mode control will
5785 * take care of enabling the pin's input/output buffers as needed.
5786 * Therefore there's no need to enable the input buffer at this
5787 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005788 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005789 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005790 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005791 * mixer ctrl)
5792 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005793 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005794
Jonathan Woithef7ace402006-02-28 11:46:14 +01005795 /* Mute capture amp left and right */
5796 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005797 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005798 * in (on mic1 pin)
5799 */
5800 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005801
Jonathan Woithef7ace402006-02-28 11:46:14 +01005802 /* Do the same for the second ADC: mute capture input amp and
5803 * set ADC connection to line in (on mic1 pin)
5804 */
5805 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5806 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005807
Jonathan Woithef7ace402006-02-28 11:46:14 +01005808 /* Mute all inputs to mixer widget (even unconnected ones) */
5809 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5810 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5811 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5812 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5813 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5814 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5815 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5816 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005817
5818 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005819};
5820
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005821/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5822 * similar laptops (adapted from Fujitsu init verbs).
5823 */
5824static struct hda_verb alc260_acer_init_verbs[] = {
5825 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5826 * the headphone jack. Turn this on and rely on the standard mute
5827 * methods whenever the user wants to turn these outputs off.
5828 */
5829 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5830 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5831 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5832 /* Internal speaker/Headphone jack is connected to Line-out pin */
5833 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5834 /* Internal microphone/Mic jack is connected to Mic1 pin */
5835 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5836 /* Line In jack is connected to Line1 pin */
5837 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005838 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5839 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005840 /* Ensure all other unused pins are disabled and muted. */
5841 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5842 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005843 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5844 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5845 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5846 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5847 /* Disable digital (SPDIF) pins */
5848 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5849 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5850
Kailang Yangea1fb292008-08-26 12:58:38 +02005851 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005852 * bus when acting as outputs.
5853 */
5854 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5855 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5856
5857 /* Start with output sum widgets muted and their output gains at min */
5858 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5859 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5860 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5861 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5862 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5863 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5864 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5865 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5866 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5867
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005868 /* Unmute Line-out pin widget amp left and right
5869 * (no equiv mixer ctrl)
5870 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005871 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005872 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5873 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005874 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5875 * inputs. If the pin mode is changed by the user the pin mode control
5876 * will take care of enabling the pin's input/output buffers as needed.
5877 * Therefore there's no need to enable the input buffer at this
5878 * stage.
5879 */
5880 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5881 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5882
5883 /* Mute capture amp left and right */
5884 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5885 /* Set ADC connection select to match default mixer setting - mic
5886 * (on mic1 pin)
5887 */
5888 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5889
5890 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005891 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005892 */
5893 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005894 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005895
5896 /* Mute all inputs to mixer widget (even unconnected ones) */
5897 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5898 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5899 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5900 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5901 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5902 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5903 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5904 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5905
5906 { }
5907};
5908
Michael Schwingencc959482009-02-22 18:58:45 +01005909/* Initialisation sequence for Maxdata Favorit 100XS
5910 * (adapted from Acer init verbs).
5911 */
5912static struct hda_verb alc260_favorit100_init_verbs[] = {
5913 /* GPIO 0 enables the output jack.
5914 * Turn this on and rely on the standard mute
5915 * methods whenever the user wants to turn these outputs off.
5916 */
5917 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5918 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5919 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5920 /* Line/Mic input jack is connected to Mic1 pin */
5921 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5922 /* Ensure all other unused pins are disabled and muted. */
5923 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5924 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5925 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5926 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5927 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5928 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5929 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5930 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5931 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5932 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5933 /* Disable digital (SPDIF) pins */
5934 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5935 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5936
5937 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5938 * bus when acting as outputs.
5939 */
5940 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5941 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5942
5943 /* Start with output sum widgets muted and their output gains at min */
5944 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5945 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5946 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5947 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5948 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5949 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5950 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5951 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5952 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5953
5954 /* Unmute Line-out pin widget amp left and right
5955 * (no equiv mixer ctrl)
5956 */
5957 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5958 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5959 * inputs. If the pin mode is changed by the user the pin mode control
5960 * will take care of enabling the pin's input/output buffers as needed.
5961 * Therefore there's no need to enable the input buffer at this
5962 * stage.
5963 */
5964 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5965
5966 /* Mute capture amp left and right */
5967 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5968 /* Set ADC connection select to match default mixer setting - mic
5969 * (on mic1 pin)
5970 */
5971 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5972
5973 /* Do similar with the second ADC: mute capture input amp and
5974 * set ADC connection to mic to match ALSA's default state.
5975 */
5976 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5977 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5978
5979 /* Mute all inputs to mixer widget (even unconnected ones) */
5980 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5981 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5982 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5983 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5984 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5985 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5986 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5987 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5988
5989 { }
5990};
5991
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005992static struct hda_verb alc260_will_verbs[] = {
5993 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5994 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5995 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5996 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5997 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5998 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5999 {}
6000};
6001
6002static struct hda_verb alc260_replacer_672v_verbs[] = {
6003 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6004 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6005 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6006
6007 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6008 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6009 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6010
6011 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6012 {}
6013};
6014
6015/* toggle speaker-output according to the hp-jack state */
6016static void alc260_replacer_672v_automute(struct hda_codec *codec)
6017{
6018 unsigned int present;
6019
6020 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006021 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006022 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006023 snd_hda_codec_write_cache(codec, 0x01, 0,
6024 AC_VERB_SET_GPIO_DATA, 1);
6025 snd_hda_codec_write_cache(codec, 0x0f, 0,
6026 AC_VERB_SET_PIN_WIDGET_CONTROL,
6027 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006028 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006029 snd_hda_codec_write_cache(codec, 0x01, 0,
6030 AC_VERB_SET_GPIO_DATA, 0);
6031 snd_hda_codec_write_cache(codec, 0x0f, 0,
6032 AC_VERB_SET_PIN_WIDGET_CONTROL,
6033 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006034 }
6035}
6036
6037static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6038 unsigned int res)
6039{
6040 if ((res >> 26) == ALC880_HP_EVENT)
6041 alc260_replacer_672v_automute(codec);
6042}
6043
Kailang Yang3f878302008-08-26 13:02:23 +02006044static struct hda_verb alc260_hp_dc7600_verbs[] = {
6045 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6046 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6047 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6048 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6049 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6050 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6051 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6052 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6053 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6054 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6055 {}
6056};
6057
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006058/* Test configuration for debugging, modelled after the ALC880 test
6059 * configuration.
6060 */
6061#ifdef CONFIG_SND_DEBUG
6062static hda_nid_t alc260_test_dac_nids[1] = {
6063 0x02,
6064};
6065static hda_nid_t alc260_test_adc_nids[2] = {
6066 0x04, 0x05,
6067};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006068/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006069 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006070 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006071 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006072static struct hda_input_mux alc260_test_capture_sources[2] = {
6073 {
6074 .num_items = 7,
6075 .items = {
6076 { "MIC1 pin", 0x0 },
6077 { "MIC2 pin", 0x1 },
6078 { "LINE1 pin", 0x2 },
6079 { "LINE2 pin", 0x3 },
6080 { "CD pin", 0x4 },
6081 { "LINE-OUT pin", 0x5 },
6082 { "HP-OUT pin", 0x6 },
6083 },
6084 },
6085 {
6086 .num_items = 8,
6087 .items = {
6088 { "MIC1 pin", 0x0 },
6089 { "MIC2 pin", 0x1 },
6090 { "LINE1 pin", 0x2 },
6091 { "LINE2 pin", 0x3 },
6092 { "CD pin", 0x4 },
6093 { "Mixer", 0x5 },
6094 { "LINE-OUT pin", 0x6 },
6095 { "HP-OUT pin", 0x7 },
6096 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006097 },
6098};
6099static struct snd_kcontrol_new alc260_test_mixer[] = {
6100 /* Output driver widgets */
6101 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6102 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6103 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6104 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6105 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6106 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6107
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006108 /* Modes for retasking pin widgets
6109 * Note: the ALC260 doesn't seem to act on requests to enable mic
6110 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6111 * mention this restriction. At this stage it's not clear whether
6112 * this behaviour is intentional or is a hardware bug in chip
6113 * revisions available at least up until early 2006. Therefore for
6114 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6115 * choices, but if it turns out that the lack of mic bias for these
6116 * NIDs is intentional we could change their modes from
6117 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6118 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006119 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6120 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6121 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6122 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6123 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6124 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6125
6126 /* Loopback mixer controls */
6127 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6128 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6129 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6130 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6131 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6132 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6133 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6134 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6135 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6136 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006137 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6138 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6139 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6140 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006141
6142 /* Controls for GPIO pins, assuming they are configured as outputs */
6143 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6144 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6145 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6146 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6147
Jonathan Woithe92621f12006-02-28 11:47:47 +01006148 /* Switches to allow the digital IO pins to be enabled. The datasheet
6149 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006150 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006151 */
6152 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6153 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6154
Jonathan Woithef8225f62008-01-08 12:16:54 +01006155 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6156 * this output to turn on an external amplifier.
6157 */
6158 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6159 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6160
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006161 { } /* end */
6162};
6163static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006164 /* Enable all GPIOs as outputs with an initial value of 0 */
6165 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6166 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6167 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6168
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006169 /* Enable retasking pins as output, initially without power amp */
6170 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6171 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6172 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6173 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6174 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6175 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6176
Jonathan Woithe92621f12006-02-28 11:47:47 +01006177 /* Disable digital (SPDIF) pins initially, but users can enable
6178 * them via a mixer switch. In the case of SPDIF-out, this initverb
6179 * payload also sets the generation to 0, output to be in "consumer"
6180 * PCM format, copyright asserted, no pre-emphasis and no validity
6181 * control.
6182 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006183 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6184 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6185
Kailang Yangea1fb292008-08-26 12:58:38 +02006186 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006187 * OUT1 sum bus when acting as an output.
6188 */
6189 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6190 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6191 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6192 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6193
6194 /* Start with output sum widgets muted and their output gains at min */
6195 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6196 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6197 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6198 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6199 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6200 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6201 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6202 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6203 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6204
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006205 /* Unmute retasking pin widget output buffers since the default
6206 * state appears to be output. As the pin mode is changed by the
6207 * user the pin mode control will take care of enabling the pin's
6208 * input/output buffers as needed.
6209 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006210 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6211 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6212 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6213 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6214 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6215 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6216 /* Also unmute the mono-out pin widget */
6217 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6218
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006219 /* Mute capture amp left and right */
6220 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006221 /* Set ADC connection select to match default mixer setting (mic1
6222 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006223 */
6224 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6225
6226 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006227 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006228 */
6229 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6230 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6231
6232 /* Mute all inputs to mixer widget (even unconnected ones) */
6233 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6234 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6235 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6236 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6237 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6238 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6239 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6240 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6241
6242 { }
6243};
6244#endif
6245
Takashi Iwai63300792008-01-24 15:31:36 +01006246#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6247#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006248
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006249#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6250#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6251
Kailang Yangdf694da2005-12-05 19:42:22 +01006252/*
6253 * for BIOS auto-configuration
6254 */
6255
6256static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006257 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006258{
6259 hda_nid_t nid_vol;
6260 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006261 int err;
6262
6263 if (nid >= 0x0f && nid < 0x11) {
6264 nid_vol = nid - 0x7;
6265 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6266 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6267 } else if (nid == 0x11) {
6268 nid_vol = nid - 0x7;
6269 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6270 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6271 } else if (nid >= 0x12 && nid <= 0x15) {
6272 nid_vol = 0x08;
6273 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6274 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6275 } else
6276 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006277
Takashi Iwai863b4512008-10-21 17:01:47 +02006278 if (!(*vol_bits & (1 << nid_vol))) {
6279 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006280 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006281 if (err < 0)
6282 return err;
6283 *vol_bits |= (1 << nid_vol);
6284 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006285 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006286 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006287 return err;
6288 return 1;
6289}
6290
6291/* add playback controls from the parsed DAC table */
6292static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6293 const struct auto_pin_cfg *cfg)
6294{
6295 hda_nid_t nid;
6296 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006297 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006298
6299 spec->multiout.num_dacs = 1;
6300 spec->multiout.dac_nids = spec->private_dac_nids;
6301 spec->multiout.dac_nids[0] = 0x02;
6302
6303 nid = cfg->line_out_pins[0];
6304 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006305 const char *pfx;
6306 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6307 pfx = "Master";
6308 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6309 pfx = "Speaker";
6310 else
6311 pfx = "Front";
6312 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006313 if (err < 0)
6314 return err;
6315 }
6316
Takashi Iwai82bc9552006-03-21 11:24:42 +01006317 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006318 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006319 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006320 if (err < 0)
6321 return err;
6322 }
6323
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006324 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006325 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006326 err = alc260_add_playback_controls(spec, nid, "Headphone",
6327 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006328 if (err < 0)
6329 return err;
6330 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006331 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006332}
6333
6334/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006335static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006336 const struct auto_pin_cfg *cfg)
6337{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006338 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006339}
6340
6341static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6342 hda_nid_t nid, int pin_type,
6343 int sel_idx)
6344{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006345 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006346 /* need the manual connection? */
6347 if (nid >= 0x12) {
6348 int idx = nid - 0x12;
6349 snd_hda_codec_write(codec, idx + 0x0b, 0,
6350 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006351 }
6352}
6353
6354static void alc260_auto_init_multi_out(struct hda_codec *codec)
6355{
6356 struct alc_spec *spec = codec->spec;
6357 hda_nid_t nid;
6358
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006359 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006360 if (nid) {
6361 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6362 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6363 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006364
Takashi Iwai82bc9552006-03-21 11:24:42 +01006365 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006366 if (nid)
6367 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6368
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006369 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006370 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006371 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006372}
Kailang Yangdf694da2005-12-05 19:42:22 +01006373
6374#define ALC260_PIN_CD_NID 0x16
6375static void alc260_auto_init_analog_input(struct hda_codec *codec)
6376{
6377 struct alc_spec *spec = codec->spec;
6378 int i;
6379
6380 for (i = 0; i < AUTO_PIN_LAST; i++) {
6381 hda_nid_t nid = spec->autocfg.input_pins[i];
6382 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006383 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006384 if (nid != ALC260_PIN_CD_NID &&
6385 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006386 snd_hda_codec_write(codec, nid, 0,
6387 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006388 AMP_OUT_MUTE);
6389 }
6390 }
6391}
6392
6393/*
6394 * generic initialization of ADC, input mixers and output mixers
6395 */
6396static struct hda_verb alc260_volume_init_verbs[] = {
6397 /*
6398 * Unmute ADC0-1 and set the default input to mic-in
6399 */
6400 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6401 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6402 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6403 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006404
Kailang Yangdf694da2005-12-05 19:42:22 +01006405 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6406 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006407 * Note: PASD motherboards uses the Line In 2 as the input for
6408 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006409 */
6410 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006411 /* mute analog inputs */
6412 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6413 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6414 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6415 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6416 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006417
6418 /*
6419 * Set up output mixers (0x08 - 0x0a)
6420 */
6421 /* set vol=0 to output mixers */
6422 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6423 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6424 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6425 /* set up input amps for analog loopback */
6426 /* Amp Indices: DAC = 0, mixer = 1 */
6427 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6428 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6429 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6430 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6431 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6432 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006433
Kailang Yangdf694da2005-12-05 19:42:22 +01006434 { }
6435};
6436
6437static int alc260_parse_auto_config(struct hda_codec *codec)
6438{
6439 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006440 int err;
6441 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6442
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006443 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6444 alc260_ignore);
6445 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006446 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006447 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6448 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006449 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006450 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006451 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006452 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006453 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006454 return err;
6455
6456 spec->multiout.max_channels = 2;
6457
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006458 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006459 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006460 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006461 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006462
Takashi Iwaid88897e2008-10-31 15:01:37 +01006463 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006464
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006465 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006466 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006467
Kailang Yang6227cdc2010-02-25 08:36:52 +01006468 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006469
Kailang Yangdf694da2005-12-05 19:42:22 +01006470 return 1;
6471}
6472
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006473/* additional initialization for auto-configuration model */
6474static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006475{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006476 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006477 alc260_auto_init_multi_out(codec);
6478 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006479 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006480 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006481}
6482
Takashi Iwaicb53c622007-08-10 17:21:45 +02006483#ifdef CONFIG_SND_HDA_POWER_SAVE
6484static struct hda_amp_list alc260_loopbacks[] = {
6485 { 0x07, HDA_INPUT, 0 },
6486 { 0x07, HDA_INPUT, 1 },
6487 { 0x07, HDA_INPUT, 2 },
6488 { 0x07, HDA_INPUT, 3 },
6489 { 0x07, HDA_INPUT, 4 },
6490 { } /* end */
6491};
6492#endif
6493
Kailang Yangdf694da2005-12-05 19:42:22 +01006494/*
6495 * ALC260 configurations
6496 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006497static const char *alc260_models[ALC260_MODEL_LAST] = {
6498 [ALC260_BASIC] = "basic",
6499 [ALC260_HP] = "hp",
6500 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006501 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006502 [ALC260_FUJITSU_S702X] = "fujitsu",
6503 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006504 [ALC260_WILL] = "will",
6505 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006506 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006507#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006508 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006509#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006510 [ALC260_AUTO] = "auto",
6511};
6512
6513static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006514 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006515 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006516 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006517 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006518 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006519 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006520 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006521 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006522 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006523 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6524 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6525 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6526 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6527 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6528 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6529 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6530 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6531 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006532 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006533 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006534 {}
6535};
6536
Kailang Yangdf694da2005-12-05 19:42:22 +01006537static struct alc_config_preset alc260_presets[] = {
6538 [ALC260_BASIC] = {
6539 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006540 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006541 .init_verbs = { alc260_init_verbs },
6542 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6543 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006544 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01006545 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006546 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6547 .channel_mode = alc260_modes,
6548 .input_mux = &alc260_capture_source,
6549 },
6550 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006551 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006552 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006553 .init_verbs = { alc260_init_verbs,
6554 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006555 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6556 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006557 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6558 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006559 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6560 .channel_mode = alc260_modes,
6561 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006562 .unsol_event = alc260_hp_unsol_event,
6563 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006564 },
Kailang Yang3f878302008-08-26 13:02:23 +02006565 [ALC260_HP_DC7600] = {
6566 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006567 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006568 .init_verbs = { alc260_init_verbs,
6569 alc260_hp_dc7600_verbs },
6570 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6571 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006572 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6573 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006574 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6575 .channel_mode = alc260_modes,
6576 .input_mux = &alc260_capture_source,
6577 .unsol_event = alc260_hp_3012_unsol_event,
6578 .init_hook = alc260_hp_3012_automute,
6579 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006580 [ALC260_HP_3013] = {
6581 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006582 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006583 .init_verbs = { alc260_hp_3013_init_verbs,
6584 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006585 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6586 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006587 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6588 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006589 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6590 .channel_mode = alc260_modes,
6591 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006592 .unsol_event = alc260_hp_3013_unsol_event,
6593 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006594 },
6595 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006596 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006597 .init_verbs = { alc260_fujitsu_init_verbs },
6598 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6599 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006600 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6601 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006602 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6603 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006604 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6605 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006606 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006607 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006608 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006609 .init_verbs = { alc260_acer_init_verbs },
6610 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6611 .dac_nids = alc260_dac_nids,
6612 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6613 .adc_nids = alc260_dual_adc_nids,
6614 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6615 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006616 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6617 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006618 },
Michael Schwingencc959482009-02-22 18:58:45 +01006619 [ALC260_FAVORIT100] = {
6620 .mixers = { alc260_favorit100_mixer },
6621 .init_verbs = { alc260_favorit100_init_verbs },
6622 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6623 .dac_nids = alc260_dac_nids,
6624 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6625 .adc_nids = alc260_dual_adc_nids,
6626 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6627 .channel_mode = alc260_modes,
6628 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6629 .input_mux = alc260_favorit100_capture_sources,
6630 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006631 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006632 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006633 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6634 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6635 .dac_nids = alc260_dac_nids,
6636 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6637 .adc_nids = alc260_adc_nids,
6638 .dig_out_nid = ALC260_DIGOUT_NID,
6639 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6640 .channel_mode = alc260_modes,
6641 .input_mux = &alc260_capture_source,
6642 },
6643 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006644 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006645 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6646 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6647 .dac_nids = alc260_dac_nids,
6648 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6649 .adc_nids = alc260_adc_nids,
6650 .dig_out_nid = ALC260_DIGOUT_NID,
6651 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6652 .channel_mode = alc260_modes,
6653 .input_mux = &alc260_capture_source,
6654 .unsol_event = alc260_replacer_672v_unsol_event,
6655 .init_hook = alc260_replacer_672v_automute,
6656 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006657#ifdef CONFIG_SND_DEBUG
6658 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006659 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006660 .init_verbs = { alc260_test_init_verbs },
6661 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6662 .dac_nids = alc260_test_dac_nids,
6663 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6664 .adc_nids = alc260_test_adc_nids,
6665 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6666 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006667 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6668 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006669 },
6670#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006671};
6672
Linus Torvalds1da177e2005-04-16 15:20:36 -07006673static int patch_alc260(struct hda_codec *codec)
6674{
6675 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006676 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006677
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006678 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006679 if (spec == NULL)
6680 return -ENOMEM;
6681
6682 codec->spec = spec;
6683
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006684 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6685 alc260_models,
6686 alc260_cfg_tbl);
6687 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006688 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006689 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006690 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006691 }
6692
Kailang Yangdf694da2005-12-05 19:42:22 +01006693 if (board_config == ALC260_AUTO) {
6694 /* automatic parse from the BIOS config */
6695 err = alc260_parse_auto_config(codec);
6696 if (err < 0) {
6697 alc_free(codec);
6698 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006699 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006700 printk(KERN_INFO
6701 "hda_codec: Cannot set up configuration "
6702 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006703 board_config = ALC260_BASIC;
6704 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006705 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006706
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006707 err = snd_hda_attach_beep_device(codec, 0x1);
6708 if (err < 0) {
6709 alc_free(codec);
6710 return err;
6711 }
6712
Kailang Yangdf694da2005-12-05 19:42:22 +01006713 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006714 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006715
Linus Torvalds1da177e2005-04-16 15:20:36 -07006716 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6717 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6718
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006719 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6720 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6721
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006722 if (!spec->adc_nids && spec->input_mux) {
6723 /* check whether NID 0x04 is valid */
6724 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006725 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006726 /* get type */
6727 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6728 spec->adc_nids = alc260_adc_nids_alt;
6729 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6730 } else {
6731 spec->adc_nids = alc260_adc_nids;
6732 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6733 }
6734 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006735 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006736 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006737
Takashi Iwai2134ea42008-01-10 16:53:55 +01006738 spec->vmaster_nid = 0x08;
6739
Linus Torvalds1da177e2005-04-16 15:20:36 -07006740 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006741 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006742 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006743#ifdef CONFIG_SND_HDA_POWER_SAVE
6744 if (!spec->loopback.amplist)
6745 spec->loopback.amplist = alc260_loopbacks;
6746#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006747
6748 return 0;
6749}
6750
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006751
Linus Torvalds1da177e2005-04-16 15:20:36 -07006752/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006753 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006754 *
6755 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6756 * configuration. Each pin widget can choose any input DACs and a mixer.
6757 * Each ADC is connected from a mixer of all inputs. This makes possible
6758 * 6-channel independent captures.
6759 *
6760 * In addition, an independent DAC for the multi-playback (not used in this
6761 * driver yet).
6762 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006763#define ALC882_DIGOUT_NID 0x06
6764#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006765#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6766#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6767#define ALC1200_DIGOUT_NID 0x10
6768
Linus Torvalds1da177e2005-04-16 15:20:36 -07006769
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006770static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006771 { 8, NULL }
6772};
6773
Takashi Iwai4953550a2009-06-30 15:28:30 +02006774/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006775static hda_nid_t alc882_dac_nids[4] = {
6776 /* front, rear, clfe, rear_surr */
6777 0x02, 0x03, 0x04, 0x05
6778};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006779#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006780
Takashi Iwai4953550a2009-06-30 15:28:30 +02006781/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006782#define alc882_adc_nids alc880_adc_nids
6783#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006784#define alc883_adc_nids alc882_adc_nids_alt
6785static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6786static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6787#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006788
Takashi Iwaie1406342008-02-11 18:32:32 +01006789static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6790static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006791#define alc883_capsrc_nids alc882_capsrc_nids_alt
6792static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6793#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006794
Linus Torvalds1da177e2005-04-16 15:20:36 -07006795/* input MUX */
6796/* FIXME: should be a matrix-type input source selection */
6797
6798static struct hda_input_mux alc882_capture_source = {
6799 .num_items = 4,
6800 .items = {
6801 { "Mic", 0x0 },
6802 { "Front Mic", 0x1 },
6803 { "Line", 0x2 },
6804 { "CD", 0x4 },
6805 },
6806};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006807
Takashi Iwai4953550a2009-06-30 15:28:30 +02006808#define alc883_capture_source alc882_capture_source
6809
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006810static struct hda_input_mux alc889_capture_source = {
6811 .num_items = 3,
6812 .items = {
6813 { "Front Mic", 0x0 },
6814 { "Mic", 0x3 },
6815 { "Line", 0x2 },
6816 },
6817};
6818
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006819static struct hda_input_mux mb5_capture_source = {
6820 .num_items = 3,
6821 .items = {
6822 { "Mic", 0x1 },
6823 { "Line", 0x2 },
6824 { "CD", 0x4 },
6825 },
6826};
6827
Luke Yelaviche458b1f2010-02-12 16:28:29 +11006828static struct hda_input_mux macmini3_capture_source = {
6829 .num_items = 2,
6830 .items = {
6831 { "Line", 0x2 },
6832 { "CD", 0x4 },
6833 },
6834};
6835
Takashi Iwai4953550a2009-06-30 15:28:30 +02006836static struct hda_input_mux alc883_3stack_6ch_intel = {
6837 .num_items = 4,
6838 .items = {
6839 { "Mic", 0x1 },
6840 { "Front Mic", 0x0 },
6841 { "Line", 0x2 },
6842 { "CD", 0x4 },
6843 },
6844};
6845
6846static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6847 .num_items = 2,
6848 .items = {
6849 { "Mic", 0x1 },
6850 { "Line", 0x2 },
6851 },
6852};
6853
6854static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6855 .num_items = 4,
6856 .items = {
6857 { "Mic", 0x0 },
6858 { "iMic", 0x1 },
6859 { "Line", 0x2 },
6860 { "CD", 0x4 },
6861 },
6862};
6863
6864static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6865 .num_items = 2,
6866 .items = {
6867 { "Mic", 0x0 },
6868 { "Int Mic", 0x1 },
6869 },
6870};
6871
6872static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6873 .num_items = 3,
6874 .items = {
6875 { "Mic", 0x0 },
6876 { "Front Mic", 0x1 },
6877 { "Line", 0x4 },
6878 },
6879};
6880
6881static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6882 .num_items = 2,
6883 .items = {
6884 { "Mic", 0x0 },
6885 { "Line", 0x2 },
6886 },
6887};
6888
6889static struct hda_input_mux alc889A_mb31_capture_source = {
6890 .num_items = 2,
6891 .items = {
6892 { "Mic", 0x0 },
6893 /* Front Mic (0x01) unused */
6894 { "Line", 0x2 },
6895 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02006896 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006897 },
6898};
6899
6900/*
6901 * 2ch mode
6902 */
6903static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6904 { 2, NULL }
6905};
6906
Kailang Yangdf694da2005-12-05 19:42:22 +01006907/*
Kailang Yang272a5272007-05-14 11:00:38 +02006908 * 2ch mode
6909 */
6910static struct hda_verb alc882_3ST_ch2_init[] = {
6911 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6912 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6913 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6914 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6915 { } /* end */
6916};
6917
6918/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006919 * 4ch mode
6920 */
6921static struct hda_verb alc882_3ST_ch4_init[] = {
6922 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6923 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6924 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6925 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6926 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6927 { } /* end */
6928};
6929
6930/*
Kailang Yang272a5272007-05-14 11:00:38 +02006931 * 6ch mode
6932 */
6933static struct hda_verb alc882_3ST_ch6_init[] = {
6934 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6935 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6936 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6937 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6938 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6939 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6940 { } /* end */
6941};
6942
Takashi Iwai4953550a2009-06-30 15:28:30 +02006943static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006944 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006945 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006946 { 6, alc882_3ST_ch6_init },
6947};
6948
Takashi Iwai4953550a2009-06-30 15:28:30 +02006949#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6950
Kailang Yang272a5272007-05-14 11:00:38 +02006951/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306952 * 2ch mode
6953 */
6954static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6955 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6956 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6957 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6958 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6959 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6960 { } /* end */
6961};
6962
6963/*
6964 * 4ch mode
6965 */
6966static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6967 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6968 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6969 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6970 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6971 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6972 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6973 { } /* end */
6974};
6975
6976/*
6977 * 6ch mode
6978 */
6979static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6980 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6981 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6982 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6983 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6984 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6985 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6986 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6987 { } /* end */
6988};
6989
6990static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6991 { 2, alc883_3ST_ch2_clevo_init },
6992 { 4, alc883_3ST_ch4_clevo_init },
6993 { 6, alc883_3ST_ch6_clevo_init },
6994};
6995
6996
6997/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006998 * 6ch mode
6999 */
7000static struct hda_verb alc882_sixstack_ch6_init[] = {
7001 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7002 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7003 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7004 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7005 { } /* end */
7006};
7007
7008/*
7009 * 8ch mode
7010 */
7011static struct hda_verb alc882_sixstack_ch8_init[] = {
7012 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7013 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7014 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7015 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7016 { } /* end */
7017};
7018
7019static struct hda_channel_mode alc882_sixstack_modes[2] = {
7020 { 6, alc882_sixstack_ch6_init },
7021 { 8, alc882_sixstack_ch8_init },
7022};
7023
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007024
7025/* Macbook Air 2,1 */
7026
7027static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7028 { 2, NULL },
7029};
7030
Takashi Iwai87350ad2007-08-16 18:19:38 +02007031/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007032 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007033 */
7034
7035/*
7036 * 2ch mode
7037 */
7038static struct hda_verb alc885_mbp_ch2_init[] = {
7039 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7040 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7041 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7042 { } /* end */
7043};
7044
7045/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007046 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007047 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007048static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007049 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7050 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7051 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7052 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7053 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7054 { } /* end */
7055};
7056
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007057static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007058 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007059 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007060};
7061
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007062/*
7063 * 2ch
7064 * Speakers/Woofer/HP = Front
7065 * LineIn = Input
7066 */
7067static struct hda_verb alc885_mb5_ch2_init[] = {
7068 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7069 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7070 { } /* end */
7071};
7072
7073/*
7074 * 6ch mode
7075 * Speakers/HP = Front
7076 * Woofer = LFE
7077 * LineIn = Surround
7078 */
7079static struct hda_verb alc885_mb5_ch6_init[] = {
7080 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7081 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7082 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7083 { } /* end */
7084};
7085
7086static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7087 { 2, alc885_mb5_ch2_init },
7088 { 6, alc885_mb5_ch6_init },
7089};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007090
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007091#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007092
7093/*
7094 * 2ch mode
7095 */
7096static struct hda_verb alc883_4ST_ch2_init[] = {
7097 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7098 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7099 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7100 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7101 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7102 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7103 { } /* end */
7104};
7105
7106/*
7107 * 4ch mode
7108 */
7109static struct hda_verb alc883_4ST_ch4_init[] = {
7110 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7111 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7112 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7113 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7114 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7115 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7116 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7117 { } /* end */
7118};
7119
7120/*
7121 * 6ch mode
7122 */
7123static struct hda_verb alc883_4ST_ch6_init[] = {
7124 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7125 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7126 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7127 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7128 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7129 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7130 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7131 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7132 { } /* end */
7133};
7134
7135/*
7136 * 8ch mode
7137 */
7138static struct hda_verb alc883_4ST_ch8_init[] = {
7139 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7140 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7141 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7142 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7143 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7144 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7145 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7146 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7147 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7148 { } /* end */
7149};
7150
7151static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7152 { 2, alc883_4ST_ch2_init },
7153 { 4, alc883_4ST_ch4_init },
7154 { 6, alc883_4ST_ch6_init },
7155 { 8, alc883_4ST_ch8_init },
7156};
7157
7158
7159/*
7160 * 2ch mode
7161 */
7162static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7163 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7164 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7165 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7166 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7167 { } /* end */
7168};
7169
7170/*
7171 * 4ch mode
7172 */
7173static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7174 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7175 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7176 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7177 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7178 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7179 { } /* end */
7180};
7181
7182/*
7183 * 6ch mode
7184 */
7185static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7186 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7187 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7188 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7189 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7190 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7191 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7192 { } /* end */
7193};
7194
7195static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7196 { 2, alc883_3ST_ch2_intel_init },
7197 { 4, alc883_3ST_ch4_intel_init },
7198 { 6, alc883_3ST_ch6_intel_init },
7199};
7200
7201/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007202 * 2ch mode
7203 */
7204static struct hda_verb alc889_ch2_intel_init[] = {
7205 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7206 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7207 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7208 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7209 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7210 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7211 { } /* end */
7212};
7213
7214/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007215 * 6ch mode
7216 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007217static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007218 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7219 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7220 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7221 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7222 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007223 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7224 { } /* end */
7225};
7226
7227/*
7228 * 8ch mode
7229 */
7230static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007231 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7232 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7233 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7234 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7235 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007236 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7237 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007238 { } /* end */
7239};
7240
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007241static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7242 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007243 { 6, alc889_ch6_intel_init },
7244 { 8, alc889_ch8_intel_init },
7245};
7246
7247/*
7248 * 6ch mode
7249 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007250static struct hda_verb alc883_sixstack_ch6_init[] = {
7251 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7252 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7253 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7254 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7255 { } /* end */
7256};
7257
7258/*
7259 * 8ch mode
7260 */
7261static struct hda_verb alc883_sixstack_ch8_init[] = {
7262 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7263 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7264 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7265 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7266 { } /* end */
7267};
7268
7269static struct hda_channel_mode alc883_sixstack_modes[2] = {
7270 { 6, alc883_sixstack_ch6_init },
7271 { 8, alc883_sixstack_ch8_init },
7272};
7273
7274
Linus Torvalds1da177e2005-04-16 15:20:36 -07007275/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7276 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7277 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007278static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007279 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007280 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007281 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007282 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007283 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7284 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007285 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7286 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007287 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007288 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007289 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7290 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7291 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7292 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7293 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7294 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007295 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007296 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7297 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007298 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007299 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007300 { } /* end */
7301};
7302
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007303/* Macbook Air 2,1 same control for HP and internal Speaker */
7304
7305static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7306 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7307 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7308 { }
7309};
7310
7311
Takashi Iwai87350ad2007-08-16 18:19:38 +02007312static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007313 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7314 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7315 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7316 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7317 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007318 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7319 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007320 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7321 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007322 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007323 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7324 { } /* end */
7325};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007326
7327static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007328 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7329 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7330 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7331 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7332 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7333 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307334 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7335 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007336 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7337 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7338 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7339 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7340 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7341 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7342 { } /* end */
7343};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007344
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007345static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7346 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7347 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7348 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7349 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7350 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7351 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7352 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7353 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7354 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7355 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7356 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7357 { } /* end */
7358};
7359
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007360static struct snd_kcontrol_new alc885_imac91_mixer[] = {
7361 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7362 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
7363 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
7364 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7365 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7366 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7367 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7368 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7369 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7370 { } /* end */
7371};
7372
7373
Kailang Yangbdd148a2007-05-08 15:19:08 +02007374static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7375 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7376 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7377 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7378 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7379 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7380 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7381 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7382 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7383 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007384 { } /* end */
7385};
7386
Kailang Yang272a5272007-05-14 11:00:38 +02007387static struct snd_kcontrol_new alc882_targa_mixer[] = {
7388 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7389 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7390 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7391 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7392 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7393 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7394 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7395 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7396 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007397 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007398 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7399 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007400 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007401 { } /* end */
7402};
7403
7404/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7405 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7406 */
7407static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7408 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7409 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7410 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7411 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7412 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7413 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7414 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7415 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7416 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7417 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7418 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7419 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007420 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007421 { } /* end */
7422};
7423
Takashi Iwai914759b2007-09-06 14:52:04 +02007424static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7425 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7426 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7427 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7428 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7429 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7430 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7431 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7432 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7433 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7434 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007435 { } /* end */
7436};
7437
Kailang Yangdf694da2005-12-05 19:42:22 +01007438static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7439 {
7440 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7441 .name = "Channel Mode",
7442 .info = alc_ch_mode_info,
7443 .get = alc_ch_mode_get,
7444 .put = alc_ch_mode_put,
7445 },
7446 { } /* end */
7447};
7448
Takashi Iwai4953550a2009-06-30 15:28:30 +02007449static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007450 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007451 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7452 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007453 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007454 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7455 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007456 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007457 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7458 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007459 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007460 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7461 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007462
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007463 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007464 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007465 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007466 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007467 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007468 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007469 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007470 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007471 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007472 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007473 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007474 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007475 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007476 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007477 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007478 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007479 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007480 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007481 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7482 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007483 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007484 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7485 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007486 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007487 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7488 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7489 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7490 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7491 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007492 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007493 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007494
7495 /* FIXME: use matrix-type input source selection */
7496 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007497 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007498 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007499 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007500 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007501 /* ADC2: mute amp left and right */
7502 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007503 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007504 /* ADC3: mute amp left and right */
7505 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007506 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007507
7508 { }
7509};
7510
Takashi Iwai4953550a2009-06-30 15:28:30 +02007511static struct hda_verb alc882_adc1_init_verbs[] = {
7512 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7513 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7514 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7515 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7516 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7517 /* ADC1: mute amp left and right */
7518 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7519 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7520 { }
7521};
7522
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007523static struct hda_verb alc882_eapd_verbs[] = {
7524 /* change to EAPD mode */
7525 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007526 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007527 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007528};
7529
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007530static struct hda_verb alc889_eapd_verbs[] = {
7531 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7532 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7533 { }
7534};
7535
Wu Fengguang6732bd02009-07-30 09:19:14 +02007536static struct hda_verb alc_hp15_unsol_verbs[] = {
7537 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7538 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7539 {}
7540};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007541
7542static struct hda_verb alc885_init_verbs[] = {
7543 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01007544 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7545 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007546 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007547 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7548 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007549 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007550 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7551 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007552 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007553 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7554 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007555
7556 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007557 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007558 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7559 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7560 /* Front Pin: output 0 (0x0c) */
7561 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7562 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7563 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7564 /* Rear Pin: output 1 (0x0d) */
7565 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7566 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7567 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7568 /* CLFE Pin: output 2 (0x0e) */
7569 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7570 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7571 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7572 /* Side Pin: output 3 (0x0f) */
7573 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7574 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7575 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7576 /* Mic (rear) pin: input vref at 80% */
7577 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7578 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7579 /* Front Mic pin: input vref at 80% */
7580 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7581 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7582 /* Line In pin: input */
7583 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7584 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7585
7586 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7587 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01007588 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007589 /* Input mixer2 */
7590 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007591 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01007592 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007593 /* ADC2: mute amp left and right */
7594 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7595 /* ADC3: mute amp left and right */
7596 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7597
7598 { }
7599};
7600
7601static struct hda_verb alc885_init_input_verbs[] = {
7602 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7603 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7604 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7605 { }
7606};
7607
7608
7609/* Unmute Selector 24h and set the default input to front mic */
7610static struct hda_verb alc889_init_input_verbs[] = {
7611 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7612 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7613 { }
7614};
7615
7616
Takashi Iwai4953550a2009-06-30 15:28:30 +02007617#define alc883_init_verbs alc882_base_init_verbs
7618
Tobin Davis9102cd12006-12-15 10:02:12 +01007619/* Mac Pro test */
7620static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7621 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7622 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7623 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7624 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7625 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007626 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007627 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7628 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007629 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007630 { } /* end */
7631};
7632
7633static struct hda_verb alc882_macpro_init_verbs[] = {
7634 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7635 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7636 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7637 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7638 /* Front Pin: output 0 (0x0c) */
7639 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7640 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7641 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7642 /* Front Mic pin: input vref at 80% */
7643 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7644 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7645 /* Speaker: output */
7646 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7647 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7648 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7649 /* Headphone output (output 0 - 0x0c) */
7650 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7651 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7652 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7653
7654 /* FIXME: use matrix-type input source selection */
7655 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7656 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7657 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7658 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7659 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7660 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7661 /* Input mixer2 */
7662 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7663 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7664 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7666 /* Input mixer3 */
7667 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7668 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7669 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7670 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7671 /* ADC1: mute amp left and right */
7672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7673 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7674 /* ADC2: mute amp left and right */
7675 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7676 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7677 /* ADC3: mute amp left and right */
7678 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7679 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7680
7681 { }
7682};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007683
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007684/* Macbook 5,1 */
7685static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007686 /* DACs */
7687 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7688 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7689 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7690 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007691 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007692 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7693 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7694 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007695 /* Surround mixer */
7696 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7697 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7698 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7699 /* LFE mixer */
7700 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7701 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7702 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7703 /* HP mixer */
7704 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7705 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7706 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7707 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007708 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7709 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007710 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7711 /* LFE Pin (0x0e) */
7712 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7713 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7714 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7715 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007716 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7717 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007718 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10307719 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007720 /* Front Mic pin: input vref at 80% */
7721 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7722 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7723 /* Line In pin */
7724 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7725 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7726
7727 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7728 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7729 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7730 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7731 { }
7732};
7733
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007734/* Macmini 3,1 */
7735static struct hda_verb alc885_macmini3_init_verbs[] = {
7736 /* DACs */
7737 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7738 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7739 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7740 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7741 /* Front mixer */
7742 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7743 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7744 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7745 /* Surround mixer */
7746 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7747 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7748 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7749 /* LFE mixer */
7750 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7751 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7752 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7753 /* HP mixer */
7754 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7755 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7756 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7757 /* Front Pin (0x0c) */
7758 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7759 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7760 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7761 /* LFE Pin (0x0e) */
7762 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7763 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7764 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7765 /* HP Pin (0x0f) */
7766 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7767 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7768 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
7769 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7770 /* Line In pin */
7771 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7772 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7773
7774 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7775 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7776 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7777 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7778 { }
7779};
7780
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007781
7782static struct hda_verb alc885_mba21_init_verbs[] = {
7783 /*Internal and HP Speaker Mixer*/
7784 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7785 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7786 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7787 /*Internal Speaker Pin (0x0c)*/
7788 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
7789 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7790 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7791 /* HP Pin: output 0 (0x0e) */
7792 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7793 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7794 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7795 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
7796 /* Line in (is hp when jack connected)*/
7797 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
7798 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7799
7800 { }
7801 };
7802
7803
Takashi Iwai87350ad2007-08-16 18:19:38 +02007804/* Macbook Pro rev3 */
7805static struct hda_verb alc885_mbp3_init_verbs[] = {
7806 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7808 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7809 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7810 /* Rear mixer */
7811 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7812 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7813 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007814 /* HP mixer */
7815 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7816 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7817 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007818 /* Front Pin: output 0 (0x0c) */
7819 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7820 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7821 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007822 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007823 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007824 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7825 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007826 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7827 /* Mic (rear) pin: input vref at 80% */
7828 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7829 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7830 /* Front Mic pin: input vref at 80% */
7831 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7832 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7833 /* Line In pin: use output 1 when in LineOut mode */
7834 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7835 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7836 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7837
7838 /* FIXME: use matrix-type input source selection */
7839 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7840 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7841 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7842 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7843 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7844 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7845 /* Input mixer2 */
7846 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7847 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7848 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7849 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7850 /* Input mixer3 */
7851 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7852 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7853 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7854 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7855 /* ADC1: mute amp left and right */
7856 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7857 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7858 /* ADC2: mute amp left and right */
7859 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7860 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7861 /* ADC3: mute amp left and right */
7862 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7863 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7864
7865 { }
7866};
7867
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007868/* iMac 9,1 */
7869static struct hda_verb alc885_imac91_init_verbs[] = {
7870 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
7871 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7872 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7873 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7874 /* Rear mixer */
7875 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7876 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7877 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7878 /* HP Pin: output 0 (0x0c) */
7879 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7880 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7881 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7882 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7883 /* Internal Speakers: output 0 (0x0d) */
7884 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7885 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7886 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7887 /* Mic (rear) pin: input vref at 80% */
7888 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7889 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7890 /* Front Mic pin: input vref at 80% */
7891 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7892 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7893 /* Line In pin: use output 1 when in LineOut mode */
7894 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7895 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7896 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7897
7898 /* FIXME: use matrix-type input source selection */
7899 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7900 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7901 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7902 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7903 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7904 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7905 /* Input mixer2 */
7906 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7907 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7908 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7909 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7910 /* Input mixer3 */
7911 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7912 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7913 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7914 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7915 /* ADC1: mute amp left and right */
7916 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7917 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7918 /* ADC2: mute amp left and right */
7919 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7920 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7921 /* ADC3: mute amp left and right */
7922 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7923 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7924
7925 { }
7926};
7927
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007928/* iMac 24 mixer. */
7929static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7930 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7931 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7932 { } /* end */
7933};
7934
7935/* iMac 24 init verbs. */
7936static struct hda_verb alc885_imac24_init_verbs[] = {
7937 /* Internal speakers: output 0 (0x0c) */
7938 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7939 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7940 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7941 /* Internal speakers: output 0 (0x0c) */
7942 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7943 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7944 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7945 /* Headphone: output 0 (0x0c) */
7946 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7947 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7948 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7949 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7950 /* Front Mic: input vref at 80% */
7951 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7952 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7953 { }
7954};
7955
7956/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007957static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007958{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007959 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007960
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007961 spec->autocfg.hp_pins[0] = 0x14;
7962 spec->autocfg.speaker_pins[0] = 0x18;
7963 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007964}
7965
Takashi Iwai9d54f082010-02-22 08:34:40 +01007966#define alc885_mb5_setup alc885_imac24_setup
7967#define alc885_macmini3_setup alc885_imac24_setup
7968
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007969/* Macbook Air 2,1 */
7970static void alc885_mba21_setup(struct hda_codec *codec)
7971{
7972 struct alc_spec *spec = codec->spec;
7973
7974 spec->autocfg.hp_pins[0] = 0x14;
7975 spec->autocfg.speaker_pins[0] = 0x18;
7976}
7977
7978
7979
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007980static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007981{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007982 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007983
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007984 spec->autocfg.hp_pins[0] = 0x15;
7985 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007986}
7987
Takashi Iwai9d54f082010-02-22 08:34:40 +01007988static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10307989{
Takashi Iwai9d54f082010-02-22 08:34:40 +01007990 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10307991
Takashi Iwai9d54f082010-02-22 08:34:40 +01007992 spec->autocfg.hp_pins[0] = 0x14;
7993 spec->autocfg.speaker_pins[0] = 0x15;
7994 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007995}
Takashi Iwai87350ad2007-08-16 18:19:38 +02007996
Kailang Yang272a5272007-05-14 11:00:38 +02007997static struct hda_verb alc882_targa_verbs[] = {
7998 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7999 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8000
8001 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8002 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008003
Kailang Yang272a5272007-05-14 11:00:38 +02008004 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8005 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8006 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8007
8008 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008009 { } /* end */
8010};
8011
8012/* toggle speaker-output according to the hp-jack state */
8013static void alc882_targa_automute(struct hda_codec *codec)
8014{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008015 struct alc_spec *spec = codec->spec;
8016 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008017 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008018 spec->jack_present ? 1 : 3);
8019}
8020
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008021static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008022{
8023 struct alc_spec *spec = codec->spec;
8024
8025 spec->autocfg.hp_pins[0] = 0x14;
8026 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008027}
8028
8029static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8030{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008031 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008032 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008033}
8034
8035static struct hda_verb alc882_asus_a7j_verbs[] = {
8036 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8037 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8038
8039 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8040 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8041 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008042
Kailang Yang272a5272007-05-14 11:00:38 +02008043 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8044 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8045 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8046
8047 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8048 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8049 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8050 { } /* end */
8051};
8052
Takashi Iwai914759b2007-09-06 14:52:04 +02008053static struct hda_verb alc882_asus_a7m_verbs[] = {
8054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8056
8057 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8058 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8059 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008060
Takashi Iwai914759b2007-09-06 14:52:04 +02008061 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8062 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8063 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8064
8065 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8066 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8067 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8068 { } /* end */
8069};
8070
Tobin Davis9102cd12006-12-15 10:02:12 +01008071static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8072{
8073 unsigned int gpiostate, gpiomask, gpiodir;
8074
8075 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8076 AC_VERB_GET_GPIO_DATA, 0);
8077
8078 if (!muted)
8079 gpiostate |= (1 << pin);
8080 else
8081 gpiostate &= ~(1 << pin);
8082
8083 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8084 AC_VERB_GET_GPIO_MASK, 0);
8085 gpiomask |= (1 << pin);
8086
8087 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8088 AC_VERB_GET_GPIO_DIRECTION, 0);
8089 gpiodir |= (1 << pin);
8090
8091
8092 snd_hda_codec_write(codec, codec->afg, 0,
8093 AC_VERB_SET_GPIO_MASK, gpiomask);
8094 snd_hda_codec_write(codec, codec->afg, 0,
8095 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8096
8097 msleep(1);
8098
8099 snd_hda_codec_write(codec, codec->afg, 0,
8100 AC_VERB_SET_GPIO_DATA, gpiostate);
8101}
8102
Takashi Iwai7debbe52007-08-16 15:01:03 +02008103/* set up GPIO at initialization */
8104static void alc885_macpro_init_hook(struct hda_codec *codec)
8105{
8106 alc882_gpio_mute(codec, 0, 0);
8107 alc882_gpio_mute(codec, 1, 0);
8108}
8109
8110/* set up GPIO and update auto-muting at initialization */
8111static void alc885_imac24_init_hook(struct hda_codec *codec)
8112{
8113 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008114 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008115}
8116
Kailang Yangdf694da2005-12-05 19:42:22 +01008117/*
8118 * generic initialization of ADC, input mixers and output mixers
8119 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008120static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008121 /*
8122 * Unmute ADC0-2 and set the default input to mic-in
8123 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008124 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8125 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8126 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8127 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8128
Kailang Yangdf694da2005-12-05 19:42:22 +01008129 /*
8130 * Set up output mixers (0x0c - 0x0f)
8131 */
8132 /* set vol=0 to output mixers */
8133 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8134 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8135 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8136 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8137 /* set up input amps for analog loopback */
8138 /* Amp Indices: DAC = 0, mixer = 1 */
8139 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8140 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8141 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8142 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8143 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8144 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8145 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8146 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8147 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8148 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8149
8150 /* FIXME: use matrix-type input source selection */
8151 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008152 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008153 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008154 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008155 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008156 { }
8157};
8158
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008159/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8160static struct hda_verb alc889A_mb31_ch2_init[] = {
8161 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8162 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8163 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8164 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8165 { } /* end */
8166};
8167
8168/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8169static struct hda_verb alc889A_mb31_ch4_init[] = {
8170 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8171 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8172 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8173 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8174 { } /* end */
8175};
8176
8177/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8178static struct hda_verb alc889A_mb31_ch5_init[] = {
8179 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8180 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8181 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8182 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8183 { } /* end */
8184};
8185
8186/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8187static struct hda_verb alc889A_mb31_ch6_init[] = {
8188 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8189 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8190 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8191 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8192 { } /* end */
8193};
8194
8195static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8196 { 2, alc889A_mb31_ch2_init },
8197 { 4, alc889A_mb31_ch4_init },
8198 { 5, alc889A_mb31_ch5_init },
8199 { 6, alc889A_mb31_ch6_init },
8200};
8201
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008202static struct hda_verb alc883_medion_eapd_verbs[] = {
8203 /* eanable EAPD on medion laptop */
8204 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8205 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8206 { }
8207};
8208
Takashi Iwai4953550a2009-06-30 15:28:30 +02008209#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008210
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008211static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8212 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8213 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8214 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8215 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8216 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8217 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8218 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8219 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8220 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8221 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8222 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8223 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8224 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008225 { } /* end */
8226};
8227
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008228static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008229 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8230 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8231 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8232 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8233 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8234 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8235 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8236 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8237 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8238 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008239 { } /* end */
8240};
8241
Jiang zhefb97dc62008-03-06 11:07:11 +01008242static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8243 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8244 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8245 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8246 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8247 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8248 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8249 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8250 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8251 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8252 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008253 { } /* end */
8254};
8255
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008256static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8257 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8258 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8259 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8260 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8261 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8262 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8263 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8264 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008265 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008266 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8267 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008268 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008269 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008270 { } /* end */
8271};
8272
8273static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8274 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8275 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8276 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8277 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8278 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8279 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8280 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8281 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8282 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8283 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8284 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8285 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8286 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8287 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008288 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008289 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8290 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008291 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008292 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008293 { } /* end */
8294};
8295
Jiang zhe17bba1b2008-06-04 12:11:07 +02008296static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8297 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8298 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8299 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8300 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8301 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8302 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_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8307 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8308 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8309 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8310 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8311 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8312 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8313 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8314 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8315 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8316 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008317 { } /* end */
8318};
8319
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008320static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8321 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8322 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8323 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8324 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8325 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8326 HDA_OUTPUT),
8327 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8328 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8329 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8330 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8331 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8332 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8333 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8334 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8336 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8337 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8338 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8339 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8340 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8341 { } /* end */
8342};
8343
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008344static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008345 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008346 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008347 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008348 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008349 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8350 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008351 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8352 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008353 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8354 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8355 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8356 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8357 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8358 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008359 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008360 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8361 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008362 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008363 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008364 { } /* end */
8365};
8366
Sasha Alexandrc2592492009-06-16 14:52:54 -04008367static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008368 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008369 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008370 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008371 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008372 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8373 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8374 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8375 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8376 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8377 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8378 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8379 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8380 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8381 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8382 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008383 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008384 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008385 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008386};
Kailang Yangccc656c2006-10-17 12:32:26 +02008387
Sasha Alexandrc2592492009-06-16 14:52:54 -04008388static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008389 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008390 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008391 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008392 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008393 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8394 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8395 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008396 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008397 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008398 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8399 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8400 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008401 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008402};
Kailang Yangccc656c2006-10-17 12:32:26 +02008403
Takashi Iwaib99dba32009-09-17 18:23:00 +02008404static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8405 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8406 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8407 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8408 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8409 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8410 { } /* end */
8411};
8412
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008413static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8414 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8415 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008416 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8417 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008418 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8419 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8420 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8421 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008422 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008423};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008424
Kailang Yang272a5272007-05-14 11:00:38 +02008425static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8426 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8427 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8428 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8429 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8430 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8431 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8432 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8433 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8434 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008435 { } /* end */
8436};
8437
8438static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8439 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8440 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8441 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8442 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8443 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8444 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8445 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8446 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8447 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008448 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008449};
Kailang Yang272a5272007-05-14 11:00:38 +02008450
Tobin Davis2880a862007-08-07 11:50:26 +02008451static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008452 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8453 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008454 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008455 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8456 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008457 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8458 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8459 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008460 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008461};
Tobin Davis2880a862007-08-07 11:50:26 +02008462
Tony Vroond2fd4b02009-06-21 00:40:10 +01008463static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8464 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8465 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8466 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8467 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008468 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8469 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008470 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8471 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8473 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8474 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8475 { } /* end */
8476};
8477
Kailang Yange2757d52008-08-26 13:17:46 +02008478static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8479 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8480 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8481 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8482 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8483 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8484 0x0d, 1, 0x0, HDA_OUTPUT),
8485 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8486 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8487 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8488 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8489 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008490 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8491 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8492 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8493 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8494 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8495 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8496 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8497 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8498 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8499 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008500 { } /* end */
8501};
8502
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008503static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8504 /* Output mixers */
8505 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8506 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8507 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8508 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8509 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8510 HDA_OUTPUT),
8511 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8512 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8513 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8514 /* Output switches */
8515 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8516 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8517 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8518 /* Boost mixers */
8519 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8520 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8521 /* Input mixers */
8522 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8523 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8524 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8525 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8526 { } /* end */
8527};
8528
Guido Günther3e1647c2009-06-05 00:47:26 +02008529static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8530 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8531 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8532 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8533 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8534 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8535 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8536 { } /* end */
8537};
8538
Kailang Yange2757d52008-08-26 13:17:46 +02008539static struct hda_bind_ctls alc883_bind_cap_vol = {
8540 .ops = &snd_hda_bind_vol,
8541 .values = {
8542 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8543 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8544 0
8545 },
8546};
8547
8548static struct hda_bind_ctls alc883_bind_cap_switch = {
8549 .ops = &snd_hda_bind_sw,
8550 .values = {
8551 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8552 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8553 0
8554 },
8555};
8556
8557static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8558 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8559 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8560 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8561 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8562 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8563 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8564 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8565 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008566 { } /* end */
8567};
8568
8569static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008570 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8571 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8572 {
8573 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8574 /* .name = "Capture Source", */
8575 .name = "Input Source",
8576 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008577 .info = alc_mux_enum_info,
8578 .get = alc_mux_enum_get,
8579 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008580 },
8581 { } /* end */
8582};
8583
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008584static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8585 {
8586 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8587 .name = "Channel Mode",
8588 .info = alc_ch_mode_info,
8589 .get = alc_ch_mode_get,
8590 .put = alc_ch_mode_put,
8591 },
8592 { } /* end */
8593};
8594
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008595/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008596static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008597{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008598 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008599
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008600 spec->autocfg.hp_pins[0] = 0x15;
8601 spec->autocfg.speaker_pins[0] = 0x14;
8602 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008603}
8604
8605/* auto-toggle front mic */
8606/*
8607static void alc883_mitac_mic_automute(struct hda_codec *codec)
8608{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008609 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008610
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008611 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8612}
8613*/
8614
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008615static struct hda_verb alc883_mitac_verbs[] = {
8616 /* HP */
8617 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8618 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8619 /* Subwoofer */
8620 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8621 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8622
8623 /* enable unsolicited event */
8624 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8625 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8626
8627 { } /* end */
8628};
8629
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308630static struct hda_verb alc883_clevo_m540r_verbs[] = {
8631 /* HP */
8632 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8633 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8634 /* Int speaker */
8635 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8636
8637 /* enable unsolicited event */
8638 /*
8639 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8640 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8641 */
8642
8643 { } /* end */
8644};
8645
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008646static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008647 /* HP */
8648 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8649 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8650 /* Int speaker */
8651 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8652 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8653
8654 /* enable unsolicited event */
8655 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008656 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008657
8658 { } /* end */
8659};
8660
Jiang zhefb97dc62008-03-06 11:07:11 +01008661static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8662 /* HP */
8663 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8664 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8665 /* Subwoofer */
8666 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8667 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8668
8669 /* enable unsolicited event */
8670 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8671
8672 { } /* end */
8673};
8674
Sasha Alexandrc2592492009-06-16 14:52:54 -04008675static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008676 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8678
8679 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8680 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008681
David Heidelberger64a8be72009-06-08 16:15:18 +02008682/* Connect Line-Out side jack (SPDIF) to Side */
8683 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8684 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8685 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8686/* Connect Mic jack to CLFE */
8687 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8688 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8689 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8690/* Connect Line-in jack to Surround */
8691 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8692 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8693 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8694/* Connect HP out jack to Front */
8695 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8696 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8697 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008698
8699 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008700
8701 { } /* end */
8702};
8703
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008704static struct hda_verb alc883_lenovo_101e_verbs[] = {
8705 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8706 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8707 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8708 { } /* end */
8709};
8710
Kailang Yang272a5272007-05-14 11:00:38 +02008711static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8712 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8713 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8714 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8715 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8716 { } /* end */
8717};
8718
8719static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8720 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8721 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8722 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8723 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8724 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8725 { } /* end */
8726};
8727
Kailang Yang189609a2007-08-20 11:31:23 +02008728static struct hda_verb alc883_haier_w66_verbs[] = {
8729 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8730 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8731
8732 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8733
8734 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8735 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8736 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8737 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8738 { } /* end */
8739};
8740
Kailang Yange2757d52008-08-26 13:17:46 +02008741static struct hda_verb alc888_lenovo_sky_verbs[] = {
8742 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8743 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8744 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8745 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8746 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8747 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8748 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8749 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8750 { } /* end */
8751};
8752
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008753static struct hda_verb alc888_6st_dell_verbs[] = {
8754 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8755 { }
8756};
8757
Guido Günther3e1647c2009-06-05 00:47:26 +02008758static struct hda_verb alc883_vaiott_verbs[] = {
8759 /* HP */
8760 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8761 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8762
8763 /* enable unsolicited event */
8764 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8765
8766 { } /* end */
8767};
8768
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008769static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008770{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008771 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008772
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008773 spec->autocfg.hp_pins[0] = 0x1b;
8774 spec->autocfg.speaker_pins[0] = 0x14;
8775 spec->autocfg.speaker_pins[1] = 0x16;
8776 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008777}
8778
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008779static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008780 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008781 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8782 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008783 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008784 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008785};
8786
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008787/*
8788 * 2ch mode
8789 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008790static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008791 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8792 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8793 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8794 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008795 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008796};
8797
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008798/*
8799 * 4ch mode
8800 */
8801static struct hda_verb alc888_3st_hp_4ch_init[] = {
8802 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8803 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8804 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8805 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8806 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8807 { } /* end */
8808};
8809
8810/*
8811 * 6ch mode
8812 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008813static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008814 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8815 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008816 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008817 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8818 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008819 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8820 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008821};
8822
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008823static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008824 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008825 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008826 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008827};
8828
Kailang Yang272a5272007-05-14 11:00:38 +02008829/* toggle front-jack and RCA according to the hp-jack state */
8830static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8831{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008832 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008833
Takashi Iwai47fd8302007-08-10 17:11:07 +02008834 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8835 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8836 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8837 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008838}
8839
8840/* toggle RCA according to the front-jack state */
8841static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8842{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008843 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02008844
Takashi Iwai47fd8302007-08-10 17:11:07 +02008845 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8846 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008847}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008848
Kailang Yang272a5272007-05-14 11:00:38 +02008849static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8850 unsigned int res)
8851{
8852 if ((res >> 26) == ALC880_HP_EVENT)
8853 alc888_lenovo_ms7195_front_automute(codec);
8854 if ((res >> 26) == ALC880_FRONT_EVENT)
8855 alc888_lenovo_ms7195_rca_automute(codec);
8856}
8857
8858static struct hda_verb alc883_medion_md2_verbs[] = {
8859 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8860 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8861
8862 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8863
8864 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8865 { } /* end */
8866};
8867
8868/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008869static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008870{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008871 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008872
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008873 spec->autocfg.hp_pins[0] = 0x14;
8874 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008875}
8876
Kailang Yangccc656c2006-10-17 12:32:26 +02008877/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008878#define alc883_targa_init_hook alc882_targa_init_hook
8879#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008880
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008881static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8882{
8883 unsigned int present;
8884
Takashi Iwaid56757a2009-11-18 08:00:14 +01008885 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008886 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8887 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8888}
8889
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008890static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008891{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008892 struct alc_spec *spec = codec->spec;
8893
8894 spec->autocfg.hp_pins[0] = 0x15;
8895 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008896}
8897
8898static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8899{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008900 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008901 alc883_clevo_m720_mic_automute(codec);
8902}
8903
8904static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008905 unsigned int res)
8906{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008907 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008908 case ALC880_MIC_EVENT:
8909 alc883_clevo_m720_mic_automute(codec);
8910 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008911 default:
8912 alc_automute_amp_unsol_event(codec, res);
8913 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008914 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008915}
8916
Jiang zhefb97dc62008-03-06 11:07:11 +01008917/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008918static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008919{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008920 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008921
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008922 spec->autocfg.hp_pins[0] = 0x14;
8923 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008924}
8925
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008926static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008927{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008928 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008929
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008930 spec->autocfg.hp_pins[0] = 0x1b;
8931 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008932}
8933
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008934static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8935{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008936 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008937
Takashi Iwai47fd8302007-08-10 17:11:07 +02008938 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8939 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008940}
8941
8942static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8943{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008944 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008945
Takashi Iwai47fd8302007-08-10 17:11:07 +02008946 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8947 HDA_AMP_MUTE, bits);
8948 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8949 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008950}
8951
8952static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8953 unsigned int res)
8954{
8955 if ((res >> 26) == ALC880_HP_EVENT)
8956 alc883_lenovo_101e_all_automute(codec);
8957 if ((res >> 26) == ALC880_FRONT_EVENT)
8958 alc883_lenovo_101e_ispeaker_automute(codec);
8959}
8960
Takashi Iwai676a9b52007-08-16 15:23:35 +02008961/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008962static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008963{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008964 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008965
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008966 spec->autocfg.hp_pins[0] = 0x14;
8967 spec->autocfg.speaker_pins[0] = 0x15;
8968 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008969}
8970
Kailang Yangd1a991a2007-08-15 16:21:59 +02008971static struct hda_verb alc883_acer_eapd_verbs[] = {
8972 /* HP Pin: output 0 (0x0c) */
8973 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8974 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8975 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8976 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008977 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8978 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008979 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008980 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8981 /* eanable EAPD on medion laptop */
8982 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8983 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008984 /* enable unsolicited event */
8985 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008986 { }
8987};
8988
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008989static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8990 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8991 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8992 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8993 { } /* end */
8994};
8995
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008996static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008997{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008998 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008999
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009000 spec->autocfg.hp_pins[0] = 0x1b;
9001 spec->autocfg.speaker_pins[0] = 0x14;
9002 spec->autocfg.speaker_pins[1] = 0x15;
9003 spec->autocfg.speaker_pins[2] = 0x16;
9004 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009005}
9006
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009007static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009008{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009009 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009010
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009011 spec->autocfg.hp_pins[0] = 0x1b;
9012 spec->autocfg.speaker_pins[0] = 0x14;
9013 spec->autocfg.speaker_pins[1] = 0x15;
9014 spec->autocfg.speaker_pins[2] = 0x16;
9015 spec->autocfg.speaker_pins[3] = 0x17;
9016 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009017}
9018
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009019static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009020{
9021 struct alc_spec *spec = codec->spec;
9022
9023 spec->autocfg.hp_pins[0] = 0x15;
9024 spec->autocfg.speaker_pins[0] = 0x14;
9025 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009026}
9027
Kailang Yange2757d52008-08-26 13:17:46 +02009028static struct hda_verb alc888_asus_m90v_verbs[] = {
9029 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9030 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9031 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9032 /* enable unsolicited event */
9033 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9034 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9035 { } /* end */
9036};
9037
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009038static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009039{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009040 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009041
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009042 spec->autocfg.hp_pins[0] = 0x1b;
9043 spec->autocfg.speaker_pins[0] = 0x14;
9044 spec->autocfg.speaker_pins[1] = 0x15;
9045 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009046 spec->ext_mic.pin = 0x18;
9047 spec->int_mic.pin = 0x19;
9048 spec->ext_mic.mux_idx = 0;
9049 spec->int_mic.mux_idx = 1;
9050 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009051}
9052
9053static struct hda_verb alc888_asus_eee1601_verbs[] = {
9054 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9055 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9056 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9057 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9058 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9059 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9060 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9061 /* enable unsolicited event */
9062 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9063 { } /* end */
9064};
9065
Kailang Yange2757d52008-08-26 13:17:46 +02009066static void alc883_eee1601_inithook(struct hda_codec *codec)
9067{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009068 struct alc_spec *spec = codec->spec;
9069
9070 spec->autocfg.hp_pins[0] = 0x14;
9071 spec->autocfg.speaker_pins[0] = 0x1b;
9072 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009073}
9074
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009075static struct hda_verb alc889A_mb31_verbs[] = {
9076 /* Init rear pin (used as headphone output) */
9077 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9078 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9079 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9080 /* Init line pin (used as output in 4ch and 6ch mode) */
9081 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9082 /* Init line 2 pin (used as headphone out by default) */
9083 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9084 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9085 { } /* end */
9086};
9087
9088/* Mute speakers according to the headphone jack state */
9089static void alc889A_mb31_automute(struct hda_codec *codec)
9090{
9091 unsigned int present;
9092
9093 /* Mute only in 2ch or 4ch mode */
9094 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9095 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009096 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009097 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9098 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9099 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9100 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9101 }
9102}
9103
9104static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9105{
9106 if ((res >> 26) == ALC880_HP_EVENT)
9107 alc889A_mb31_automute(codec);
9108}
9109
Takashi Iwai4953550a2009-06-30 15:28:30 +02009110
Takashi Iwaicb53c622007-08-10 17:21:45 +02009111#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009112#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009113#endif
9114
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009115/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009116#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9117#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9118#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9119#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9120
9121static hda_nid_t alc883_slave_dig_outs[] = {
9122 ALC1200_DIGOUT_NID, 0,
9123};
9124
9125static hda_nid_t alc1200_slave_dig_outs[] = {
9126 ALC883_DIGOUT_NID, 0,
9127};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009128
9129/*
9130 * configuration and preset
9131 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009132static const char *alc882_models[ALC882_MODEL_LAST] = {
9133 [ALC882_3ST_DIG] = "3stack-dig",
9134 [ALC882_6ST_DIG] = "6stack-dig",
9135 [ALC882_ARIMA] = "arima",
9136 [ALC882_W2JC] = "w2jc",
9137 [ALC882_TARGA] = "targa",
9138 [ALC882_ASUS_A7J] = "asus-a7j",
9139 [ALC882_ASUS_A7M] = "asus-a7m",
9140 [ALC885_MACPRO] = "macpro",
9141 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009142 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009143 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009144 [ALC885_MBP3] = "mbp3",
9145 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009146 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009147 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009148 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9149 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009150 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009151 [ALC883_TARGA_DIG] = "targa-dig",
9152 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009153 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009154 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009155 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009156 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009157 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009158 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009159 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009160 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009161 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009162 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009163 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009164 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9165 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009166 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009167 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009168 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009169 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009170 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309171 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009172 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009173 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009174 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009175 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009176 [ALC889A_INTEL] = "intel-alc889a",
9177 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009178 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009179 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009180 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009181 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009182};
9183
Takashi Iwai4953550a2009-06-30 15:28:30 +02009184static struct snd_pci_quirk alc882_cfg_tbl[] = {
9185 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9186
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009187 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009188 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009189 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009190 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9191 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009192 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009193 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9194 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009195 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009196 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009197 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9198 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009199 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9200 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009201 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9202 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009203 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009204 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009205 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009206 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009207 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9208 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009209 /* default Acer -- disabled as it causes more problems.
9210 * model=auto should work fine now
9211 */
9212 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009213
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009214 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009215
Tobin Davisfebe3372007-06-12 11:27:46 +02009216 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009217 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9218 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009219 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009220 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009221 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009222
9223 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9224 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9225 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009226 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009227 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9228 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9229 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009230 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009231 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009232 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009233 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009234
9235 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009236 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009237 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009238 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009239 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9240 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009241 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009242 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009243 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9244
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009245 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9246 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9247 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009248 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009249 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009250 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009251 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009252 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009253 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9254 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9255 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9256 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9257 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9258 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009259 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009260 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9261 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9262 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009263 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009264 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009265 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9266 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009267 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009268 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009269 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009270 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009271 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009272 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009273 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009274 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009275 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009276
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009277 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009278 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9279 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309280 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009281 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009282 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009283 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009284 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009285 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009286 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009287 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009288 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009289 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009290 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009291 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9292 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009293 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009294 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009295 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009296 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009297 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009298
Jiang zhe17bba1b2008-06-04 12:11:07 +02009299 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9300 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009301 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009302 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9303 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9304 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009305 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009306
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009307 {}
9308};
9309
Takashi Iwai4953550a2009-06-30 15:28:30 +02009310/* codec SSID table for Intel Mac */
9311static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9312 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9313 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9314 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9315 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9316 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9317 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9318 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
9319 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9320 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9321 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009322 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009323 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009324 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9325 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009326 */
9327 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009328 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009329 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009330 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009331};
9332
Takashi Iwai4953550a2009-06-30 15:28:30 +02009333static struct alc_config_preset alc882_presets[] = {
9334 [ALC882_3ST_DIG] = {
9335 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009336 .init_verbs = { alc882_base_init_verbs,
9337 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009338 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9339 .dac_nids = alc882_dac_nids,
9340 .dig_out_nid = ALC882_DIGOUT_NID,
9341 .dig_in_nid = ALC882_DIGIN_NID,
9342 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9343 .channel_mode = alc882_ch_modes,
9344 .need_dac_fix = 1,
9345 .input_mux = &alc882_capture_source,
9346 },
9347 [ALC882_6ST_DIG] = {
9348 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009349 .init_verbs = { alc882_base_init_verbs,
9350 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009351 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9352 .dac_nids = alc882_dac_nids,
9353 .dig_out_nid = ALC882_DIGOUT_NID,
9354 .dig_in_nid = ALC882_DIGIN_NID,
9355 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9356 .channel_mode = alc882_sixstack_modes,
9357 .input_mux = &alc882_capture_source,
9358 },
9359 [ALC882_ARIMA] = {
9360 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009361 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9362 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009363 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9364 .dac_nids = alc882_dac_nids,
9365 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9366 .channel_mode = alc882_sixstack_modes,
9367 .input_mux = &alc882_capture_source,
9368 },
9369 [ALC882_W2JC] = {
9370 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009371 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9372 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009373 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9374 .dac_nids = alc882_dac_nids,
9375 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9376 .channel_mode = alc880_threestack_modes,
9377 .need_dac_fix = 1,
9378 .input_mux = &alc882_capture_source,
9379 .dig_out_nid = ALC882_DIGOUT_NID,
9380 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009381 [ALC885_MBA21] = {
9382 .mixers = { alc885_mba21_mixer },
9383 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9384 .num_dacs = 2,
9385 .dac_nids = alc882_dac_nids,
9386 .channel_mode = alc885_mba21_ch_modes,
9387 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9388 .input_mux = &alc882_capture_source,
9389 .unsol_event = alc_automute_amp_unsol_event,
9390 .setup = alc885_mba21_setup,
9391 .init_hook = alc_automute_amp,
9392 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009393 [ALC885_MBP3] = {
9394 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9395 .init_verbs = { alc885_mbp3_init_verbs,
9396 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009397 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009398 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009399 .hp_nid = 0x04,
9400 .channel_mode = alc885_mbp_4ch_modes,
9401 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009402 .input_mux = &alc882_capture_source,
9403 .dig_out_nid = ALC882_DIGOUT_NID,
9404 .dig_in_nid = ALC882_DIGIN_NID,
9405 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009406 .setup = alc885_mbp3_setup,
9407 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009408 },
9409 [ALC885_MB5] = {
9410 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9411 .init_verbs = { alc885_mb5_init_verbs,
9412 alc880_gpio1_init_verbs },
9413 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9414 .dac_nids = alc882_dac_nids,
9415 .channel_mode = alc885_mb5_6ch_modes,
9416 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9417 .input_mux = &mb5_capture_source,
9418 .dig_out_nid = ALC882_DIGOUT_NID,
9419 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009420 .unsol_event = alc_automute_amp_unsol_event,
9421 .setup = alc885_mb5_setup,
9422 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009423 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009424 [ALC885_MACMINI3] = {
9425 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9426 .init_verbs = { alc885_macmini3_init_verbs,
9427 alc880_gpio1_init_verbs },
9428 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9429 .dac_nids = alc882_dac_nids,
9430 .channel_mode = alc885_macmini3_6ch_modes,
9431 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9432 .input_mux = &macmini3_capture_source,
9433 .dig_out_nid = ALC882_DIGOUT_NID,
9434 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009435 .unsol_event = alc_automute_amp_unsol_event,
9436 .setup = alc885_macmini3_setup,
9437 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009438 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009439 [ALC885_MACPRO] = {
9440 .mixers = { alc882_macpro_mixer },
9441 .init_verbs = { alc882_macpro_init_verbs },
9442 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9443 .dac_nids = alc882_dac_nids,
9444 .dig_out_nid = ALC882_DIGOUT_NID,
9445 .dig_in_nid = ALC882_DIGIN_NID,
9446 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9447 .channel_mode = alc882_ch_modes,
9448 .input_mux = &alc882_capture_source,
9449 .init_hook = alc885_macpro_init_hook,
9450 },
9451 [ALC885_IMAC24] = {
9452 .mixers = { alc885_imac24_mixer },
9453 .init_verbs = { alc885_imac24_init_verbs },
9454 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9455 .dac_nids = alc882_dac_nids,
9456 .dig_out_nid = ALC882_DIGOUT_NID,
9457 .dig_in_nid = ALC882_DIGIN_NID,
9458 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9459 .channel_mode = alc882_ch_modes,
9460 .input_mux = &alc882_capture_source,
9461 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009462 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009463 .init_hook = alc885_imac24_init_hook,
9464 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009465 [ALC885_IMAC91] = {
9466 .mixers = { alc885_imac91_mixer, alc882_chmode_mixer },
9467 .init_verbs = { alc885_imac91_init_verbs,
9468 alc880_gpio1_init_verbs },
9469 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9470 .dac_nids = alc882_dac_nids,
9471 .channel_mode = alc885_mbp_4ch_modes,
9472 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
9473 .input_mux = &alc882_capture_source,
9474 .dig_out_nid = ALC882_DIGOUT_NID,
9475 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009476 .unsol_event = alc_automute_amp_unsol_event,
9477 .setup = alc885_imac91_setup,
9478 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009479 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009480 [ALC882_TARGA] = {
9481 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009482 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009483 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009484 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9485 .dac_nids = alc882_dac_nids,
9486 .dig_out_nid = ALC882_DIGOUT_NID,
9487 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9488 .adc_nids = alc882_adc_nids,
9489 .capsrc_nids = alc882_capsrc_nids,
9490 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9491 .channel_mode = alc882_3ST_6ch_modes,
9492 .need_dac_fix = 1,
9493 .input_mux = &alc882_capture_source,
9494 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009495 .setup = alc882_targa_setup,
9496 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009497 },
9498 [ALC882_ASUS_A7J] = {
9499 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009500 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9501 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009502 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9503 .dac_nids = alc882_dac_nids,
9504 .dig_out_nid = ALC882_DIGOUT_NID,
9505 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9506 .adc_nids = alc882_adc_nids,
9507 .capsrc_nids = alc882_capsrc_nids,
9508 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9509 .channel_mode = alc882_3ST_6ch_modes,
9510 .need_dac_fix = 1,
9511 .input_mux = &alc882_capture_source,
9512 },
9513 [ALC882_ASUS_A7M] = {
9514 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009515 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9516 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009517 alc882_asus_a7m_verbs },
9518 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9519 .dac_nids = alc882_dac_nids,
9520 .dig_out_nid = ALC882_DIGOUT_NID,
9521 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9522 .channel_mode = alc880_threestack_modes,
9523 .need_dac_fix = 1,
9524 .input_mux = &alc882_capture_source,
9525 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009526 [ALC883_3ST_2ch_DIG] = {
9527 .mixers = { alc883_3ST_2ch_mixer },
9528 .init_verbs = { alc883_init_verbs },
9529 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9530 .dac_nids = alc883_dac_nids,
9531 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009532 .dig_in_nid = ALC883_DIGIN_NID,
9533 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9534 .channel_mode = alc883_3ST_2ch_modes,
9535 .input_mux = &alc883_capture_source,
9536 },
9537 [ALC883_3ST_6ch_DIG] = {
9538 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9539 .init_verbs = { alc883_init_verbs },
9540 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9541 .dac_nids = alc883_dac_nids,
9542 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009543 .dig_in_nid = ALC883_DIGIN_NID,
9544 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9545 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009546 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009547 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009548 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009549 [ALC883_3ST_6ch] = {
9550 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9551 .init_verbs = { alc883_init_verbs },
9552 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9553 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009554 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9555 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009556 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009557 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009558 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009559 [ALC883_3ST_6ch_INTEL] = {
9560 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9561 .init_verbs = { alc883_init_verbs },
9562 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9563 .dac_nids = alc883_dac_nids,
9564 .dig_out_nid = ALC883_DIGOUT_NID,
9565 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009566 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009567 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9568 .channel_mode = alc883_3ST_6ch_intel_modes,
9569 .need_dac_fix = 1,
9570 .input_mux = &alc883_3stack_6ch_intel,
9571 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009572 [ALC889A_INTEL] = {
9573 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009574 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9575 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009576 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9577 .dac_nids = alc883_dac_nids,
9578 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9579 .adc_nids = alc889_adc_nids,
9580 .dig_out_nid = ALC883_DIGOUT_NID,
9581 .dig_in_nid = ALC883_DIGIN_NID,
9582 .slave_dig_outs = alc883_slave_dig_outs,
9583 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9584 .channel_mode = alc889_8ch_intel_modes,
9585 .capsrc_nids = alc889_capsrc_nids,
9586 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009587 .setup = alc889_automute_setup,
9588 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009589 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009590 .need_dac_fix = 1,
9591 },
9592 [ALC889_INTEL] = {
9593 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9594 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009595 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009596 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9597 .dac_nids = alc883_dac_nids,
9598 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9599 .adc_nids = alc889_adc_nids,
9600 .dig_out_nid = ALC883_DIGOUT_NID,
9601 .dig_in_nid = ALC883_DIGIN_NID,
9602 .slave_dig_outs = alc883_slave_dig_outs,
9603 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9604 .channel_mode = alc889_8ch_intel_modes,
9605 .capsrc_nids = alc889_capsrc_nids,
9606 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009607 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009608 .init_hook = alc889_intel_init_hook,
9609 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009610 .need_dac_fix = 1,
9611 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009612 [ALC883_6ST_DIG] = {
9613 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9614 .init_verbs = { alc883_init_verbs },
9615 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9616 .dac_nids = alc883_dac_nids,
9617 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009618 .dig_in_nid = ALC883_DIGIN_NID,
9619 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9620 .channel_mode = alc883_sixstack_modes,
9621 .input_mux = &alc883_capture_source,
9622 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009623 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009624 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009625 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9626 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009627 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9628 .dac_nids = alc883_dac_nids,
9629 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009630 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9631 .channel_mode = alc883_3ST_6ch_modes,
9632 .need_dac_fix = 1,
9633 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009634 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009635 .setup = alc882_targa_setup,
9636 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009637 },
9638 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009639 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009640 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9641 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009642 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9643 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009644 .adc_nids = alc883_adc_nids_alt,
9645 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009646 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009647 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009648 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9649 .channel_mode = alc883_3ST_2ch_modes,
9650 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009651 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009652 .setup = alc882_targa_setup,
9653 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009654 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009655 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009656 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9657 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009658 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009659 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009660 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9661 .dac_nids = alc883_dac_nids,
9662 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9663 .adc_nids = alc883_adc_nids_rev,
9664 .capsrc_nids = alc883_capsrc_nids_rev,
9665 .dig_out_nid = ALC883_DIGOUT_NID,
9666 .dig_in_nid = ALC883_DIGIN_NID,
9667 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9668 .channel_mode = alc883_4ST_8ch_modes,
9669 .need_dac_fix = 1,
9670 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009671 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009672 .setup = alc882_targa_setup,
9673 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009674 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009675 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009676 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009677 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9678 * and the headphone jack. Turn this on and rely on the
9679 * standard mute methods whenever the user wants to turn
9680 * these outputs off.
9681 */
9682 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9683 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9684 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009685 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9686 .channel_mode = alc883_3ST_2ch_modes,
9687 .input_mux = &alc883_capture_source,
9688 },
Tobin Davis2880a862007-08-07 11:50:26 +02009689 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009690 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009691 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009692 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9693 .dac_nids = alc883_dac_nids,
9694 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009695 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9696 .channel_mode = alc883_3ST_2ch_modes,
9697 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009698 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009699 .setup = alc883_acer_aspire_setup,
9700 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009701 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009702 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009703 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009704 alc883_chmode_mixer },
9705 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9706 alc888_acer_aspire_4930g_verbs },
9707 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9708 .dac_nids = alc883_dac_nids,
9709 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9710 .adc_nids = alc883_adc_nids_rev,
9711 .capsrc_nids = alc883_capsrc_nids_rev,
9712 .dig_out_nid = ALC883_DIGOUT_NID,
9713 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9714 .channel_mode = alc883_3ST_6ch_modes,
9715 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +01009716 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009717 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009718 ARRAY_SIZE(alc888_2_capture_sources),
9719 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009720 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009721 .setup = alc888_acer_aspire_4930g_setup,
9722 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009723 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009724 [ALC888_ACER_ASPIRE_6530G] = {
9725 .mixers = { alc888_acer_aspire_6530_mixer },
9726 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9727 alc888_acer_aspire_6530g_verbs },
9728 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9729 .dac_nids = alc883_dac_nids,
9730 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9731 .adc_nids = alc883_adc_nids_rev,
9732 .capsrc_nids = alc883_capsrc_nids_rev,
9733 .dig_out_nid = ALC883_DIGOUT_NID,
9734 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9735 .channel_mode = alc883_3ST_2ch_modes,
9736 .num_mux_defs =
9737 ARRAY_SIZE(alc888_2_capture_sources),
9738 .input_mux = alc888_acer_aspire_6530_sources,
9739 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009740 .setup = alc888_acer_aspire_6530g_setup,
9741 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009742 },
Hector Martin3b315d72009-06-02 10:54:19 +02009743 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +01009744 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +02009745 alc883_chmode_mixer },
9746 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +01009747 alc889_acer_aspire_8930g_verbs,
9748 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +02009749 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9750 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009751 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9752 .adc_nids = alc889_adc_nids,
9753 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009754 .dig_out_nid = ALC883_DIGOUT_NID,
9755 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9756 .channel_mode = alc883_3ST_6ch_modes,
9757 .need_dac_fix = 1,
9758 .const_channel_count = 6,
9759 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009760 ARRAY_SIZE(alc889_capture_sources),
9761 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009762 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009763 .setup = alc889_acer_aspire_8930g_setup,
9764 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +01009765#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05009766 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +01009767#endif
Hector Martin3b315d72009-06-02 10:54:19 +02009768 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009769 [ALC888_ACER_ASPIRE_7730G] = {
9770 .mixers = { alc883_3ST_6ch_mixer,
9771 alc883_chmode_mixer },
9772 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9773 alc888_acer_aspire_7730G_verbs },
9774 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9775 .dac_nids = alc883_dac_nids,
9776 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9777 .adc_nids = alc883_adc_nids_rev,
9778 .capsrc_nids = alc883_capsrc_nids_rev,
9779 .dig_out_nid = ALC883_DIGOUT_NID,
9780 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9781 .channel_mode = alc883_3ST_6ch_modes,
9782 .need_dac_fix = 1,
9783 .const_channel_count = 6,
9784 .input_mux = &alc883_capture_source,
9785 .unsol_event = alc_automute_amp_unsol_event,
9786 .setup = alc888_acer_aspire_6530g_setup,
9787 .init_hook = alc_automute_amp,
9788 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009789 [ALC883_MEDION] = {
9790 .mixers = { alc883_fivestack_mixer,
9791 alc883_chmode_mixer },
9792 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009793 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009794 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9795 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009796 .adc_nids = alc883_adc_nids_alt,
9797 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009798 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009799 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9800 .channel_mode = alc883_sixstack_modes,
9801 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009802 },
Kailang Yang272a5272007-05-14 11:00:38 +02009803 [ALC883_MEDION_MD2] = {
9804 .mixers = { alc883_medion_md2_mixer},
9805 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9806 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9807 .dac_nids = alc883_dac_nids,
9808 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009809 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9810 .channel_mode = alc883_3ST_2ch_modes,
9811 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009812 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009813 .setup = alc883_medion_md2_setup,
9814 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009815 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009816 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009817 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009818 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9819 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9820 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009821 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9822 .channel_mode = alc883_3ST_2ch_modes,
9823 .input_mux = &alc883_capture_source,
9824 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309825 [ALC883_CLEVO_M540R] = {
9826 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9827 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9828 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9829 .dac_nids = alc883_dac_nids,
9830 .dig_out_nid = ALC883_DIGOUT_NID,
9831 .dig_in_nid = ALC883_DIGIN_NID,
9832 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9833 .channel_mode = alc883_3ST_6ch_clevo_modes,
9834 .need_dac_fix = 1,
9835 .input_mux = &alc883_capture_source,
9836 /* This machine has the hardware HP auto-muting, thus
9837 * we need no software mute via unsol event
9838 */
9839 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009840 [ALC883_CLEVO_M720] = {
9841 .mixers = { alc883_clevo_m720_mixer },
9842 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009843 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9844 .dac_nids = alc883_dac_nids,
9845 .dig_out_nid = ALC883_DIGOUT_NID,
9846 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9847 .channel_mode = alc883_3ST_2ch_modes,
9848 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009849 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009850 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009851 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009852 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009853 [ALC883_LENOVO_101E_2ch] = {
9854 .mixers = { alc883_lenovo_101e_2ch_mixer},
9855 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9856 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9857 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009858 .adc_nids = alc883_adc_nids_alt,
9859 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009860 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009861 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9862 .channel_mode = alc883_3ST_2ch_modes,
9863 .input_mux = &alc883_lenovo_101e_capture_source,
9864 .unsol_event = alc883_lenovo_101e_unsol_event,
9865 .init_hook = alc883_lenovo_101e_all_automute,
9866 },
Kailang Yang272a5272007-05-14 11:00:38 +02009867 [ALC883_LENOVO_NB0763] = {
9868 .mixers = { alc883_lenovo_nb0763_mixer },
9869 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9870 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9871 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009872 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9873 .channel_mode = alc883_3ST_2ch_modes,
9874 .need_dac_fix = 1,
9875 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009876 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009877 .setup = alc883_medion_md2_setup,
9878 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009879 },
9880 [ALC888_LENOVO_MS7195_DIG] = {
9881 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9882 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9883 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9884 .dac_nids = alc883_dac_nids,
9885 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009886 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9887 .channel_mode = alc883_3ST_6ch_modes,
9888 .need_dac_fix = 1,
9889 .input_mux = &alc883_capture_source,
9890 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9891 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009892 },
9893 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009894 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009895 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9896 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9897 .dac_nids = alc883_dac_nids,
9898 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009899 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9900 .channel_mode = alc883_3ST_2ch_modes,
9901 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009902 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009903 .setup = alc883_haier_w66_setup,
9904 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009905 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009906 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009907 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009908 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009909 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9910 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009911 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9912 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009913 .need_dac_fix = 1,
9914 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009915 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009916 .setup = alc888_3st_hp_setup,
9917 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009918 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009919 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009920 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009921 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9922 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9923 .dac_nids = alc883_dac_nids,
9924 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009925 .dig_in_nid = ALC883_DIGIN_NID,
9926 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9927 .channel_mode = alc883_sixstack_modes,
9928 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009929 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009930 .setup = alc888_6st_dell_setup,
9931 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009932 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009933 [ALC883_MITAC] = {
9934 .mixers = { alc883_mitac_mixer },
9935 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9936 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9937 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009938 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9939 .channel_mode = alc883_3ST_2ch_modes,
9940 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009941 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009942 .setup = alc883_mitac_setup,
9943 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009944 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009945 [ALC883_FUJITSU_PI2515] = {
9946 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9947 .init_verbs = { alc883_init_verbs,
9948 alc883_2ch_fujitsu_pi2515_verbs},
9949 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9950 .dac_nids = alc883_dac_nids,
9951 .dig_out_nid = ALC883_DIGOUT_NID,
9952 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9953 .channel_mode = alc883_3ST_2ch_modes,
9954 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009955 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009956 .setup = alc883_2ch_fujitsu_pi2515_setup,
9957 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009958 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009959 [ALC888_FUJITSU_XA3530] = {
9960 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9961 .init_verbs = { alc883_init_verbs,
9962 alc888_fujitsu_xa3530_verbs },
9963 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9964 .dac_nids = alc883_dac_nids,
9965 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9966 .adc_nids = alc883_adc_nids_rev,
9967 .capsrc_nids = alc883_capsrc_nids_rev,
9968 .dig_out_nid = ALC883_DIGOUT_NID,
9969 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9970 .channel_mode = alc888_4ST_8ch_intel_modes,
9971 .num_mux_defs =
9972 ARRAY_SIZE(alc888_2_capture_sources),
9973 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009974 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009975 .setup = alc888_fujitsu_xa3530_setup,
9976 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009977 },
Kailang Yange2757d52008-08-26 13:17:46 +02009978 [ALC888_LENOVO_SKY] = {
9979 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9980 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9981 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9982 .dac_nids = alc883_dac_nids,
9983 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009984 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9985 .channel_mode = alc883_sixstack_modes,
9986 .need_dac_fix = 1,
9987 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009988 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009989 .setup = alc888_lenovo_sky_setup,
9990 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009991 },
9992 [ALC888_ASUS_M90V] = {
9993 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9994 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9995 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9996 .dac_nids = alc883_dac_nids,
9997 .dig_out_nid = ALC883_DIGOUT_NID,
9998 .dig_in_nid = ALC883_DIGIN_NID,
9999 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10000 .channel_mode = alc883_3ST_6ch_modes,
10001 .need_dac_fix = 1,
10002 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010003 .unsol_event = alc_sku_unsol_event,
10004 .setup = alc883_mode2_setup,
10005 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010006 },
10007 [ALC888_ASUS_EEE1601] = {
10008 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010009 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010010 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10011 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10012 .dac_nids = alc883_dac_nids,
10013 .dig_out_nid = ALC883_DIGOUT_NID,
10014 .dig_in_nid = ALC883_DIGIN_NID,
10015 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10016 .channel_mode = alc883_3ST_2ch_modes,
10017 .need_dac_fix = 1,
10018 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010019 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010020 .init_hook = alc883_eee1601_inithook,
10021 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010022 [ALC1200_ASUS_P5Q] = {
10023 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10024 .init_verbs = { alc883_init_verbs },
10025 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10026 .dac_nids = alc883_dac_nids,
10027 .dig_out_nid = ALC1200_DIGOUT_NID,
10028 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010029 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010030 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10031 .channel_mode = alc883_sixstack_modes,
10032 .input_mux = &alc883_capture_source,
10033 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010034 [ALC889A_MB31] = {
10035 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10036 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10037 alc880_gpio1_init_verbs },
10038 .adc_nids = alc883_adc_nids,
10039 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010040 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010041 .dac_nids = alc883_dac_nids,
10042 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10043 .channel_mode = alc889A_mb31_6ch_modes,
10044 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10045 .input_mux = &alc889A_mb31_capture_source,
10046 .dig_out_nid = ALC883_DIGOUT_NID,
10047 .unsol_event = alc889A_mb31_unsol_event,
10048 .init_hook = alc889A_mb31_automute,
10049 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010050 [ALC883_SONY_VAIO_TT] = {
10051 .mixers = { alc883_vaiott_mixer },
10052 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10053 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10054 .dac_nids = alc883_dac_nids,
10055 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10056 .channel_mode = alc883_3ST_2ch_modes,
10057 .input_mux = &alc883_capture_source,
10058 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010059 .setup = alc883_vaiott_setup,
10060 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010061 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010062};
10063
10064
10065/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010066 * Pin config fixes
10067 */
10068enum {
10069 PINFIX_ABIT_AW9D_MAX
10070};
10071
10072static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
10073 { 0x15, 0x01080104 }, /* side */
10074 { 0x16, 0x01011012 }, /* rear */
10075 { 0x17, 0x01016011 }, /* clfe */
10076 { }
10077};
10078
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010079static const struct alc_fixup alc882_fixups[] = {
10080 [PINFIX_ABIT_AW9D_MAX] = {
10081 .pins = alc882_abit_aw9d_pinfix
10082 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010083};
10084
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010085static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +020010086 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10087 {}
10088};
10089
10090/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010091 * BIOS auto configuration
10092 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010093static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10094 const struct auto_pin_cfg *cfg)
10095{
10096 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10097}
10098
Takashi Iwai4953550a2009-06-30 15:28:30 +020010099static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010100 hda_nid_t nid, int pin_type,
10101 int dac_idx)
10102{
10103 /* set as output */
10104 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010105 int idx;
10106
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010107 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010108 if (spec->multiout.dac_nids[dac_idx] == 0x25)
10109 idx = 4;
Takashi Iwai6a4f2cc2010-03-25 15:00:15 +010010110 else {
10111 if (spec->multiout.num_dacs >= dac_idx)
10112 return;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010113 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai6a4f2cc2010-03-25 15:00:15 +010010114 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010115 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
10116
10117}
10118
Takashi Iwai4953550a2009-06-30 15:28:30 +020010119static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010120{
10121 struct alc_spec *spec = codec->spec;
10122 int i;
10123
10124 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010125 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010126 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010127 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010128 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010129 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010130 }
10131}
10132
Takashi Iwai4953550a2009-06-30 15:28:30 +020010133static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010134{
10135 struct alc_spec *spec = codec->spec;
10136 hda_nid_t pin;
10137
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010138 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010139 if (pin) /* connect to front */
10140 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010141 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010142 pin = spec->autocfg.speaker_pins[0];
10143 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010144 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010145}
10146
Takashi Iwai4953550a2009-06-30 15:28:30 +020010147static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010148{
10149 struct alc_spec *spec = codec->spec;
10150 int i;
10151
10152 for (i = 0; i < AUTO_PIN_LAST; i++) {
10153 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010154 if (!nid)
10155 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +020010156 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010157 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10158 snd_hda_codec_write(codec, nid, 0,
10159 AC_VERB_SET_AMP_GAIN_MUTE,
10160 AMP_OUT_MUTE);
10161 }
10162}
10163
10164static void alc882_auto_init_input_src(struct hda_codec *codec)
10165{
10166 struct alc_spec *spec = codec->spec;
10167 int c;
10168
10169 for (c = 0; c < spec->num_adc_nids; c++) {
10170 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10171 hda_nid_t nid = spec->capsrc_nids[c];
10172 unsigned int mux_idx;
10173 const struct hda_input_mux *imux;
10174 int conns, mute, idx, item;
10175
10176 conns = snd_hda_get_connections(codec, nid, conn_list,
10177 ARRAY_SIZE(conn_list));
10178 if (conns < 0)
10179 continue;
10180 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10181 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010182 if (!imux->num_items && mux_idx > 0)
10183 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010184 for (idx = 0; idx < conns; idx++) {
10185 /* if the current connection is the selected one,
10186 * unmute it as default - otherwise mute it
10187 */
10188 mute = AMP_IN_MUTE(idx);
10189 for (item = 0; item < imux->num_items; item++) {
10190 if (imux->items[item].index == idx) {
10191 if (spec->cur_mux[c] == item)
10192 mute = AMP_IN_UNMUTE(idx);
10193 break;
10194 }
10195 }
10196 /* check if we have a selector or mixer
10197 * we could check for the widget type instead, but
10198 * just check for Amp-In presence (in case of mixer
10199 * without amp-in there is something wrong, this
10200 * function shouldn't be used or capsrc nid is wrong)
10201 */
10202 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010203 snd_hda_codec_write(codec, nid, 0,
10204 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010205 mute);
10206 else if (mute != AMP_IN_MUTE(idx))
10207 snd_hda_codec_write(codec, nid, 0,
10208 AC_VERB_SET_CONNECT_SEL,
10209 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010210 }
10211 }
10212}
10213
Takashi Iwai4953550a2009-06-30 15:28:30 +020010214/* add mic boosts if needed */
10215static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010216{
10217 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010218 int err;
10219 hda_nid_t nid;
10220
10221 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
10222 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10223 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10224 "Mic Boost",
10225 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10226 if (err < 0)
10227 return err;
10228 }
10229 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
10230 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10231 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10232 "Front Mic Boost",
10233 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10234 if (err < 0)
10235 return err;
10236 }
10237 return 0;
10238}
10239
10240/* almost identical with ALC880 parser... */
10241static int alc882_parse_auto_config(struct hda_codec *codec)
10242{
10243 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010244 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
10245 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010246
Takashi Iwai05f5f472009-08-25 13:10:18 +020010247 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10248 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010249 if (err < 0)
10250 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010251 if (!spec->autocfg.line_outs)
10252 return 0; /* can't find valid BIOS pin config */
10253
10254 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10255 if (err < 0)
10256 return err;
10257 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10258 if (err < 0)
10259 return err;
10260 err = alc880_auto_create_extra_out(spec,
10261 spec->autocfg.speaker_pins[0],
10262 "Speaker");
10263 if (err < 0)
10264 return err;
10265 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10266 "Headphone");
10267 if (err < 0)
10268 return err;
10269 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10270 if (err < 0)
10271 return err;
10272
10273 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10274
10275 /* check multiple SPDIF-out (for recent codecs) */
10276 for (i = 0; i < spec->autocfg.dig_outs; i++) {
10277 hda_nid_t dig_nid;
10278 err = snd_hda_get_connections(codec,
10279 spec->autocfg.dig_out_pins[i],
10280 &dig_nid, 1);
10281 if (err < 0)
10282 continue;
10283 if (!i)
10284 spec->multiout.dig_out_nid = dig_nid;
10285 else {
10286 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010287 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +020010288 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010289 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010290 }
10291 }
10292 if (spec->autocfg.dig_in_pin)
10293 spec->dig_in_nid = ALC880_DIGIN_NID;
10294
10295 if (spec->kctls.list)
10296 add_mixer(spec, spec->kctls.list);
10297
10298 add_verb(spec, alc883_auto_init_verbs);
10299 /* if ADC 0x07 is available, initialize it, too */
10300 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10301 add_verb(spec, alc882_adc1_init_verbs);
10302
10303 spec->num_mux_defs = 1;
10304 spec->input_mux = &spec->private_imux[0];
10305
Kailang Yang6227cdc2010-02-25 08:36:52 +010010306 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010307
10308 err = alc_auto_add_mic_boost(codec);
10309 if (err < 0)
10310 return err;
10311
Takashi Iwai776e1842007-08-29 15:07:11 +020010312 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010313}
10314
10315/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010316static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010317{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010318 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010319 alc882_auto_init_multi_out(codec);
10320 alc882_auto_init_hp_out(codec);
10321 alc882_auto_init_analog_input(codec);
10322 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010323 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010324 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010325}
10326
Takashi Iwai4953550a2009-06-30 15:28:30 +020010327static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010328{
10329 struct alc_spec *spec;
10330 int err, board_config;
10331
10332 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10333 if (spec == NULL)
10334 return -ENOMEM;
10335
10336 codec->spec = spec;
10337
Takashi Iwai4953550a2009-06-30 15:28:30 +020010338 switch (codec->vendor_id) {
10339 case 0x10ec0882:
10340 case 0x10ec0885:
10341 break;
10342 default:
10343 /* ALC883 and variants */
10344 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10345 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010346 }
10347
Takashi Iwai4953550a2009-06-30 15:28:30 +020010348 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10349 alc882_models,
10350 alc882_cfg_tbl);
10351
10352 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10353 board_config = snd_hda_check_board_codec_sid_config(codec,
10354 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10355
10356 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010357 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010358 codec->chip_name);
10359 board_config = ALC882_AUTO;
10360 }
10361
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010362 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010363
10364 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010365 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010366 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010367 if (err < 0) {
10368 alc_free(codec);
10369 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010370 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010371 printk(KERN_INFO
10372 "hda_codec: Cannot set up configuration "
10373 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010374 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010375 }
10376 }
10377
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010378 err = snd_hda_attach_beep_device(codec, 0x1);
10379 if (err < 0) {
10380 alc_free(codec);
10381 return err;
10382 }
10383
Takashi Iwai4953550a2009-06-30 15:28:30 +020010384 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010385 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010386
Takashi Iwai4953550a2009-06-30 15:28:30 +020010387 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10388 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10389 /* FIXME: setup DAC5 */
10390 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10391 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10392
10393 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10394 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10395
10396 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010397 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010398
10399 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010400 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010401 spec->num_adc_nids = 0;
10402 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010403 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010404 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010405 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010406 hda_nid_t nid = alc882_adc_nids[i];
10407 unsigned int wcap = get_wcaps(codec, nid);
10408 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010409 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010410 if (wcap != AC_WID_AUD_IN)
10411 continue;
10412 spec->private_adc_nids[spec->num_adc_nids] = nid;
10413 err = snd_hda_get_connections(codec, nid, &cap, 1);
10414 if (err < 0)
10415 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010416 err = snd_hda_get_connections(codec, cap, items,
10417 ARRAY_SIZE(items));
10418 if (err < 0)
10419 continue;
10420 for (j = 0; j < imux->num_items; j++)
10421 if (imux->items[j].index >= err)
10422 break;
10423 if (j < imux->num_items)
10424 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010425 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10426 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010427 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010428 spec->adc_nids = spec->private_adc_nids;
10429 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010430 }
10431
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010432 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010010433 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010434
Takashi Iwai2134ea42008-01-10 16:53:55 +010010435 spec->vmaster_nid = 0x0c;
10436
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010437 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010438 if (board_config == ALC882_AUTO)
10439 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010440#ifdef CONFIG_SND_HDA_POWER_SAVE
10441 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010442 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010443#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010444
10445 return 0;
10446}
10447
Takashi Iwai4953550a2009-06-30 15:28:30 +020010448
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010449/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010450 * ALC262 support
10451 */
10452
10453#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10454#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10455
10456#define alc262_dac_nids alc260_dac_nids
10457#define alc262_adc_nids alc882_adc_nids
10458#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010459#define alc262_capsrc_nids alc882_capsrc_nids
10460#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010461
10462#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010463#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010464
Kailang Yang4e555fe2008-08-26 13:05:55 +020010465static hda_nid_t alc262_dmic_adc_nids[1] = {
10466 /* ADC0 */
10467 0x09
10468};
10469
10470static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10471
Kailang Yangdf694da2005-12-05 19:42:22 +010010472static struct snd_kcontrol_new alc262_base_mixer[] = {
10473 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10474 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10475 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10476 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10477 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10478 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10479 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10480 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010481 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010482 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10483 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010484 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010485 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10486 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10487 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10488 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010489 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010490};
10491
Takashi Iwaice875f02008-01-28 18:17:43 +010010492/* update HP, line and mono-out pins according to the master switch */
10493static void alc262_hp_master_update(struct hda_codec *codec)
10494{
10495 struct alc_spec *spec = codec->spec;
10496 int val = spec->master_sw;
10497
10498 /* HP & line-out */
10499 snd_hda_codec_write_cache(codec, 0x1b, 0,
10500 AC_VERB_SET_PIN_WIDGET_CONTROL,
10501 val ? PIN_HP : 0);
10502 snd_hda_codec_write_cache(codec, 0x15, 0,
10503 AC_VERB_SET_PIN_WIDGET_CONTROL,
10504 val ? PIN_HP : 0);
10505 /* mono (speaker) depending on the HP jack sense */
10506 val = val && !spec->jack_present;
10507 snd_hda_codec_write_cache(codec, 0x16, 0,
10508 AC_VERB_SET_PIN_WIDGET_CONTROL,
10509 val ? PIN_OUT : 0);
10510}
10511
10512static void alc262_hp_bpc_automute(struct hda_codec *codec)
10513{
10514 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010515
10516 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010517 alc262_hp_master_update(codec);
10518}
10519
10520static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10521{
10522 if ((res >> 26) != ALC880_HP_EVENT)
10523 return;
10524 alc262_hp_bpc_automute(codec);
10525}
10526
10527static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10528{
10529 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010530
10531 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010532 alc262_hp_master_update(codec);
10533}
10534
10535static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10536 unsigned int res)
10537{
10538 if ((res >> 26) != ALC880_HP_EVENT)
10539 return;
10540 alc262_hp_wildwest_automute(codec);
10541}
10542
Takashi Iwaib72519b2009-05-08 14:31:55 +020010543#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010544
10545static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10546 struct snd_ctl_elem_value *ucontrol)
10547{
10548 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10549 struct alc_spec *spec = codec->spec;
10550 int val = !!*ucontrol->value.integer.value;
10551
10552 if (val == spec->master_sw)
10553 return 0;
10554 spec->master_sw = val;
10555 alc262_hp_master_update(codec);
10556 return 1;
10557}
10558
Takashi Iwaib72519b2009-05-08 14:31:55 +020010559#define ALC262_HP_MASTER_SWITCH \
10560 { \
10561 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10562 .name = "Master Playback Switch", \
10563 .info = snd_ctl_boolean_mono_info, \
10564 .get = alc262_hp_master_sw_get, \
10565 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010566 }, \
10567 { \
10568 .iface = NID_MAPPING, \
10569 .name = "Master Playback Switch", \
10570 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020010571 }
10572
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010573
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010574static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010575 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010576 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10577 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10578 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010579 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10580 HDA_OUTPUT),
10581 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10582 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010583 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10584 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010585 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010586 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10587 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010588 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010589 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10590 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10591 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10592 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010593 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10594 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10595 { } /* end */
10596};
10597
Kailang Yangcd7509a2007-01-26 18:33:17 +010010598static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010599 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010600 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10601 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10602 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10603 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010604 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10605 HDA_OUTPUT),
10606 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10607 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010608 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10609 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010610 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010611 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10612 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10613 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10614 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010615 { } /* end */
10616};
10617
10618static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10619 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10620 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010621 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010622 { } /* end */
10623};
10624
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010625/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010626static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010627{
10628 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010629
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010630 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010010631 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010632}
10633
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010634static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010635 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10636 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010637 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10638 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10639 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10640 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10641 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10642 { } /* end */
10643};
10644
10645static struct hda_verb alc262_hp_t5735_verbs[] = {
10646 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10647 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10648
10649 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10650 { }
10651};
10652
Kailang Yang8c427222008-01-10 13:03:59 +010010653static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010654 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10655 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010656 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10657 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010658 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10659 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10660 { } /* end */
10661};
10662
10663static struct hda_verb alc262_hp_rp5700_verbs[] = {
10664 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10665 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10666 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10667 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10668 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10669 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10670 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10671 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10672 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10673 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10674 {}
10675};
10676
10677static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10678 .num_items = 1,
10679 .items = {
10680 { "Line", 0x1 },
10681 },
10682};
10683
Takashi Iwai42171c12009-05-08 14:11:43 +020010684/* bind hp and internal speaker mute (with plug check) as master switch */
10685static void alc262_hippo_master_update(struct hda_codec *codec)
10686{
10687 struct alc_spec *spec = codec->spec;
10688 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10689 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10690 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10691 unsigned int mute;
10692
10693 /* HP */
10694 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10695 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10696 HDA_AMP_MUTE, mute);
10697 /* mute internal speaker per jack sense */
10698 if (spec->jack_present)
10699 mute = HDA_AMP_MUTE;
10700 if (line_nid)
10701 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10702 HDA_AMP_MUTE, mute);
10703 if (speaker_nid && speaker_nid != line_nid)
10704 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10705 HDA_AMP_MUTE, mute);
10706}
10707
10708#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10709
10710static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10711 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010712{
10713 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010714 struct alc_spec *spec = codec->spec;
10715 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010716
Takashi Iwai42171c12009-05-08 14:11:43 +020010717 if (val == spec->master_sw)
10718 return 0;
10719 spec->master_sw = val;
10720 alc262_hippo_master_update(codec);
10721 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010722}
Takashi Iwai5b319542007-07-26 11:49:22 +020010723
Takashi Iwai42171c12009-05-08 14:11:43 +020010724#define ALC262_HIPPO_MASTER_SWITCH \
10725 { \
10726 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10727 .name = "Master Playback Switch", \
10728 .info = snd_ctl_boolean_mono_info, \
10729 .get = alc262_hippo_master_sw_get, \
10730 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010731 }, \
10732 { \
10733 .iface = NID_MAPPING, \
10734 .name = "Master Playback Switch", \
10735 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
10736 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020010737 }
10738
10739static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10740 ALC262_HIPPO_MASTER_SWITCH,
10741 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10742 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10743 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10744 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10745 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10746 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10747 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10748 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10749 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10750 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10751 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10752 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10753 { } /* end */
10754};
10755
10756static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10757 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10758 ALC262_HIPPO_MASTER_SWITCH,
10759 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10760 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10761 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10762 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10763 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10764 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10765 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10766 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10767 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10768 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10769 { } /* end */
10770};
10771
10772/* mute/unmute internal speaker according to the hp jack and mute state */
10773static void alc262_hippo_automute(struct hda_codec *codec)
10774{
10775 struct alc_spec *spec = codec->spec;
10776 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010777
Wu Fengguang864f92b2009-11-18 12:38:02 +080010778 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010779 alc262_hippo_master_update(codec);
10780}
10781
10782static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10783{
10784 if ((res >> 26) != ALC880_HP_EVENT)
10785 return;
10786 alc262_hippo_automute(codec);
10787}
10788
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010789static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010790{
10791 struct alc_spec *spec = codec->spec;
10792
10793 spec->autocfg.hp_pins[0] = 0x15;
10794 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010795}
10796
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010797static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010798{
10799 struct alc_spec *spec = codec->spec;
10800
10801 spec->autocfg.hp_pins[0] = 0x1b;
10802 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010803}
10804
10805
Kailang Yang272a5272007-05-14 11:00:38 +020010806static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010807 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010808 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010809 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10810 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10811 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10812 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10813 { } /* end */
10814};
10815
Kailang Yang83c34212007-07-05 11:43:05 +020010816static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010817 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10818 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010819 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10820 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10821 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10822 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10823 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10824 { } /* end */
10825};
Kailang Yang272a5272007-05-14 11:00:38 +020010826
Tony Vroonba340e82009-02-02 19:01:30 +000010827static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10828 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10829 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10830 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10831 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10832 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10833 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10834 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10835 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10836 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10837 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10838 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10839 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10840 { } /* end */
10841};
10842
10843static struct hda_verb alc262_tyan_verbs[] = {
10844 /* Headphone automute */
10845 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10846 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10847 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10848
10849 /* P11 AUX_IN, white 4-pin connector */
10850 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10851 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10852 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10853 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10854
10855 {}
10856};
10857
10858/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010859static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010860{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010861 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010862
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010863 spec->autocfg.hp_pins[0] = 0x1b;
10864 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010865}
10866
Tony Vroonba340e82009-02-02 19:01:30 +000010867
Kailang Yangdf694da2005-12-05 19:42:22 +010010868#define alc262_capture_mixer alc882_capture_mixer
10869#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10870
10871/*
10872 * generic initialization of ADC, input mixers and output mixers
10873 */
10874static struct hda_verb alc262_init_verbs[] = {
10875 /*
10876 * Unmute ADC0-2 and set the default input to mic-in
10877 */
10878 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10879 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10880 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10881 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10882 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10883 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10884
Takashi Iwaicb53c622007-08-10 17:21:45 +020010885 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010886 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010887 * Note: PASD motherboards uses the Line In 2 as the input for
10888 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010889 */
10890 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010891 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10892 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10893 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10894 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10895 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010896
10897 /*
10898 * Set up output mixers (0x0c - 0x0e)
10899 */
10900 /* set vol=0 to output mixers */
10901 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10902 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10903 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10904 /* set up input amps for analog loopback */
10905 /* Amp Indices: DAC = 0, mixer = 1 */
10906 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10907 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10908 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10909 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10910 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10911 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10912
10913 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10914 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10915 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10916 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10917 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10918 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10919
10920 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10921 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10922 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10923 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10924 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010925
Kailang Yangdf694da2005-12-05 19:42:22 +010010926 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10927 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010928
Kailang Yangdf694da2005-12-05 19:42:22 +010010929 /* FIXME: use matrix-type input source selection */
10930 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10931 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10932 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10933 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10934 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10935 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10936 /* Input mixer2 */
10937 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10938 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10939 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10940 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10941 /* Input mixer3 */
10942 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10943 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10944 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010945 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010946
10947 { }
10948};
10949
Kailang Yang4e555fe2008-08-26 13:05:55 +020010950static struct hda_verb alc262_eapd_verbs[] = {
10951 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10952 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10953 { }
10954};
10955
Kailang Yangccc656c2006-10-17 12:32:26 +020010956static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10957 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10958 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10959 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10960
10961 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10962 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10963 {}
10964};
10965
Kailang Yang272a5272007-05-14 11:00:38 +020010966static struct hda_verb alc262_sony_unsol_verbs[] = {
10967 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10968 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10969 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10970
10971 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10972 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010973 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010974};
10975
Kailang Yang4e555fe2008-08-26 13:05:55 +020010976static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10977 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10978 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10979 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10980 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10981 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010982 { } /* end */
10983};
10984
10985static struct hda_verb alc262_toshiba_s06_verbs[] = {
10986 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10987 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10988 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10989 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10990 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10991 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10992 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10993 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10994 {}
10995};
10996
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010997static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010998{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010999 struct alc_spec *spec = codec->spec;
11000
11001 spec->autocfg.hp_pins[0] = 0x15;
11002 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011003 spec->ext_mic.pin = 0x18;
11004 spec->ext_mic.mux_idx = 0;
11005 spec->int_mic.pin = 0x12;
11006 spec->int_mic.mux_idx = 9;
11007 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011008}
11009
Takashi Iwai834be882006-03-01 14:16:17 +010011010/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011011 * nec model
11012 * 0x15 = headphone
11013 * 0x16 = internal speaker
11014 * 0x18 = external mic
11015 */
11016
11017static struct snd_kcontrol_new alc262_nec_mixer[] = {
11018 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11019 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11020
11021 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11022 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11023 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11024
11025 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11026 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11027 { } /* end */
11028};
11029
11030static struct hda_verb alc262_nec_verbs[] = {
11031 /* Unmute Speaker */
11032 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11033
11034 /* Headphone */
11035 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11036 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11037
11038 /* External mic to headphone */
11039 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11040 /* External mic to speaker */
11041 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11042 {}
11043};
11044
11045/*
Takashi Iwai834be882006-03-01 14:16:17 +010011046 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011047 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11048 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011049 */
11050
11051#define ALC_HP_EVENT 0x37
11052
11053static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11054 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11055 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011056 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11057 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011058 {}
11059};
11060
Jiang zhe0e31daf2008-03-20 12:12:39 +010011061static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11062 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11063 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11064 {}
11065};
11066
Daniel T Chene2595322009-12-19 18:19:02 -050011067static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11068 /* Front Mic pin: input vref at 50% */
11069 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11070 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11071 {}
11072};
11073
Takashi Iwai834be882006-03-01 14:16:17 +010011074static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011075 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011076 .items = {
11077 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011078 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011079 { "CD", 0x4 },
11080 },
11081};
11082
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011083static struct hda_input_mux alc262_HP_capture_source = {
11084 .num_items = 5,
11085 .items = {
11086 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011087 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011088 { "Line", 0x2 },
11089 { "CD", 0x4 },
11090 { "AUX IN", 0x6 },
11091 },
11092};
11093
zhejiangaccbe492007-08-31 12:36:05 +020011094static struct hda_input_mux alc262_HP_D7000_capture_source = {
11095 .num_items = 4,
11096 .items = {
11097 { "Mic", 0x0 },
11098 { "Front Mic", 0x2 },
11099 { "Line", 0x1 },
11100 { "CD", 0x4 },
11101 },
11102};
11103
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011104/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011105static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11106{
11107 struct alc_spec *spec = codec->spec;
11108 unsigned int mute;
11109
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011110 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011111 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11112 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011113 spec->sense_updated = 1;
11114 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011115 /* unmute internal speaker only if both HPs are unplugged and
11116 * master switch is on
11117 */
11118 if (spec->jack_present)
11119 mute = HDA_AMP_MUTE;
11120 else
Takashi Iwai834be882006-03-01 14:16:17 +010011121 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011122 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11123 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011124}
11125
11126/* unsolicited event for HP jack sensing */
11127static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11128 unsigned int res)
11129{
11130 if ((res >> 26) != ALC_HP_EVENT)
11131 return;
11132 alc262_fujitsu_automute(codec, 1);
11133}
11134
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011135static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11136{
11137 alc262_fujitsu_automute(codec, 1);
11138}
11139
Takashi Iwai834be882006-03-01 14:16:17 +010011140/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011141static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11142 .ops = &snd_hda_bind_vol,
11143 .values = {
11144 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11145 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11146 0
11147 },
11148};
Takashi Iwai834be882006-03-01 14:16:17 +010011149
Jiang zhe0e31daf2008-03-20 12:12:39 +010011150/* mute/unmute internal speaker according to the hp jack and mute state */
11151static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11152{
11153 struct alc_spec *spec = codec->spec;
11154 unsigned int mute;
11155
11156 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011157 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011158 spec->sense_updated = 1;
11159 }
11160 if (spec->jack_present) {
11161 /* mute internal speaker */
11162 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11163 HDA_AMP_MUTE, HDA_AMP_MUTE);
11164 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11165 HDA_AMP_MUTE, HDA_AMP_MUTE);
11166 } else {
11167 /* unmute internal speaker if necessary */
11168 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11169 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11170 HDA_AMP_MUTE, mute);
11171 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11172 HDA_AMP_MUTE, mute);
11173 }
11174}
11175
11176/* unsolicited event for HP jack sensing */
11177static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11178 unsigned int res)
11179{
11180 if ((res >> 26) != ALC_HP_EVENT)
11181 return;
11182 alc262_lenovo_3000_automute(codec, 1);
11183}
11184
Takashi Iwai8de56b72009-07-24 16:51:47 +020011185static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11186 int dir, int idx, long *valp)
11187{
11188 int i, change = 0;
11189
11190 for (i = 0; i < 2; i++, valp++)
11191 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11192 HDA_AMP_MUTE,
11193 *valp ? 0 : HDA_AMP_MUTE);
11194 return change;
11195}
11196
Takashi Iwai834be882006-03-01 14:16:17 +010011197/* bind hp and internal speaker mute (with plug check) */
11198static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11199 struct snd_ctl_elem_value *ucontrol)
11200{
11201 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11202 long *valp = ucontrol->value.integer.value;
11203 int change;
11204
Takashi Iwai8de56b72009-07-24 16:51:47 +020011205 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11206 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011207 if (change)
11208 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011209 return change;
11210}
11211
11212static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011213 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011214 {
11215 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11216 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011217 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011218 .info = snd_hda_mixer_amp_switch_info,
11219 .get = snd_hda_mixer_amp_switch_get,
11220 .put = alc262_fujitsu_master_sw_put,
11221 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11222 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011223 {
11224 .iface = NID_MAPPING,
11225 .name = "Master Playback Switch",
11226 .private_value = 0x1b,
11227 },
Takashi Iwai834be882006-03-01 14:16:17 +010011228 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11229 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11230 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11231 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11232 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011233 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11234 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11235 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011236 { } /* end */
11237};
11238
Jiang zhe0e31daf2008-03-20 12:12:39 +010011239/* bind hp and internal speaker mute (with plug check) */
11240static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11241 struct snd_ctl_elem_value *ucontrol)
11242{
11243 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11244 long *valp = ucontrol->value.integer.value;
11245 int change;
11246
Takashi Iwai8de56b72009-07-24 16:51:47 +020011247 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011248 if (change)
11249 alc262_lenovo_3000_automute(codec, 0);
11250 return change;
11251}
11252
11253static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11254 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11255 {
11256 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11257 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011258 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011259 .info = snd_hda_mixer_amp_switch_info,
11260 .get = snd_hda_mixer_amp_switch_get,
11261 .put = alc262_lenovo_3000_master_sw_put,
11262 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11263 },
11264 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11265 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11266 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11267 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11268 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11269 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11270 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11271 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11272 { } /* end */
11273};
11274
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011275static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11276 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011277 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011278 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11279 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11280 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11281 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11282 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11283 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11284 { } /* end */
11285};
11286
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011287/* additional init verbs for Benq laptops */
11288static struct hda_verb alc262_EAPD_verbs[] = {
11289 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11290 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11291 {}
11292};
11293
Kailang Yang83c34212007-07-05 11:43:05 +020011294static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11295 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11296 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11297
11298 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11299 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11300 {}
11301};
11302
Tobin Davisf651b502007-10-26 12:40:47 +020011303/* Samsung Q1 Ultra Vista model setup */
11304static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011305 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11306 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011307 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11308 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11309 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011310 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011311 { } /* end */
11312};
11313
11314static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011315 /* output mixer */
11316 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11317 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11318 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11319 /* speaker */
11320 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11321 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11322 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11323 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11324 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011325 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011326 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11327 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11328 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11329 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11330 /* internal mic */
11331 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11332 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11333 /* ADC, choose mic */
11334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11335 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11336 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11337 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11338 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11339 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11340 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11341 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11342 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11343 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011344 {}
11345};
11346
Tobin Davisf651b502007-10-26 12:40:47 +020011347/* mute/unmute internal speaker according to the hp jack and mute state */
11348static void alc262_ultra_automute(struct hda_codec *codec)
11349{
11350 struct alc_spec *spec = codec->spec;
11351 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011352
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011353 mute = 0;
11354 /* auto-mute only when HP is used as HP */
11355 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011356 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011357 if (spec->jack_present)
11358 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011359 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011360 /* mute/unmute internal speaker */
11361 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11362 HDA_AMP_MUTE, mute);
11363 /* mute/unmute HP */
11364 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11365 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011366}
11367
11368/* unsolicited event for HP jack sensing */
11369static void alc262_ultra_unsol_event(struct hda_codec *codec,
11370 unsigned int res)
11371{
11372 if ((res >> 26) != ALC880_HP_EVENT)
11373 return;
11374 alc262_ultra_automute(codec);
11375}
11376
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011377static struct hda_input_mux alc262_ultra_capture_source = {
11378 .num_items = 2,
11379 .items = {
11380 { "Mic", 0x1 },
11381 { "Headphone", 0x7 },
11382 },
11383};
11384
11385static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11386 struct snd_ctl_elem_value *ucontrol)
11387{
11388 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11389 struct alc_spec *spec = codec->spec;
11390 int ret;
11391
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011392 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011393 if (!ret)
11394 return 0;
11395 /* reprogram the HP pin as mic or HP according to the input source */
11396 snd_hda_codec_write_cache(codec, 0x15, 0,
11397 AC_VERB_SET_PIN_WIDGET_CONTROL,
11398 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11399 alc262_ultra_automute(codec); /* mute/unmute HP */
11400 return ret;
11401}
11402
11403static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11404 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11405 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11406 {
11407 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11408 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011409 .info = alc_mux_enum_info,
11410 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011411 .put = alc262_ultra_mux_enum_put,
11412 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011413 {
11414 .iface = NID_MAPPING,
11415 .name = "Capture Source",
11416 .private_value = 0x15,
11417 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011418 { } /* end */
11419};
11420
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011421/* We use two mixers depending on the output pin; 0x16 is a mono output
11422 * and thus it's bound with a different mixer.
11423 * This function returns which mixer amp should be used.
11424 */
11425static int alc262_check_volbit(hda_nid_t nid)
11426{
11427 if (!nid)
11428 return 0;
11429 else if (nid == 0x16)
11430 return 2;
11431 else
11432 return 1;
11433}
11434
11435static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11436 const char *pfx, int *vbits)
11437{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011438 unsigned long val;
11439 int vbit;
11440
11441 vbit = alc262_check_volbit(nid);
11442 if (!vbit)
11443 return 0;
11444 if (*vbits & vbit) /* a volume control for this mixer already there */
11445 return 0;
11446 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011447 if (vbit == 2)
11448 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11449 else
11450 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011451 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011452}
11453
11454static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11455 const char *pfx)
11456{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011457 unsigned long val;
11458
11459 if (!nid)
11460 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011461 if (nid == 0x16)
11462 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11463 else
11464 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011465 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011466}
11467
Kailang Yangdf694da2005-12-05 19:42:22 +010011468/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011469static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11470 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011471{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011472 const char *pfx;
11473 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011474 int err;
11475
11476 spec->multiout.num_dacs = 1; /* only use one dac */
11477 spec->multiout.dac_nids = spec->private_dac_nids;
11478 spec->multiout.dac_nids[0] = 2;
11479
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011480 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11481 pfx = "Master";
11482 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11483 pfx = "Speaker";
11484 else
11485 pfx = "Front";
11486 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11487 if (err < 0)
11488 return err;
11489 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11490 if (err < 0)
11491 return err;
11492 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11493 if (err < 0)
11494 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011495
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011496 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11497 alc262_check_volbit(cfg->speaker_pins[0]) |
11498 alc262_check_volbit(cfg->hp_pins[0]);
11499 if (vbits == 1 || vbits == 2)
11500 pfx = "Master"; /* only one mixer is used */
11501 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11502 pfx = "Speaker";
11503 else
11504 pfx = "Front";
11505 vbits = 0;
11506 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11507 if (err < 0)
11508 return err;
11509 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11510 &vbits);
11511 if (err < 0)
11512 return err;
11513 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11514 &vbits);
11515 if (err < 0)
11516 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011517 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011518}
11519
Takashi Iwai05f5f472009-08-25 13:10:18 +020011520#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011521 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011522
11523/*
11524 * generic initialization of ADC, input mixers and output mixers
11525 */
11526static struct hda_verb alc262_volume_init_verbs[] = {
11527 /*
11528 * Unmute ADC0-2 and set the default input to mic-in
11529 */
11530 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11531 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11532 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11533 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11534 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11535 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11536
Takashi Iwaicb53c622007-08-10 17:21:45 +020011537 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011538 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011539 * Note: PASD motherboards uses the Line In 2 as the input for
11540 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011541 */
11542 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11544 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11547 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011548
11549 /*
11550 * Set up output mixers (0x0c - 0x0f)
11551 */
11552 /* set vol=0 to output mixers */
11553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11554 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11555 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011556
Kailang Yangdf694da2005-12-05 19:42:22 +010011557 /* set up input amps for analog loopback */
11558 /* Amp Indices: DAC = 0, mixer = 1 */
11559 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11560 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11561 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11562 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11563 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11564 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11565
11566 /* FIXME: use matrix-type input source selection */
11567 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11568 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11569 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11570 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11571 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11572 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11573 /* Input mixer2 */
11574 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11575 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11576 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11577 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11578 /* Input mixer3 */
11579 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11580 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11581 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11582 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11583
11584 { }
11585};
11586
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011587static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11588 /*
11589 * Unmute ADC0-2 and set the default input to mic-in
11590 */
11591 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11592 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11593 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11594 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11595 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11596 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11597
Takashi Iwaicb53c622007-08-10 17:21:45 +020011598 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011599 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011600 * Note: PASD motherboards uses the Line In 2 as the input for
11601 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011602 */
11603 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011604 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11605 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11606 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11607 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11608 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11609 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11610 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011611
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011612 /*
11613 * Set up output mixers (0x0c - 0x0e)
11614 */
11615 /* set vol=0 to output mixers */
11616 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11617 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11618 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11619
11620 /* set up input amps for analog loopback */
11621 /* Amp Indices: DAC = 0, mixer = 1 */
11622 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11623 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11624 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11625 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11626 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11627 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11628
Takashi Iwaice875f02008-01-28 18:17:43 +010011629 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011630 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11631 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11632
11633 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11634 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11635
11636 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11637 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11638
11639 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11640 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11641 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11642 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11643 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11644
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011645 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011646 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11647 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011648 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011649 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11650 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11651
11652
11653 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011654 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11655 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011656 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011657 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11658 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11659 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11660 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11661 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11662 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11663 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11664 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011665 /* Input mixer2 */
11666 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011667 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11668 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11669 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11670 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11671 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11672 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11673 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11674 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011675 /* Input mixer3 */
11676 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011677 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11678 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11679 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11680 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11681 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11682 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11683 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11684 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011685
Takashi Iwaice875f02008-01-28 18:17:43 +010011686 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11687
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011688 { }
11689};
11690
Kailang Yangcd7509a2007-01-26 18:33:17 +010011691static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11692 /*
11693 * Unmute ADC0-2 and set the default input to mic-in
11694 */
11695 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11696 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11697 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11698 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11699 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11700 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11701
Takashi Iwaicb53c622007-08-10 17:21:45 +020011702 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011703 * mixer widget
11704 * Note: PASD motherboards uses the Line In 2 as the input for front
11705 * panel mic (mic 2)
11706 */
11707 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011708 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11709 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11710 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11711 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11712 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11713 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11714 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11715 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011716 /*
11717 * Set up output mixers (0x0c - 0x0e)
11718 */
11719 /* set vol=0 to output mixers */
11720 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11721 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11722 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11723
11724 /* set up input amps for analog loopback */
11725 /* Amp Indices: DAC = 0, mixer = 1 */
11726 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11727 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11728 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11729 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11730 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11731 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11732
11733
11734 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11735 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11736 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11737 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11738 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11739 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11740 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11741
11742 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11743 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11744
11745 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11746 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11747
11748 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11749 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11750 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11751 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11752 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11753 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11754
11755 /* FIXME: use matrix-type input source selection */
11756 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11757 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11758 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11759 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11760 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11761 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11762 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11763 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11764 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11765 /* Input mixer2 */
11766 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11767 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11768 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11769 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11770 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11771 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11772 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11773 /* Input mixer3 */
11774 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11775 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11776 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11778 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11779 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11780 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11781
Takashi Iwaice875f02008-01-28 18:17:43 +010011782 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11783
Kailang Yangcd7509a2007-01-26 18:33:17 +010011784 { }
11785};
11786
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011787static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11788
11789 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11790 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11791 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11792
11793 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11794 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11795 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11796 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11797
11798 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11799 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11800 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11801 {}
11802};
11803
11804
Takashi Iwaicb53c622007-08-10 17:21:45 +020011805#ifdef CONFIG_SND_HDA_POWER_SAVE
11806#define alc262_loopbacks alc880_loopbacks
11807#endif
11808
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011809/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011810#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11811#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11812#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11813#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11814
11815/*
11816 * BIOS auto configuration
11817 */
11818static int alc262_parse_auto_config(struct hda_codec *codec)
11819{
11820 struct alc_spec *spec = codec->spec;
11821 int err;
11822 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11823
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011824 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11825 alc262_ignore);
11826 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011827 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011828 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011829 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011830 spec->multiout.max_channels = 2;
11831 spec->no_analog = 1;
11832 goto dig_only;
11833 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011834 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011835 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011836 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11837 if (err < 0)
11838 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011839 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011840 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011841 return err;
11842
11843 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11844
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011845 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011846 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011847 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011848 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011849 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011850 if (spec->autocfg.dig_in_pin)
11851 spec->dig_in_nid = ALC262_DIGIN_NID;
11852
Takashi Iwai603c4012008-07-30 15:01:44 +020011853 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011854 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011855
Takashi Iwaid88897e2008-10-31 15:01:37 +010011856 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011857 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011858 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011859
Takashi Iwai776e1842007-08-29 15:07:11 +020011860 err = alc_auto_add_mic_boost(codec);
11861 if (err < 0)
11862 return err;
11863
Kailang Yang6227cdc2010-02-25 08:36:52 +010011864 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011865
Kailang Yangdf694da2005-12-05 19:42:22 +010011866 return 1;
11867}
11868
11869#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11870#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11871#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011872#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011873
11874
11875/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011876static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011877{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011878 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011879 alc262_auto_init_multi_out(codec);
11880 alc262_auto_init_hp_out(codec);
11881 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011882 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011883 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011884 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011885}
11886
11887/*
11888 * configuration and preset
11889 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011890static const char *alc262_models[ALC262_MODEL_LAST] = {
11891 [ALC262_BASIC] = "basic",
11892 [ALC262_HIPPO] = "hippo",
11893 [ALC262_HIPPO_1] = "hippo_1",
11894 [ALC262_FUJITSU] = "fujitsu",
11895 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011896 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011897 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011898 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011899 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011900 [ALC262_BENQ_T31] = "benq-t31",
11901 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011902 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011903 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011904 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011905 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011906 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011907 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011908 [ALC262_AUTO] = "auto",
11909};
11910
11911static struct snd_pci_quirk alc262_cfg_tbl[] = {
11912 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011913 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011914 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11915 ALC262_HP_BPC),
11916 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11917 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011918 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11919 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011920 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011921 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011922 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011923 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011924 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011925 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011926 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011927 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011928 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11929 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11930 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011931 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11932 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011933 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011934 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011935 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011936 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011937 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011938 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050011939 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010011940 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011941#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010011942 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11943 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011944#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090011945 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011946 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011947 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011948 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011949 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011950 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011951 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11952 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011953 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011954 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011955 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011956 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011957 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011958 {}
11959};
11960
11961static struct alc_config_preset alc262_presets[] = {
11962 [ALC262_BASIC] = {
11963 .mixers = { alc262_base_mixer },
11964 .init_verbs = { alc262_init_verbs },
11965 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11966 .dac_nids = alc262_dac_nids,
11967 .hp_nid = 0x03,
11968 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11969 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011970 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011971 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011972 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011973 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011974 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011975 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11976 .dac_nids = alc262_dac_nids,
11977 .hp_nid = 0x03,
11978 .dig_out_nid = ALC262_DIGOUT_NID,
11979 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11980 .channel_mode = alc262_modes,
11981 .input_mux = &alc262_capture_source,
11982 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011983 .setup = alc262_hippo_setup,
11984 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011985 },
11986 [ALC262_HIPPO_1] = {
11987 .mixers = { alc262_hippo1_mixer },
11988 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11989 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11990 .dac_nids = alc262_dac_nids,
11991 .hp_nid = 0x02,
11992 .dig_out_nid = ALC262_DIGOUT_NID,
11993 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11994 .channel_mode = alc262_modes,
11995 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011996 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011997 .setup = alc262_hippo1_setup,
11998 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011999 },
Takashi Iwai834be882006-03-01 14:16:17 +010012000 [ALC262_FUJITSU] = {
12001 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012002 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12003 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012004 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12005 .dac_nids = alc262_dac_nids,
12006 .hp_nid = 0x03,
12007 .dig_out_nid = ALC262_DIGOUT_NID,
12008 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12009 .channel_mode = alc262_modes,
12010 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012011 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012012 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012013 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012014 [ALC262_HP_BPC] = {
12015 .mixers = { alc262_HP_BPC_mixer },
12016 .init_verbs = { alc262_HP_BPC_init_verbs },
12017 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12018 .dac_nids = alc262_dac_nids,
12019 .hp_nid = 0x03,
12020 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12021 .channel_mode = alc262_modes,
12022 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012023 .unsol_event = alc262_hp_bpc_unsol_event,
12024 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012025 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012026 [ALC262_HP_BPC_D7000_WF] = {
12027 .mixers = { alc262_HP_BPC_WildWest_mixer },
12028 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12029 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12030 .dac_nids = alc262_dac_nids,
12031 .hp_nid = 0x03,
12032 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12033 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012034 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012035 .unsol_event = alc262_hp_wildwest_unsol_event,
12036 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012037 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012038 [ALC262_HP_BPC_D7000_WL] = {
12039 .mixers = { alc262_HP_BPC_WildWest_mixer,
12040 alc262_HP_BPC_WildWest_option_mixer },
12041 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12042 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12043 .dac_nids = alc262_dac_nids,
12044 .hp_nid = 0x03,
12045 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12046 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012047 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012048 .unsol_event = alc262_hp_wildwest_unsol_event,
12049 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012050 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012051 [ALC262_HP_TC_T5735] = {
12052 .mixers = { alc262_hp_t5735_mixer },
12053 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12054 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12055 .dac_nids = alc262_dac_nids,
12056 .hp_nid = 0x03,
12057 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12058 .channel_mode = alc262_modes,
12059 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012060 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012061 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012062 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012063 },
12064 [ALC262_HP_RP5700] = {
12065 .mixers = { alc262_hp_rp5700_mixer },
12066 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12067 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12068 .dac_nids = alc262_dac_nids,
12069 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12070 .channel_mode = alc262_modes,
12071 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012072 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012073 [ALC262_BENQ_ED8] = {
12074 .mixers = { alc262_base_mixer },
12075 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12076 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12077 .dac_nids = alc262_dac_nids,
12078 .hp_nid = 0x03,
12079 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12080 .channel_mode = alc262_modes,
12081 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012082 },
Kailang Yang272a5272007-05-14 11:00:38 +020012083 [ALC262_SONY_ASSAMD] = {
12084 .mixers = { alc262_sony_mixer },
12085 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12086 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12087 .dac_nids = alc262_dac_nids,
12088 .hp_nid = 0x02,
12089 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12090 .channel_mode = alc262_modes,
12091 .input_mux = &alc262_capture_source,
12092 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012093 .setup = alc262_hippo_setup,
12094 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012095 },
12096 [ALC262_BENQ_T31] = {
12097 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012098 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12099 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012100 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12101 .dac_nids = alc262_dac_nids,
12102 .hp_nid = 0x03,
12103 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12104 .channel_mode = alc262_modes,
12105 .input_mux = &alc262_capture_source,
12106 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012107 .setup = alc262_hippo_setup,
12108 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012109 },
Tobin Davisf651b502007-10-26 12:40:47 +020012110 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012111 .mixers = { alc262_ultra_mixer },
12112 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012113 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012114 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12115 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012116 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12117 .channel_mode = alc262_modes,
12118 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012119 .adc_nids = alc262_adc_nids, /* ADC0 */
12120 .capsrc_nids = alc262_capsrc_nids,
12121 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012122 .unsol_event = alc262_ultra_unsol_event,
12123 .init_hook = alc262_ultra_automute,
12124 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012125 [ALC262_LENOVO_3000] = {
12126 .mixers = { alc262_lenovo_3000_mixer },
12127 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012128 alc262_lenovo_3000_unsol_verbs,
12129 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012130 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12131 .dac_nids = alc262_dac_nids,
12132 .hp_nid = 0x03,
12133 .dig_out_nid = ALC262_DIGOUT_NID,
12134 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12135 .channel_mode = alc262_modes,
12136 .input_mux = &alc262_fujitsu_capture_source,
12137 .unsol_event = alc262_lenovo_3000_unsol_event,
12138 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012139 [ALC262_NEC] = {
12140 .mixers = { alc262_nec_mixer },
12141 .init_verbs = { alc262_nec_verbs },
12142 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12143 .dac_nids = alc262_dac_nids,
12144 .hp_nid = 0x03,
12145 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12146 .channel_mode = alc262_modes,
12147 .input_mux = &alc262_capture_source,
12148 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012149 [ALC262_TOSHIBA_S06] = {
12150 .mixers = { alc262_toshiba_s06_mixer },
12151 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12152 alc262_eapd_verbs },
12153 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12154 .capsrc_nids = alc262_dmic_capsrc_nids,
12155 .dac_nids = alc262_dac_nids,
12156 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012157 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012158 .dig_out_nid = ALC262_DIGOUT_NID,
12159 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12160 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012161 .unsol_event = alc_sku_unsol_event,
12162 .setup = alc262_toshiba_s06_setup,
12163 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012164 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012165 [ALC262_TOSHIBA_RX1] = {
12166 .mixers = { alc262_toshiba_rx1_mixer },
12167 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12168 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12169 .dac_nids = alc262_dac_nids,
12170 .hp_nid = 0x03,
12171 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12172 .channel_mode = alc262_modes,
12173 .input_mux = &alc262_capture_source,
12174 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012175 .setup = alc262_hippo_setup,
12176 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012177 },
Tony Vroonba340e82009-02-02 19:01:30 +000012178 [ALC262_TYAN] = {
12179 .mixers = { alc262_tyan_mixer },
12180 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12181 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12182 .dac_nids = alc262_dac_nids,
12183 .hp_nid = 0x02,
12184 .dig_out_nid = ALC262_DIGOUT_NID,
12185 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12186 .channel_mode = alc262_modes,
12187 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012188 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012189 .setup = alc262_tyan_setup,
12190 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012191 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012192};
12193
12194static int patch_alc262(struct hda_codec *codec)
12195{
12196 struct alc_spec *spec;
12197 int board_config;
12198 int err;
12199
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012200 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012201 if (spec == NULL)
12202 return -ENOMEM;
12203
12204 codec->spec = spec;
12205#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012206 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12207 * under-run
12208 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012209 {
12210 int tmp;
12211 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12212 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12213 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12214 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12215 }
12216#endif
12217
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012218 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12219
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012220 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12221 alc262_models,
12222 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012223
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012224 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012225 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12226 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012227 board_config = ALC262_AUTO;
12228 }
12229
12230 if (board_config == ALC262_AUTO) {
12231 /* automatic parse from the BIOS config */
12232 err = alc262_parse_auto_config(codec);
12233 if (err < 0) {
12234 alc_free(codec);
12235 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012236 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012237 printk(KERN_INFO
12238 "hda_codec: Cannot set up configuration "
12239 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012240 board_config = ALC262_BASIC;
12241 }
12242 }
12243
Takashi Iwai07eba612009-02-19 08:06:35 +010012244 if (!spec->no_analog) {
12245 err = snd_hda_attach_beep_device(codec, 0x1);
12246 if (err < 0) {
12247 alc_free(codec);
12248 return err;
12249 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012250 }
12251
Kailang Yangdf694da2005-12-05 19:42:22 +010012252 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012253 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012254
Kailang Yangdf694da2005-12-05 19:42:22 +010012255 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12256 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012257
Kailang Yangdf694da2005-12-05 19:42:22 +010012258 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12259 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12260
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012261 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012262 int i;
12263 /* check whether the digital-mic has to be supported */
12264 for (i = 0; i < spec->input_mux->num_items; i++) {
12265 if (spec->input_mux->items[i].index >= 9)
12266 break;
12267 }
12268 if (i < spec->input_mux->num_items) {
12269 /* use only ADC0 */
12270 spec->adc_nids = alc262_dmic_adc_nids;
12271 spec->num_adc_nids = 1;
12272 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012273 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012274 /* all analog inputs */
12275 /* check whether NID 0x07 is valid */
12276 unsigned int wcap = get_wcaps(codec, 0x07);
12277
12278 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012279 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012280 if (wcap != AC_WID_AUD_IN) {
12281 spec->adc_nids = alc262_adc_nids_alt;
12282 spec->num_adc_nids =
12283 ARRAY_SIZE(alc262_adc_nids_alt);
12284 spec->capsrc_nids = alc262_capsrc_nids_alt;
12285 } else {
12286 spec->adc_nids = alc262_adc_nids;
12287 spec->num_adc_nids =
12288 ARRAY_SIZE(alc262_adc_nids);
12289 spec->capsrc_nids = alc262_capsrc_nids;
12290 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012291 }
12292 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012293 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012294 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010012295 if (!spec->no_analog)
12296 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012297
Takashi Iwai2134ea42008-01-10 16:53:55 +010012298 spec->vmaster_nid = 0x0c;
12299
Kailang Yangdf694da2005-12-05 19:42:22 +010012300 codec->patch_ops = alc_patch_ops;
12301 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012302 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012303#ifdef CONFIG_SND_HDA_POWER_SAVE
12304 if (!spec->loopback.amplist)
12305 spec->loopback.amplist = alc262_loopbacks;
12306#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012307
Kailang Yangdf694da2005-12-05 19:42:22 +010012308 return 0;
12309}
12310
Kailang Yangdf694da2005-12-05 19:42:22 +010012311/*
Kailang Yanga361d842007-06-05 12:30:55 +020012312 * ALC268 channel source setting (2 channel)
12313 */
12314#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12315#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012316
Kailang Yanga361d842007-06-05 12:30:55 +020012317static hda_nid_t alc268_dac_nids[2] = {
12318 /* front, hp */
12319 0x02, 0x03
12320};
12321
12322static hda_nid_t alc268_adc_nids[2] = {
12323 /* ADC0-1 */
12324 0x08, 0x07
12325};
12326
12327static hda_nid_t alc268_adc_nids_alt[1] = {
12328 /* ADC0 */
12329 0x08
12330};
12331
Takashi Iwaie1406342008-02-11 18:32:32 +010012332static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12333
Kailang Yanga361d842007-06-05 12:30:55 +020012334static struct snd_kcontrol_new alc268_base_mixer[] = {
12335 /* output mixer control */
12336 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12337 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12338 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12339 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012340 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12341 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12342 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012343 { }
12344};
12345
Takashi Iwai42171c12009-05-08 14:11:43 +020012346static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12347 /* output mixer control */
12348 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12349 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12350 ALC262_HIPPO_MASTER_SWITCH,
12351 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12352 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12353 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12354 { }
12355};
12356
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012357/* bind Beep switches of both NID 0x0f and 0x10 */
12358static struct hda_bind_ctls alc268_bind_beep_sw = {
12359 .ops = &snd_hda_bind_sw,
12360 .values = {
12361 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12362 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12363 0
12364 },
12365};
12366
12367static struct snd_kcontrol_new alc268_beep_mixer[] = {
12368 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12369 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12370 { }
12371};
12372
Kailang Yangd1a991a2007-08-15 16:21:59 +020012373static struct hda_verb alc268_eapd_verbs[] = {
12374 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12375 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12376 { }
12377};
12378
Takashi Iwaid2738092007-08-16 14:59:45 +020012379/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012380static struct hda_verb alc268_toshiba_verbs[] = {
12381 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12382 { } /* end */
12383};
12384
12385/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012386/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012387static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12388 .ops = &snd_hda_bind_vol,
12389 .values = {
12390 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12391 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12392 0
12393 },
12394};
12395
Takashi Iwai889c4392007-08-23 18:56:52 +020012396/* mute/unmute internal speaker according to the hp jack and mute state */
12397static void alc268_acer_automute(struct hda_codec *codec, int force)
12398{
12399 struct alc_spec *spec = codec->spec;
12400 unsigned int mute;
12401
12402 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012403 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012404 spec->sense_updated = 1;
12405 }
12406 if (spec->jack_present)
12407 mute = HDA_AMP_MUTE; /* mute internal speaker */
12408 else /* unmute internal speaker if necessary */
12409 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12410 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12411 HDA_AMP_MUTE, mute);
12412}
12413
12414
12415/* bind hp and internal speaker mute (with plug check) */
12416static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12417 struct snd_ctl_elem_value *ucontrol)
12418{
12419 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12420 long *valp = ucontrol->value.integer.value;
12421 int change;
12422
Takashi Iwai8de56b72009-07-24 16:51:47 +020012423 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012424 if (change)
12425 alc268_acer_automute(codec, 0);
12426 return change;
12427}
Takashi Iwaid2738092007-08-16 14:59:45 +020012428
Kailang Yang8ef355d2008-08-26 13:10:22 +020012429static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12430 /* output mixer control */
12431 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12432 {
12433 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12434 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012435 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012436 .info = snd_hda_mixer_amp_switch_info,
12437 .get = snd_hda_mixer_amp_switch_get,
12438 .put = alc268_acer_master_sw_put,
12439 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12440 },
12441 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12442 { }
12443};
12444
Takashi Iwaid2738092007-08-16 14:59:45 +020012445static struct snd_kcontrol_new alc268_acer_mixer[] = {
12446 /* output mixer control */
12447 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12448 {
12449 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12450 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012451 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012452 .info = snd_hda_mixer_amp_switch_info,
12453 .get = snd_hda_mixer_amp_switch_get,
12454 .put = alc268_acer_master_sw_put,
12455 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12456 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012457 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12458 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12459 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012460 { }
12461};
12462
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012463static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12464 /* output mixer control */
12465 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12466 {
12467 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12468 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012469 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012470 .info = snd_hda_mixer_amp_switch_info,
12471 .get = snd_hda_mixer_amp_switch_get,
12472 .put = alc268_acer_master_sw_put,
12473 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12474 },
12475 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12476 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12477 { }
12478};
12479
Kailang Yang8ef355d2008-08-26 13:10:22 +020012480static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12481 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12482 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12483 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12484 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12485 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12486 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12487 { }
12488};
12489
Takashi Iwaid2738092007-08-16 14:59:45 +020012490static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012491 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12492 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012493 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12494 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012495 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12496 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012497 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12498 { }
12499};
12500
12501/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012502#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012503#define alc268_toshiba_setup alc262_hippo_setup
12504#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012505
12506static void alc268_acer_unsol_event(struct hda_codec *codec,
12507 unsigned int res)
12508{
Takashi Iwai889c4392007-08-23 18:56:52 +020012509 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012510 return;
12511 alc268_acer_automute(codec, 1);
12512}
12513
Takashi Iwai889c4392007-08-23 18:56:52 +020012514static void alc268_acer_init_hook(struct hda_codec *codec)
12515{
12516 alc268_acer_automute(codec, 1);
12517}
12518
Kailang Yang8ef355d2008-08-26 13:10:22 +020012519/* toggle speaker-output according to the hp-jack state */
12520static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12521{
12522 unsigned int present;
12523 unsigned char bits;
12524
Wu Fengguang864f92b2009-11-18 12:38:02 +080012525 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012526 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012527 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012528 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012529 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012530 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012531}
12532
Kailang Yang8ef355d2008-08-26 13:10:22 +020012533static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12534 unsigned int res)
12535{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012536 switch (res >> 26) {
12537 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012538 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012539 break;
12540 case ALC880_MIC_EVENT:
12541 alc_mic_automute(codec);
12542 break;
12543 }
12544}
12545
12546static void alc268_acer_lc_setup(struct hda_codec *codec)
12547{
12548 struct alc_spec *spec = codec->spec;
12549 spec->ext_mic.pin = 0x18;
12550 spec->ext_mic.mux_idx = 0;
12551 spec->int_mic.pin = 0x12;
12552 spec->int_mic.mux_idx = 6;
12553 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012554}
12555
12556static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12557{
12558 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012559 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012560}
12561
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012562static struct snd_kcontrol_new alc268_dell_mixer[] = {
12563 /* output mixer control */
12564 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12565 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12566 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12567 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12568 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12569 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12570 { }
12571};
12572
12573static struct hda_verb alc268_dell_verbs[] = {
12574 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12575 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12576 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012577 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012578 { }
12579};
12580
12581/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012582static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012583{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012584 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012585
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012586 spec->autocfg.hp_pins[0] = 0x15;
12587 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012588 spec->ext_mic.pin = 0x18;
12589 spec->ext_mic.mux_idx = 0;
12590 spec->int_mic.pin = 0x19;
12591 spec->int_mic.mux_idx = 1;
12592 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012593}
12594
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012595static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12596 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12597 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12598 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12599 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12600 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12601 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12602 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12603 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12604 { }
12605};
12606
12607static struct hda_verb alc267_quanta_il1_verbs[] = {
12608 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12609 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12610 { }
12611};
12612
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012613static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012614{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012615 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012616 spec->autocfg.hp_pins[0] = 0x15;
12617 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012618 spec->ext_mic.pin = 0x18;
12619 spec->ext_mic.mux_idx = 0;
12620 spec->int_mic.pin = 0x19;
12621 spec->int_mic.mux_idx = 1;
12622 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012623}
12624
Kailang Yanga361d842007-06-05 12:30:55 +020012625/*
12626 * generic initialization of ADC, input mixers and output mixers
12627 */
12628static struct hda_verb alc268_base_init_verbs[] = {
12629 /* Unmute DAC0-1 and set vol = 0 */
12630 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012631 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012632
12633 /*
12634 * Set up output mixers (0x0c - 0x0e)
12635 */
12636 /* set vol=0 to output mixers */
12637 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012638 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12639
12640 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12641 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12642
12643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12644 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12645 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12646 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12647 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12648 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12649 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12650 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12651
12652 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12653 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12654 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12655 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012656 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012657
12658 /* set PCBEEP vol = 0, mute connections */
12659 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12660 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12661 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012662
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012663 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012664
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012665 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12666 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12667 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12668 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012669
Kailang Yanga361d842007-06-05 12:30:55 +020012670 { }
12671};
12672
12673/*
12674 * generic initialization of ADC, input mixers and output mixers
12675 */
12676static struct hda_verb alc268_volume_init_verbs[] = {
12677 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012678 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12679 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012680
12681 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12682 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12683 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12684 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12685 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12686
Kailang Yanga361d842007-06-05 12:30:55 +020012687 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012688 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12689 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12690
12691 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012692 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012693
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012694 /* set PCBEEP vol = 0, mute connections */
12695 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12696 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12697 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012698
12699 { }
12700};
12701
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012702static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12703 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12704 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12705 { } /* end */
12706};
12707
Kailang Yanga361d842007-06-05 12:30:55 +020012708static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12709 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12710 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012711 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012712 { } /* end */
12713};
12714
12715static struct snd_kcontrol_new alc268_capture_mixer[] = {
12716 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12717 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12718 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12719 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012720 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012721 { } /* end */
12722};
12723
12724static struct hda_input_mux alc268_capture_source = {
12725 .num_items = 4,
12726 .items = {
12727 { "Mic", 0x0 },
12728 { "Front Mic", 0x1 },
12729 { "Line", 0x2 },
12730 { "CD", 0x3 },
12731 },
12732};
12733
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012734static struct hda_input_mux alc268_acer_capture_source = {
12735 .num_items = 3,
12736 .items = {
12737 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012738 { "Internal Mic", 0x1 },
12739 { "Line", 0x2 },
12740 },
12741};
12742
12743static struct hda_input_mux alc268_acer_dmic_capture_source = {
12744 .num_items = 3,
12745 .items = {
12746 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012747 { "Internal Mic", 0x6 },
12748 { "Line", 0x2 },
12749 },
12750};
12751
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012752#ifdef CONFIG_SND_DEBUG
12753static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012754 /* Volume widgets */
12755 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12756 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12757 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12758 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12759 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12760 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12761 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12762 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12763 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12764 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12765 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12766 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12767 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012768 /* The below appears problematic on some hardwares */
12769 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012770 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12771 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12772 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12773 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12774
12775 /* Modes for retasking pin widgets */
12776 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12777 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12778 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12779 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12780
12781 /* Controls for GPIO pins, assuming they are configured as outputs */
12782 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12783 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12784 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12785 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12786
12787 /* Switches to allow the digital SPDIF output pin to be enabled.
12788 * The ALC268 does not have an SPDIF input.
12789 */
12790 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12791
12792 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12793 * this output to turn on an external amplifier.
12794 */
12795 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12796 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12797
12798 { } /* end */
12799};
12800#endif
12801
Kailang Yanga361d842007-06-05 12:30:55 +020012802/* create input playback/capture controls for the given pin */
12803static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12804 const char *ctlname, int idx)
12805{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012806 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012807 int err;
12808
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012809 switch (nid) {
12810 case 0x14:
12811 case 0x16:
12812 dac = 0x02;
12813 break;
12814 case 0x15:
12815 dac = 0x03;
12816 break;
12817 default:
12818 return 0;
12819 }
12820 if (spec->multiout.dac_nids[0] != dac &&
12821 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012822 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012823 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012824 HDA_OUTPUT));
12825 if (err < 0)
12826 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012827 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12828 }
12829
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012830 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012831 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020012832 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012833 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012834 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012835 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012836 if (err < 0)
12837 return err;
12838 return 0;
12839}
12840
12841/* add playback controls from the parsed DAC table */
12842static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12843 const struct auto_pin_cfg *cfg)
12844{
12845 hda_nid_t nid;
12846 int err;
12847
Kailang Yanga361d842007-06-05 12:30:55 +020012848 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012849
12850 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012851 if (nid) {
12852 const char *name;
12853 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12854 name = "Speaker";
12855 else
12856 name = "Front";
12857 err = alc268_new_analog_output(spec, nid, name, 0);
12858 if (err < 0)
12859 return err;
12860 }
Kailang Yanga361d842007-06-05 12:30:55 +020012861
12862 nid = cfg->speaker_pins[0];
12863 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012864 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020012865 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12866 if (err < 0)
12867 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012868 } else {
12869 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12870 if (err < 0)
12871 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012872 }
12873 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012874 if (nid) {
12875 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12876 if (err < 0)
12877 return err;
12878 }
Kailang Yanga361d842007-06-05 12:30:55 +020012879
12880 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12881 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012882 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012883 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012884 if (err < 0)
12885 return err;
12886 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012887 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012888}
12889
12890/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012891static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012892 const struct auto_pin_cfg *cfg)
12893{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012894 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012895}
12896
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012897static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12898 hda_nid_t nid, int pin_type)
12899{
12900 int idx;
12901
12902 alc_set_pin_output(codec, nid, pin_type);
12903 if (nid == 0x14 || nid == 0x16)
12904 idx = 0;
12905 else
12906 idx = 1;
12907 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12908}
12909
12910static void alc268_auto_init_multi_out(struct hda_codec *codec)
12911{
12912 struct alc_spec *spec = codec->spec;
12913 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12914 if (nid) {
12915 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12916 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12917 }
12918}
12919
12920static void alc268_auto_init_hp_out(struct hda_codec *codec)
12921{
12922 struct alc_spec *spec = codec->spec;
12923 hda_nid_t pin;
12924
12925 pin = spec->autocfg.hp_pins[0];
12926 if (pin)
12927 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12928 pin = spec->autocfg.speaker_pins[0];
12929 if (pin)
12930 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12931}
12932
Kailang Yanga361d842007-06-05 12:30:55 +020012933static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12934{
12935 struct alc_spec *spec = codec->spec;
12936 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12937 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12938 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12939 unsigned int dac_vol1, dac_vol2;
12940
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012941 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012942 snd_hda_codec_write(codec, speaker_nid, 0,
12943 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012944 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012945 snd_hda_codec_write(codec, 0x0f, 0,
12946 AC_VERB_SET_AMP_GAIN_MUTE,
12947 AMP_IN_UNMUTE(1));
12948 snd_hda_codec_write(codec, 0x10, 0,
12949 AC_VERB_SET_AMP_GAIN_MUTE,
12950 AMP_IN_UNMUTE(1));
12951 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012952 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012953 snd_hda_codec_write(codec, 0x0f, 0,
12954 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12955 snd_hda_codec_write(codec, 0x10, 0,
12956 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12957 }
12958
12959 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012960 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012961 dac_vol2 = AMP_OUT_ZERO;
12962 else if (line_nid == 0x15)
12963 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012964 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012965 dac_vol2 = AMP_OUT_ZERO;
12966 else if (hp_nid == 0x15)
12967 dac_vol1 = AMP_OUT_ZERO;
12968 if (line_nid != 0x16 || hp_nid != 0x16 ||
12969 spec->autocfg.line_out_pins[1] != 0x16 ||
12970 spec->autocfg.line_out_pins[2] != 0x16)
12971 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12972
12973 snd_hda_codec_write(codec, 0x02, 0,
12974 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12975 snd_hda_codec_write(codec, 0x03, 0,
12976 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12977}
12978
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012979/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012980#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12981#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012982#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012983#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12984
12985/*
12986 * BIOS auto configuration
12987 */
12988static int alc268_parse_auto_config(struct hda_codec *codec)
12989{
12990 struct alc_spec *spec = codec->spec;
12991 int err;
12992 static hda_nid_t alc268_ignore[] = { 0 };
12993
12994 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12995 alc268_ignore);
12996 if (err < 0)
12997 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012998 if (!spec->autocfg.line_outs) {
12999 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13000 spec->multiout.max_channels = 2;
13001 spec->no_analog = 1;
13002 goto dig_only;
13003 }
Kailang Yanga361d842007-06-05 12:30:55 +020013004 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013005 }
Kailang Yanga361d842007-06-05 12:30:55 +020013006 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13007 if (err < 0)
13008 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013009 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013010 if (err < 0)
13011 return err;
13012
13013 spec->multiout.max_channels = 2;
13014
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013015 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013016 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013017 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020013018 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013019 spec->dig_out_type = spec->autocfg.dig_out_type[0];
13020 }
Takashi Iwai603c4012008-07-30 15:01:44 +020013021 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013022 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013023
Takashi Iwai892981f2009-03-02 08:04:35 +010013024 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013025 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013026
Takashi Iwaid88897e2008-10-31 15:01:37 +010013027 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013028 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013029 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013030
Takashi Iwai776e1842007-08-29 15:07:11 +020013031 err = alc_auto_add_mic_boost(codec);
13032 if (err < 0)
13033 return err;
13034
Kailang Yang6227cdc2010-02-25 08:36:52 +010013035 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013036
Kailang Yanga361d842007-06-05 12:30:55 +020013037 return 1;
13038}
13039
Kailang Yanga361d842007-06-05 12:30:55 +020013040#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13041
13042/* init callback for auto-configuration model -- overriding the default init */
13043static void alc268_auto_init(struct hda_codec *codec)
13044{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013045 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013046 alc268_auto_init_multi_out(codec);
13047 alc268_auto_init_hp_out(codec);
13048 alc268_auto_init_mono_speaker_out(codec);
13049 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013050 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013051 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013052}
13053
13054/*
13055 * configuration and preset
13056 */
13057static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013058 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013059 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013060 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013061 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013062 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013063 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013064 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013065 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013066#ifdef CONFIG_SND_DEBUG
13067 [ALC268_TEST] = "test",
13068#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013069 [ALC268_AUTO] = "auto",
13070};
13071
13072static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013073 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013074 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013075 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013076 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013077 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013078 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13079 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013080 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013081 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13082 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013083 /* almost compatible with toshiba but with optional digital outs;
13084 * auto-probing seems working fine
13085 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013086 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013087 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013088 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013089 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013090 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013091 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013092 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013093 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020013094 {}
13095};
13096
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013097/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13098static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13099 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13100 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13101 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13102 ALC268_TOSHIBA),
13103 {}
13104};
13105
Kailang Yanga361d842007-06-05 12:30:55 +020013106static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013107 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013108 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13109 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013110 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13111 alc267_quanta_il1_verbs },
13112 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13113 .dac_nids = alc268_dac_nids,
13114 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13115 .adc_nids = alc268_adc_nids_alt,
13116 .hp_nid = 0x03,
13117 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13118 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013119 .unsol_event = alc_sku_unsol_event,
13120 .setup = alc267_quanta_il1_setup,
13121 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013122 },
Kailang Yanga361d842007-06-05 12:30:55 +020013123 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013124 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13125 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013126 .init_verbs = { alc268_base_init_verbs },
13127 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13128 .dac_nids = alc268_dac_nids,
13129 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13130 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013131 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013132 .hp_nid = 0x03,
13133 .dig_out_nid = ALC268_DIGOUT_NID,
13134 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13135 .channel_mode = alc268_modes,
13136 .input_mux = &alc268_capture_source,
13137 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013138 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013139 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013140 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013141 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13142 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013143 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13144 .dac_nids = alc268_dac_nids,
13145 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13146 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013147 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013148 .hp_nid = 0x03,
13149 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13150 .channel_mode = alc268_modes,
13151 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013152 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013153 .setup = alc268_toshiba_setup,
13154 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013155 },
13156 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013157 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013158 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013159 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13160 alc268_acer_verbs },
13161 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13162 .dac_nids = alc268_dac_nids,
13163 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13164 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013165 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013166 .hp_nid = 0x02,
13167 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13168 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013169 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013170 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013171 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013172 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013173 [ALC268_ACER_DMIC] = {
13174 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13175 alc268_beep_mixer },
13176 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13177 alc268_acer_verbs },
13178 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13179 .dac_nids = alc268_dac_nids,
13180 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13181 .adc_nids = alc268_adc_nids_alt,
13182 .capsrc_nids = alc268_capsrc_nids,
13183 .hp_nid = 0x02,
13184 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13185 .channel_mode = alc268_modes,
13186 .input_mux = &alc268_acer_dmic_capture_source,
13187 .unsol_event = alc268_acer_unsol_event,
13188 .init_hook = alc268_acer_init_hook,
13189 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013190 [ALC268_ACER_ASPIRE_ONE] = {
13191 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013192 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013193 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013194 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13195 alc268_acer_aspire_one_verbs },
13196 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13197 .dac_nids = alc268_dac_nids,
13198 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13199 .adc_nids = alc268_adc_nids_alt,
13200 .capsrc_nids = alc268_capsrc_nids,
13201 .hp_nid = 0x03,
13202 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13203 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013204 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013205 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013206 .init_hook = alc268_acer_lc_init_hook,
13207 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013208 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013209 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13210 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013211 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13212 alc268_dell_verbs },
13213 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13214 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013215 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13216 .adc_nids = alc268_adc_nids_alt,
13217 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013218 .hp_nid = 0x02,
13219 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13220 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013221 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013222 .setup = alc268_dell_setup,
13223 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013224 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013225 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013226 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13227 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013228 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13229 alc268_toshiba_verbs },
13230 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13231 .dac_nids = alc268_dac_nids,
13232 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13233 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013234 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013235 .hp_nid = 0x03,
13236 .dig_out_nid = ALC268_DIGOUT_NID,
13237 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13238 .channel_mode = alc268_modes,
13239 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013240 .setup = alc268_toshiba_setup,
13241 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013242 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013243#ifdef CONFIG_SND_DEBUG
13244 [ALC268_TEST] = {
13245 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13246 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13247 alc268_volume_init_verbs },
13248 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13249 .dac_nids = alc268_dac_nids,
13250 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13251 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013252 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013253 .hp_nid = 0x03,
13254 .dig_out_nid = ALC268_DIGOUT_NID,
13255 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13256 .channel_mode = alc268_modes,
13257 .input_mux = &alc268_capture_source,
13258 },
13259#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013260};
13261
13262static int patch_alc268(struct hda_codec *codec)
13263{
13264 struct alc_spec *spec;
13265 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013266 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013267
Julia Lawallef86f582009-12-19 08:18:03 +010013268 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013269 if (spec == NULL)
13270 return -ENOMEM;
13271
13272 codec->spec = spec;
13273
13274 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13275 alc268_models,
13276 alc268_cfg_tbl);
13277
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013278 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13279 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013280 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013281
Kailang Yanga361d842007-06-05 12:30:55 +020013282 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013283 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13284 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013285 board_config = ALC268_AUTO;
13286 }
13287
13288 if (board_config == ALC268_AUTO) {
13289 /* automatic parse from the BIOS config */
13290 err = alc268_parse_auto_config(codec);
13291 if (err < 0) {
13292 alc_free(codec);
13293 return err;
13294 } else if (!err) {
13295 printk(KERN_INFO
13296 "hda_codec: Cannot set up configuration "
13297 "from BIOS. Using base mode...\n");
13298 board_config = ALC268_3ST;
13299 }
13300 }
13301
13302 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013303 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013304
Kailang Yanga361d842007-06-05 12:30:55 +020013305 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13306 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013307 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013308
Kailang Yanga361d842007-06-05 12:30:55 +020013309 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13310
Takashi Iwai22971e32009-02-10 11:56:44 +010013311 has_beep = 0;
13312 for (i = 0; i < spec->num_mixers; i++) {
13313 if (spec->mixers[i] == alc268_beep_mixer) {
13314 has_beep = 1;
13315 break;
13316 }
13317 }
13318
13319 if (has_beep) {
13320 err = snd_hda_attach_beep_device(codec, 0x1);
13321 if (err < 0) {
13322 alc_free(codec);
13323 return err;
13324 }
13325 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13326 /* override the amp caps for beep generator */
13327 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013328 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13329 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13330 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13331 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013332 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013333
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013334 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013335 /* check whether NID 0x07 is valid */
13336 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013337 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013338
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013339 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013340 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013341 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013342 if (spec->auto_mic ||
13343 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013344 spec->adc_nids = alc268_adc_nids_alt;
13345 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013346 if (spec->auto_mic)
13347 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013348 if (spec->auto_mic || spec->input_mux->num_items == 1)
13349 add_mixer(spec, alc268_capture_nosrc_mixer);
13350 else
13351 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013352 } else {
13353 spec->adc_nids = alc268_adc_nids;
13354 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013355 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013356 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013357 /* set default input source */
13358 for (i = 0; i < spec->num_adc_nids; i++)
13359 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13360 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013361 i < spec->num_mux_defs ?
13362 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013363 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013364 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013365
13366 spec->vmaster_nid = 0x02;
13367
Kailang Yanga361d842007-06-05 12:30:55 +020013368 codec->patch_ops = alc_patch_ops;
13369 if (board_config == ALC268_AUTO)
13370 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013371
Kailang Yanga361d842007-06-05 12:30:55 +020013372 return 0;
13373}
13374
13375/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013376 * ALC269 channel source setting (2 channel)
13377 */
13378#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13379
13380#define alc269_dac_nids alc260_dac_nids
13381
13382static hda_nid_t alc269_adc_nids[1] = {
13383 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013384 0x08,
13385};
13386
Takashi Iwaie01bf502008-08-21 16:25:07 +020013387static hda_nid_t alc269_capsrc_nids[1] = {
13388 0x23,
13389};
13390
Kailang Yang84898e82010-02-04 14:16:14 +010013391static hda_nid_t alc269vb_adc_nids[1] = {
13392 /* ADC1 */
13393 0x09,
13394};
13395
13396static hda_nid_t alc269vb_capsrc_nids[1] = {
13397 0x22,
13398};
13399
Takashi Iwai66946352010-03-29 17:21:45 +020013400static hda_nid_t alc269_adc_candidates[] = {
13401 0x08, 0x09, 0x07,
13402};
Takashi Iwaie01bf502008-08-21 16:25:07 +020013403
Kailang Yangf6a92242007-12-13 16:52:54 +010013404#define alc269_modes alc260_modes
13405#define alc269_capture_source alc880_lg_lw_capture_source
13406
13407static struct snd_kcontrol_new alc269_base_mixer[] = {
13408 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13409 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13410 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13411 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13412 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13413 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13414 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13415 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13416 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13417 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13418 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13419 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13420 { } /* end */
13421};
13422
Kailang Yang60db6b52008-08-26 13:13:00 +020013423static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13424 /* output mixer control */
13425 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13426 {
13427 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13428 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013429 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013430 .info = snd_hda_mixer_amp_switch_info,
13431 .get = snd_hda_mixer_amp_switch_get,
13432 .put = alc268_acer_master_sw_put,
13433 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13434 },
13435 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13436 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13437 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13438 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13439 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13440 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013441 { }
13442};
13443
Tony Vroon64154832008-11-06 15:08:49 +000013444static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13445 /* output mixer control */
13446 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13447 {
13448 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13449 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013450 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013451 .info = snd_hda_mixer_amp_switch_info,
13452 .get = snd_hda_mixer_amp_switch_get,
13453 .put = alc268_acer_master_sw_put,
13454 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13455 },
13456 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13457 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13458 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13459 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13460 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13461 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13462 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13463 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13464 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013465 { }
13466};
13467
Kailang Yang84898e82010-02-04 14:16:14 +010013468static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013469 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013470 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013471 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013472 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013473 { } /* end */
13474};
13475
Kailang Yang84898e82010-02-04 14:16:14 +010013476static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
13477 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13478 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13479 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13480 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13481 { } /* end */
13482};
13483
Kailang Yangf6a92242007-12-13 16:52:54 +010013484/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010013485static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
13486 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13487 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13488 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13489 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13490 { } /* end */
13491};
13492
13493static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020013494 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13495 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013496 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13497 { } /* end */
13498};
13499
Kailang Yang84898e82010-02-04 14:16:14 +010013500static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
13501 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13502 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13503 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13504 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13505 { } /* end */
13506};
13507
13508static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
13509 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13510 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13511 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13512 { } /* end */
13513};
13514
Takashi Iwai26f5df22008-11-03 17:39:46 +010013515/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010013516#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013517
Kailang Yang60db6b52008-08-26 13:13:00 +020013518static struct hda_verb alc269_quanta_fl1_verbs[] = {
13519 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13520 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13521 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13522 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13523 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13524 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13525 { }
13526};
13527
Tony Vroon64154832008-11-06 15:08:49 +000013528static struct hda_verb alc269_lifebook_verbs[] = {
13529 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13530 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13531 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13532 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13533 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13534 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13535 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13536 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13537 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13538 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13539 { }
13540};
13541
Kailang Yang60db6b52008-08-26 13:13:00 +020013542/* toggle speaker-output according to the hp-jack state */
13543static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13544{
13545 unsigned int present;
13546 unsigned char bits;
13547
Wu Fengguang864f92b2009-11-18 12:38:02 +080013548 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013549 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013550 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013551 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013552 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013553 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013554
13555 snd_hda_codec_write(codec, 0x20, 0,
13556 AC_VERB_SET_COEF_INDEX, 0x0c);
13557 snd_hda_codec_write(codec, 0x20, 0,
13558 AC_VERB_SET_PROC_COEF, 0x680);
13559
13560 snd_hda_codec_write(codec, 0x20, 0,
13561 AC_VERB_SET_COEF_INDEX, 0x0c);
13562 snd_hda_codec_write(codec, 0x20, 0,
13563 AC_VERB_SET_PROC_COEF, 0x480);
13564}
13565
Tony Vroon64154832008-11-06 15:08:49 +000013566/* toggle speaker-output according to the hp-jacks state */
13567static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13568{
13569 unsigned int present;
13570 unsigned char bits;
13571
13572 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013573 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013574
13575 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013576 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013577
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013578 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000013579 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013580 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013581 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013582 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013583
13584 snd_hda_codec_write(codec, 0x20, 0,
13585 AC_VERB_SET_COEF_INDEX, 0x0c);
13586 snd_hda_codec_write(codec, 0x20, 0,
13587 AC_VERB_SET_PROC_COEF, 0x680);
13588
13589 snd_hda_codec_write(codec, 0x20, 0,
13590 AC_VERB_SET_COEF_INDEX, 0x0c);
13591 snd_hda_codec_write(codec, 0x20, 0,
13592 AC_VERB_SET_PROC_COEF, 0x480);
13593}
13594
Tony Vroon64154832008-11-06 15:08:49 +000013595static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13596{
13597 unsigned int present_laptop;
13598 unsigned int present_dock;
13599
Wu Fengguang864f92b2009-11-18 12:38:02 +080013600 present_laptop = snd_hda_jack_detect(codec, 0x18);
13601 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013602
13603 /* Laptop mic port overrides dock mic port, design decision */
13604 if (present_dock)
13605 snd_hda_codec_write(codec, 0x23, 0,
13606 AC_VERB_SET_CONNECT_SEL, 0x3);
13607 if (present_laptop)
13608 snd_hda_codec_write(codec, 0x23, 0,
13609 AC_VERB_SET_CONNECT_SEL, 0x0);
13610 if (!present_dock && !present_laptop)
13611 snd_hda_codec_write(codec, 0x23, 0,
13612 AC_VERB_SET_CONNECT_SEL, 0x1);
13613}
13614
Kailang Yang60db6b52008-08-26 13:13:00 +020013615static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13616 unsigned int res)
13617{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013618 switch (res >> 26) {
13619 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013620 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013621 break;
13622 case ALC880_MIC_EVENT:
13623 alc_mic_automute(codec);
13624 break;
13625 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013626}
13627
Tony Vroon64154832008-11-06 15:08:49 +000013628static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13629 unsigned int res)
13630{
13631 if ((res >> 26) == ALC880_HP_EVENT)
13632 alc269_lifebook_speaker_automute(codec);
13633 if ((res >> 26) == ALC880_MIC_EVENT)
13634 alc269_lifebook_mic_autoswitch(codec);
13635}
13636
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013637static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13638{
13639 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013640 spec->autocfg.hp_pins[0] = 0x15;
13641 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013642 spec->ext_mic.pin = 0x18;
13643 spec->ext_mic.mux_idx = 0;
13644 spec->int_mic.pin = 0x19;
13645 spec->int_mic.mux_idx = 1;
13646 spec->auto_mic = 1;
13647}
13648
Kailang Yang60db6b52008-08-26 13:13:00 +020013649static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13650{
13651 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013652 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013653}
13654
Tony Vroon64154832008-11-06 15:08:49 +000013655static void alc269_lifebook_init_hook(struct hda_codec *codec)
13656{
13657 alc269_lifebook_speaker_automute(codec);
13658 alc269_lifebook_mic_autoswitch(codec);
13659}
13660
Kailang Yang84898e82010-02-04 14:16:14 +010013661static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013662 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13663 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13664 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13665 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13666 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13667 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13668 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13669 {}
13670};
13671
Kailang Yang84898e82010-02-04 14:16:14 +010013672static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013673 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13674 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13675 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13676 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13677 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13678 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13679 {}
13680};
13681
Kailang Yang84898e82010-02-04 14:16:14 +010013682static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
13683 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13684 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
13685 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13686 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13687 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13688 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13689 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13690 {}
13691};
13692
13693static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
13694 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13695 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
13696 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13697 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13698 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13699 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13700 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13701 {}
13702};
13703
Kailang Yang60db6b52008-08-26 13:13:00 +020013704/* toggle speaker-output according to the hp-jack state */
13705static void alc269_speaker_automute(struct hda_codec *codec)
13706{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013707 struct alc_spec *spec = codec->spec;
13708 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013709 unsigned int present;
13710 unsigned char bits;
13711
Kailang Yangebb83ee2009-12-17 12:23:00 +010013712 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013713 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013714 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013715 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013716 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013717 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013718}
13719
Kailang Yang60db6b52008-08-26 13:13:00 +020013720/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010013721static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013722 unsigned int res)
13723{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013724 switch (res >> 26) {
13725 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013726 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013727 break;
13728 case ALC880_MIC_EVENT:
13729 alc_mic_automute(codec);
13730 break;
13731 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013732}
13733
Kailang Yang84898e82010-02-04 14:16:14 +010013734static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013735{
13736 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013737 spec->autocfg.hp_pins[0] = 0x15;
13738 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013739 spec->ext_mic.pin = 0x18;
13740 spec->ext_mic.mux_idx = 0;
13741 spec->int_mic.pin = 0x12;
13742 spec->int_mic.mux_idx = 5;
13743 spec->auto_mic = 1;
13744}
13745
Kailang Yang84898e82010-02-04 14:16:14 +010013746static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
13747{
13748 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013749 spec->autocfg.hp_pins[0] = 0x15;
13750 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang84898e82010-02-04 14:16:14 +010013751 spec->ext_mic.pin = 0x18;
13752 spec->ext_mic.mux_idx = 0;
13753 spec->int_mic.pin = 0x12;
13754 spec->int_mic.mux_idx = 6;
13755 spec->auto_mic = 1;
13756}
13757
13758static void alc269_laptop_amic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013759{
13760 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013761 spec->autocfg.hp_pins[0] = 0x15;
13762 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013763 spec->ext_mic.pin = 0x18;
13764 spec->ext_mic.mux_idx = 0;
13765 spec->int_mic.pin = 0x19;
13766 spec->int_mic.mux_idx = 1;
13767 spec->auto_mic = 1;
13768}
13769
Kailang Yang84898e82010-02-04 14:16:14 +010013770static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013771{
13772 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013773 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013774}
13775
Kailang Yangf6a92242007-12-13 16:52:54 +010013776/*
13777 * generic initialization of ADC, input mixers and output mixers
13778 */
13779static struct hda_verb alc269_init_verbs[] = {
13780 /*
13781 * Unmute ADC0 and set the default input to mic-in
13782 */
Kailang Yang84898e82010-02-04 14:16:14 +010013783 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013784
13785 /*
Kailang Yang84898e82010-02-04 14:16:14 +010013786 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010013787 */
13788 /* set vol=0 to output mixers */
13789 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13790 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13791
13792 /* set up input amps for analog loopback */
13793 /* Amp Indices: DAC = 0, mixer = 1 */
13794 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13795 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13796 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13797 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13798 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13799 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13800
13801 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13802 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13803 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13804 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13805 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13806 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13807 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13808
13809 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13810 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010013811
Kailang Yang84898e82010-02-04 14:16:14 +010013812 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010013813 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13814 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010013815 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010013816
13817 /* set EAPD */
13818 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010013819 { }
13820};
13821
13822static struct hda_verb alc269vb_init_verbs[] = {
13823 /*
13824 * Unmute ADC0 and set the default input to mic-in
13825 */
13826 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13827
13828 /*
13829 * Set up output mixers (0x02 - 0x03)
13830 */
13831 /* set vol=0 to output mixers */
13832 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13833 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13834
13835 /* set up input amps for analog loopback */
13836 /* Amp Indices: DAC = 0, mixer = 1 */
13837 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13838 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13839 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13840 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13841 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13842 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13843
13844 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13845 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13846 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13847 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13848 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13849 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13850 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13851
13852 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13853 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13854
13855 /* FIXME: use Mux-type input source selection */
13856 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13857 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
13858 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
13859
13860 /* set EAPD */
13861 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010013862 { }
13863};
13864
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013865#define alc269_auto_create_multi_out_ctls \
13866 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013867#define alc269_auto_create_input_ctls \
13868 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013869
13870#ifdef CONFIG_SND_HDA_POWER_SAVE
13871#define alc269_loopbacks alc880_loopbacks
13872#endif
13873
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013874/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013875#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13876#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13877#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13878#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13879
Takashi Iwaif03d3112009-03-05 14:18:16 +010013880static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13881 .substreams = 1,
13882 .channels_min = 2,
13883 .channels_max = 8,
13884 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13885 /* NID is set in alc_build_pcms */
13886 .ops = {
13887 .open = alc880_playback_pcm_open,
13888 .prepare = alc880_playback_pcm_prepare,
13889 .cleanup = alc880_playback_pcm_cleanup
13890 },
13891};
13892
13893static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13894 .substreams = 1,
13895 .channels_min = 2,
13896 .channels_max = 2,
13897 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13898 /* NID is set in alc_build_pcms */
13899};
13900
Kailang Yangf6a92242007-12-13 16:52:54 +010013901/*
13902 * BIOS auto configuration
13903 */
13904static int alc269_parse_auto_config(struct hda_codec *codec)
13905{
13906 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013907 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013908 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13909
13910 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13911 alc269_ignore);
13912 if (err < 0)
13913 return err;
13914
13915 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13916 if (err < 0)
13917 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013918 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013919 if (err < 0)
13920 return err;
13921
13922 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13923
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013924 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013925 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13926
Takashi Iwai603c4012008-07-30 15:01:44 +020013927 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013928 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013929
Kailang Yang84898e82010-02-04 14:16:14 +010013930 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
13931 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010013932 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010013933 } else {
13934 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010013935 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010013936 }
13937
Kailang Yangf6a92242007-12-13 16:52:54 +010013938 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013939 spec->input_mux = &spec->private_imux[0];
Takashi Iwai66946352010-03-29 17:21:45 +020013940 fillup_priv_adc_nids(codec, alc269_adc_candidates,
13941 sizeof(alc269_adc_candidates));
13942
Takashi Iwaie01bf502008-08-21 16:25:07 +020013943 /* set default input source */
Takashi Iwai66946352010-03-29 17:21:45 +020013944 snd_hda_codec_write_cache(codec, spec->capsrc_nids[0],
Takashi Iwaie01bf502008-08-21 16:25:07 +020013945 0, AC_VERB_SET_CONNECT_SEL,
13946 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013947
13948 err = alc_auto_add_mic_boost(codec);
13949 if (err < 0)
13950 return err;
13951
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013952 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013953 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013954
Kailang Yangf6a92242007-12-13 16:52:54 +010013955 return 1;
13956}
13957
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013958#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13959#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013960#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13961
13962
13963/* init callback for auto-configuration model -- overriding the default init */
13964static void alc269_auto_init(struct hda_codec *codec)
13965{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013966 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013967 alc269_auto_init_multi_out(codec);
13968 alc269_auto_init_hp_out(codec);
13969 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013970 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013971 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013972}
13973
13974/*
13975 * configuration and preset
13976 */
13977static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013978 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013979 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010013980 [ALC269_AMIC] = "laptop-amic",
13981 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000013982 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020013983 [ALC269_LIFEBOOK] = "lifebook",
13984 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010013985};
13986
13987static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013988 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013989 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010013990 ALC269_AMIC),
13991 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
13992 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
13993 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
13994 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
13995 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
13996 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
13997 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
13998 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
13999 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14000 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14001 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14002 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14003 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14004 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14005 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14006 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14007 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14008 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14009 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14010 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14011 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14012 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14013 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14014 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14015 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14016 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14017 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14018 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14019 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14020 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14021 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14022 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14023 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14024 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14025 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14026 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014027 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014028 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014029 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014030 ALC269_DMIC),
14031 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14032 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014033 SND_PCI_QUIRK(0x104d, 0x9071, "SONY XTB", ALC269_DMIC),
Tony Vroon64154832008-11-06 15:08:49 +000014034 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014035 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14036 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14037 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14038 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14039 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14040 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014041 {}
14042};
14043
14044static struct alc_config_preset alc269_presets[] = {
14045 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014046 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014047 .init_verbs = { alc269_init_verbs },
14048 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14049 .dac_nids = alc269_dac_nids,
14050 .hp_nid = 0x03,
14051 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14052 .channel_mode = alc269_modes,
14053 .input_mux = &alc269_capture_source,
14054 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014055 [ALC269_QUANTA_FL1] = {
14056 .mixers = { alc269_quanta_fl1_mixer },
14057 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14058 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14059 .dac_nids = alc269_dac_nids,
14060 .hp_nid = 0x03,
14061 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14062 .channel_mode = alc269_modes,
14063 .input_mux = &alc269_capture_source,
14064 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014065 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014066 .init_hook = alc269_quanta_fl1_init_hook,
14067 },
Kailang Yang84898e82010-02-04 14:16:14 +010014068 [ALC269_AMIC] = {
14069 .mixers = { alc269_laptop_mixer },
14070 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014071 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014072 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014073 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14074 .dac_nids = alc269_dac_nids,
14075 .hp_nid = 0x03,
14076 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14077 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014078 .unsol_event = alc269_laptop_unsol_event,
14079 .setup = alc269_laptop_amic_setup,
14080 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014081 },
Kailang Yang84898e82010-02-04 14:16:14 +010014082 [ALC269_DMIC] = {
14083 .mixers = { alc269_laptop_mixer },
14084 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014085 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014086 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014087 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14088 .dac_nids = alc269_dac_nids,
14089 .hp_nid = 0x03,
14090 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14091 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014092 .unsol_event = alc269_laptop_unsol_event,
14093 .setup = alc269_laptop_dmic_setup,
14094 .init_hook = alc269_laptop_inithook,
14095 },
14096 [ALC269VB_AMIC] = {
14097 .mixers = { alc269vb_laptop_mixer },
14098 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14099 .init_verbs = { alc269vb_init_verbs,
14100 alc269vb_laptop_amic_init_verbs },
14101 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14102 .dac_nids = alc269_dac_nids,
14103 .hp_nid = 0x03,
14104 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14105 .channel_mode = alc269_modes,
14106 .unsol_event = alc269_laptop_unsol_event,
14107 .setup = alc269_laptop_amic_setup,
14108 .init_hook = alc269_laptop_inithook,
14109 },
14110 [ALC269VB_DMIC] = {
14111 .mixers = { alc269vb_laptop_mixer },
14112 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14113 .init_verbs = { alc269vb_init_verbs,
14114 alc269vb_laptop_dmic_init_verbs },
14115 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14116 .dac_nids = alc269_dac_nids,
14117 .hp_nid = 0x03,
14118 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14119 .channel_mode = alc269_modes,
14120 .unsol_event = alc269_laptop_unsol_event,
14121 .setup = alc269vb_laptop_dmic_setup,
14122 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014123 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014124 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014125 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014126 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014127 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014128 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014129 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14130 .dac_nids = alc269_dac_nids,
14131 .hp_nid = 0x03,
14132 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14133 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014134 .unsol_event = alc269_laptop_unsol_event,
14135 .setup = alc269_laptop_dmic_setup,
14136 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014137 },
Tony Vroon64154832008-11-06 15:08:49 +000014138 [ALC269_LIFEBOOK] = {
14139 .mixers = { alc269_lifebook_mixer },
14140 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14141 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14142 .dac_nids = alc269_dac_nids,
14143 .hp_nid = 0x03,
14144 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14145 .channel_mode = alc269_modes,
14146 .input_mux = &alc269_capture_source,
14147 .unsol_event = alc269_lifebook_unsol_event,
14148 .init_hook = alc269_lifebook_init_hook,
14149 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014150};
14151
14152static int patch_alc269(struct hda_codec *codec)
14153{
14154 struct alc_spec *spec;
14155 int board_config;
14156 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014157 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014158
14159 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14160 if (spec == NULL)
14161 return -ENOMEM;
14162
14163 codec->spec = spec;
14164
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020014165 alc_fix_pll_init(codec, 0x20, 0x04, 15);
14166
Kailang Yang274693f2009-12-03 10:07:50 +010014167 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
14168 kfree(codec->chip_name);
14169 codec->chip_name = kstrdup("ALC259", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010014170 if (!codec->chip_name) {
14171 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010014172 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010014173 }
Kailang Yang84898e82010-02-04 14:16:14 +010014174 is_alc269vb = 1;
Kailang Yang274693f2009-12-03 10:07:50 +010014175 }
14176
Kailang Yangf6a92242007-12-13 16:52:54 +010014177 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14178 alc269_models,
14179 alc269_cfg_tbl);
14180
14181 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014182 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14183 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014184 board_config = ALC269_AUTO;
14185 }
14186
14187 if (board_config == ALC269_AUTO) {
14188 /* automatic parse from the BIOS config */
14189 err = alc269_parse_auto_config(codec);
14190 if (err < 0) {
14191 alc_free(codec);
14192 return err;
14193 } else if (!err) {
14194 printk(KERN_INFO
14195 "hda_codec: Cannot set up configuration "
14196 "from BIOS. Using base mode...\n");
14197 board_config = ALC269_BASIC;
14198 }
14199 }
14200
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014201 err = snd_hda_attach_beep_device(codec, 0x1);
14202 if (err < 0) {
14203 alc_free(codec);
14204 return err;
14205 }
14206
Kailang Yangf6a92242007-12-13 16:52:54 +010014207 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014208 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014209
Kailang Yang84898e82010-02-04 14:16:14 +010014210 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014211 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14212 * fix the sample rate of analog I/O to 44.1kHz
14213 */
14214 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14215 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
14216 } else {
14217 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14218 spec->stream_analog_capture = &alc269_pcm_analog_capture;
14219 }
Kailang Yangf6a92242007-12-13 16:52:54 +010014220 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14221 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14222
Takashi Iwai66946352010-03-29 17:21:45 +020014223 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
14224 if (!is_alc269vb) {
14225 spec->adc_nids = alc269_adc_nids;
14226 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14227 spec->capsrc_nids = alc269_capsrc_nids;
14228 } else {
14229 spec->adc_nids = alc269vb_adc_nids;
14230 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14231 spec->capsrc_nids = alc269vb_capsrc_nids;
14232 }
Kailang Yang84898e82010-02-04 14:16:14 +010014233 }
14234
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014235 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014236 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014237 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010014238
Takashi Iwai100d5eb2009-08-10 11:55:51 +020014239 spec->vmaster_nid = 0x02;
14240
Kailang Yangf6a92242007-12-13 16:52:54 +010014241 codec->patch_ops = alc_patch_ops;
14242 if (board_config == ALC269_AUTO)
14243 spec->init_hook = alc269_auto_init;
14244#ifdef CONFIG_SND_HDA_POWER_SAVE
14245 if (!spec->loopback.amplist)
14246 spec->loopback.amplist = alc269_loopbacks;
14247#endif
14248
14249 return 0;
14250}
14251
14252/*
Kailang Yangdf694da2005-12-05 19:42:22 +010014253 * ALC861 channel source setting (2/6 channel selection for 3-stack)
14254 */
14255
14256/*
14257 * set the path ways for 2 channel output
14258 * need to set the codec line out and mic 1 pin widgets to inputs
14259 */
14260static struct hda_verb alc861_threestack_ch2_init[] = {
14261 /* set pin widget 1Ah (line in) for input */
14262 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014263 /* set pin widget 18h (mic1/2) for input, for mic also enable
14264 * the vref
14265 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014266 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14267
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014268 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14269#if 0
14270 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14271 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14272#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014273 { } /* end */
14274};
14275/*
14276 * 6ch mode
14277 * need to set the codec line out and mic 1 pin widgets to outputs
14278 */
14279static struct hda_verb alc861_threestack_ch6_init[] = {
14280 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14281 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14282 /* set pin widget 18h (mic1) for output (CLFE)*/
14283 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14284
14285 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014286 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014287
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014288 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14289#if 0
14290 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14291 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14292#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014293 { } /* end */
14294};
14295
14296static struct hda_channel_mode alc861_threestack_modes[2] = {
14297 { 2, alc861_threestack_ch2_init },
14298 { 6, alc861_threestack_ch6_init },
14299};
Takashi Iwai22309c32006-08-09 16:57:28 +020014300/* Set mic1 as input and unmute the mixer */
14301static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
14302 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14303 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14304 { } /* end */
14305};
14306/* Set mic1 as output and mute mixer */
14307static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
14308 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14309 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14310 { } /* end */
14311};
14312
14313static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
14314 { 2, alc861_uniwill_m31_ch2_init },
14315 { 4, alc861_uniwill_m31_ch4_init },
14316};
Kailang Yangdf694da2005-12-05 19:42:22 +010014317
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014318/* Set mic1 and line-in as input and unmute the mixer */
14319static struct hda_verb alc861_asus_ch2_init[] = {
14320 /* set pin widget 1Ah (line in) for input */
14321 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014322 /* set pin widget 18h (mic1/2) for input, for mic also enable
14323 * the vref
14324 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014325 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14326
14327 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14328#if 0
14329 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14330 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14331#endif
14332 { } /* end */
14333};
14334/* Set mic1 nad line-in as output and mute mixer */
14335static struct hda_verb alc861_asus_ch6_init[] = {
14336 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14337 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14338 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14339 /* set pin widget 18h (mic1) for output (CLFE)*/
14340 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14341 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14342 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
14343 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
14344
14345 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14346#if 0
14347 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14348 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14349#endif
14350 { } /* end */
14351};
14352
14353static struct hda_channel_mode alc861_asus_modes[2] = {
14354 { 2, alc861_asus_ch2_init },
14355 { 6, alc861_asus_ch6_init },
14356};
14357
Kailang Yangdf694da2005-12-05 19:42:22 +010014358/* patch-ALC861 */
14359
14360static struct snd_kcontrol_new alc861_base_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),
14378 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014379
Kailang Yangdf694da2005-12-05 19:42:22 +010014380 { } /* end */
14381};
14382
14383static struct snd_kcontrol_new alc861_3ST_mixer[] = {
14384 /* output mixer control */
14385 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14386 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14387 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14388 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14389 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14390
14391 /* Input mixer control */
14392 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14393 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14394 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14395 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14396 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14397 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14398 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14399 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14400 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14401 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014402
Kailang Yangdf694da2005-12-05 19:42:22 +010014403 {
14404 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14405 .name = "Channel Mode",
14406 .info = alc_ch_mode_info,
14407 .get = alc_ch_mode_get,
14408 .put = alc_ch_mode_put,
14409 .private_value = ARRAY_SIZE(alc861_threestack_modes),
14410 },
14411 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014412};
14413
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014414static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014415 /* output mixer control */
14416 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14417 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14418 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014419
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014420 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014421};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014422
Takashi Iwai22309c32006-08-09 16:57:28 +020014423static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
14424 /* output mixer control */
14425 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14426 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14427 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14428 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14429 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14430
14431 /* Input mixer control */
14432 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14433 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14434 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14435 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14436 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14437 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14438 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14439 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14440 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14441 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014442
Takashi Iwai22309c32006-08-09 16:57:28 +020014443 {
14444 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14445 .name = "Channel Mode",
14446 .info = alc_ch_mode_info,
14447 .get = alc_ch_mode_get,
14448 .put = alc_ch_mode_put,
14449 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
14450 },
14451 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014452};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014453
14454static struct snd_kcontrol_new alc861_asus_mixer[] = {
14455 /* output mixer control */
14456 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14457 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14458 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14459 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14460 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14461
14462 /* Input mixer control */
14463 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14464 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14465 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14466 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14467 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14468 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14469 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14470 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14471 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014472 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
14473
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014474 {
14475 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14476 .name = "Channel Mode",
14477 .info = alc_ch_mode_info,
14478 .get = alc_ch_mode_get,
14479 .put = alc_ch_mode_put,
14480 .private_value = ARRAY_SIZE(alc861_asus_modes),
14481 },
14482 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014483};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014484
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014485/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014486static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014487 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14488 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014489 { }
14490};
14491
Kailang Yangdf694da2005-12-05 19:42:22 +010014492/*
14493 * generic initialization of ADC, input mixers and output mixers
14494 */
14495static struct hda_verb alc861_base_init_verbs[] = {
14496 /*
14497 * Unmute ADC0 and set the default input to mic-in
14498 */
14499 /* port-A for surround (rear panel) */
14500 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14501 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
14502 /* port-B for mic-in (rear panel) with vref */
14503 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14504 /* port-C for line-in (rear panel) */
14505 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14506 /* port-D for Front */
14507 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14508 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14509 /* port-E for HP out (front panel) */
14510 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14511 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014512 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014513 /* port-F for mic-in (front panel) with vref */
14514 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14515 /* port-G for CLFE (rear panel) */
14516 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14517 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14518 /* port-H for side (rear panel) */
14519 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14520 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
14521 /* CD-in */
14522 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14523 /* route front mic to ADC1*/
14524 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14525 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014526
Kailang Yangdf694da2005-12-05 19:42:22 +010014527 /* Unmute DAC0~3 & spdif out*/
14528 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14529 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14530 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14531 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14532 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014533
Kailang Yangdf694da2005-12-05 19:42:22 +010014534 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14535 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14536 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14537 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14538 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014539
Kailang Yangdf694da2005-12-05 19:42:22 +010014540 /* Unmute Stereo Mixer 15 */
14541 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14542 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14543 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014544 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014545
14546 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14547 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14548 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14549 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14550 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14551 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14552 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14553 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014554 /* hp used DAC 3 (Front) */
14555 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014556 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14557
14558 { }
14559};
14560
14561static struct hda_verb alc861_threestack_init_verbs[] = {
14562 /*
14563 * Unmute ADC0 and set the default input to mic-in
14564 */
14565 /* port-A for surround (rear panel) */
14566 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14567 /* port-B for mic-in (rear panel) with vref */
14568 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14569 /* port-C for line-in (rear panel) */
14570 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14571 /* port-D for Front */
14572 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14573 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14574 /* port-E for HP out (front panel) */
14575 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14576 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014577 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014578 /* port-F for mic-in (front panel) with vref */
14579 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14580 /* port-G for CLFE (rear panel) */
14581 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14582 /* port-H for side (rear panel) */
14583 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14584 /* CD-in */
14585 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14586 /* route front mic to ADC1*/
14587 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14588 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14589 /* Unmute DAC0~3 & spdif out*/
14590 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14591 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14592 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14593 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14594 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014595
Kailang Yangdf694da2005-12-05 19:42:22 +010014596 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14597 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14598 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14599 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14600 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014601
Kailang Yangdf694da2005-12-05 19:42:22 +010014602 /* Unmute Stereo Mixer 15 */
14603 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14604 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14605 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014606 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014607
14608 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14609 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14610 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14611 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14612 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14613 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14614 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14615 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014616 /* hp used DAC 3 (Front) */
14617 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014618 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14619 { }
14620};
Takashi Iwai22309c32006-08-09 16:57:28 +020014621
14622static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14623 /*
14624 * Unmute ADC0 and set the default input to mic-in
14625 */
14626 /* port-A for surround (rear panel) */
14627 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14628 /* port-B for mic-in (rear panel) with vref */
14629 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14630 /* port-C for line-in (rear panel) */
14631 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14632 /* port-D for Front */
14633 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14634 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14635 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014636 /* this has to be set to VREF80 */
14637 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014638 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014639 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014640 /* port-F for mic-in (front panel) with vref */
14641 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14642 /* port-G for CLFE (rear panel) */
14643 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14644 /* port-H for side (rear panel) */
14645 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14646 /* CD-in */
14647 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14648 /* route front mic to ADC1*/
14649 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14650 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14651 /* Unmute DAC0~3 & spdif out*/
14652 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14653 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14654 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14655 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14656 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014657
Takashi Iwai22309c32006-08-09 16:57:28 +020014658 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14659 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14660 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14661 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14662 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014663
Takashi Iwai22309c32006-08-09 16:57:28 +020014664 /* Unmute Stereo Mixer 15 */
14665 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14666 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14667 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014668 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014669
14670 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14671 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14672 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14673 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14674 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14675 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14676 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14677 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014678 /* hp used DAC 3 (Front) */
14679 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014680 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14681 { }
14682};
14683
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014684static struct hda_verb alc861_asus_init_verbs[] = {
14685 /*
14686 * Unmute ADC0 and set the default input to mic-in
14687 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014688 /* port-A for surround (rear panel)
14689 * according to codec#0 this is the HP jack
14690 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014691 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14692 /* route front PCM to HP */
14693 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14694 /* port-B for mic-in (rear panel) with vref */
14695 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14696 /* port-C for line-in (rear panel) */
14697 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14698 /* port-D for Front */
14699 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14700 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14701 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014702 /* this has to be set to VREF80 */
14703 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014704 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014705 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014706 /* port-F for mic-in (front panel) with vref */
14707 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14708 /* port-G for CLFE (rear panel) */
14709 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14710 /* port-H for side (rear panel) */
14711 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14712 /* CD-in */
14713 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14714 /* route front mic to ADC1*/
14715 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14716 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14717 /* Unmute DAC0~3 & spdif out*/
14718 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14719 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14720 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14721 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14722 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14723 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14724 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14725 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14726 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14727 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014728
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014729 /* Unmute Stereo Mixer 15 */
14730 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14731 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14732 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014733 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014734
14735 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14736 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14737 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14738 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14739 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14740 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14741 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14742 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014743 /* hp used DAC 3 (Front) */
14744 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014745 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14746 { }
14747};
14748
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014749/* additional init verbs for ASUS laptops */
14750static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14751 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14752 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14753 { }
14754};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014755
Kailang Yangdf694da2005-12-05 19:42:22 +010014756/*
14757 * generic initialization of ADC, input mixers and output mixers
14758 */
14759static struct hda_verb alc861_auto_init_verbs[] = {
14760 /*
14761 * Unmute ADC0 and set the default input to mic-in
14762 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014763 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014764 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014765
Kailang Yangdf694da2005-12-05 19:42:22 +010014766 /* Unmute DAC0~3 & spdif out*/
14767 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14768 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14769 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14770 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14771 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014772
Kailang Yangdf694da2005-12-05 19:42:22 +010014773 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14774 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14775 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14776 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14777 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014778
Kailang Yangdf694da2005-12-05 19:42:22 +010014779 /* Unmute Stereo Mixer 15 */
14780 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14781 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14782 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14783 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14784
Takashi Iwai1c209302009-07-22 15:17:45 +020014785 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14786 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14787 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14788 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14789 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14790 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14791 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14792 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014793
14794 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14795 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014796 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14797 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014798 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14799 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014800 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14801 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014802
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014803 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014804
14805 { }
14806};
14807
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014808static struct hda_verb alc861_toshiba_init_verbs[] = {
14809 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014810
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014811 { }
14812};
14813
14814/* toggle speaker-output according to the hp-jack state */
14815static void alc861_toshiba_automute(struct hda_codec *codec)
14816{
Wu Fengguang864f92b2009-11-18 12:38:02 +080014817 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014818
Takashi Iwai47fd8302007-08-10 17:11:07 +020014819 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14820 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14821 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14822 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014823}
14824
14825static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14826 unsigned int res)
14827{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014828 if ((res >> 26) == ALC880_HP_EVENT)
14829 alc861_toshiba_automute(codec);
14830}
14831
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014832/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014833#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14834#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14835#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14836#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14837
14838
14839#define ALC861_DIGOUT_NID 0x07
14840
14841static struct hda_channel_mode alc861_8ch_modes[1] = {
14842 { 8, NULL }
14843};
14844
14845static hda_nid_t alc861_dac_nids[4] = {
14846 /* front, surround, clfe, side */
14847 0x03, 0x06, 0x05, 0x04
14848};
14849
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014850static hda_nid_t alc660_dac_nids[3] = {
14851 /* front, clfe, surround */
14852 0x03, 0x05, 0x06
14853};
14854
Kailang Yangdf694da2005-12-05 19:42:22 +010014855static hda_nid_t alc861_adc_nids[1] = {
14856 /* ADC0-2 */
14857 0x08,
14858};
14859
14860static struct hda_input_mux alc861_capture_source = {
14861 .num_items = 5,
14862 .items = {
14863 { "Mic", 0x0 },
14864 { "Front Mic", 0x3 },
14865 { "Line", 0x1 },
14866 { "CD", 0x4 },
14867 { "Mixer", 0x5 },
14868 },
14869};
14870
Takashi Iwai1c209302009-07-22 15:17:45 +020014871static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14872{
14873 struct alc_spec *spec = codec->spec;
14874 hda_nid_t mix, srcs[5];
14875 int i, j, num;
14876
14877 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14878 return 0;
14879 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14880 if (num < 0)
14881 return 0;
14882 for (i = 0; i < num; i++) {
14883 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014884 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014885 if (type != AC_WID_AUD_OUT)
14886 continue;
14887 for (j = 0; j < spec->multiout.num_dacs; j++)
14888 if (spec->multiout.dac_nids[j] == srcs[i])
14889 break;
14890 if (j >= spec->multiout.num_dacs)
14891 return srcs[i];
14892 }
14893 return 0;
14894}
14895
Kailang Yangdf694da2005-12-05 19:42:22 +010014896/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014897static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014898 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014899{
Takashi Iwai1c209302009-07-22 15:17:45 +020014900 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014901 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014902 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014903
14904 spec->multiout.dac_nids = spec->private_dac_nids;
14905 for (i = 0; i < cfg->line_outs; i++) {
14906 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014907 dac = alc861_look_for_dac(codec, nid);
14908 if (!dac)
14909 continue;
14910 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014911 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014912 return 0;
14913}
14914
Takashi Iwai1c209302009-07-22 15:17:45 +020014915static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14916 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014917{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020014918 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020014919 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14920}
14921
14922/* add playback controls from the parsed DAC table */
14923static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14924 const struct auto_pin_cfg *cfg)
14925{
14926 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014927 static const char *chname[4] = {
14928 "Front", "Surround", NULL /*CLFE*/, "Side"
14929 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014930 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014931 int i, err;
14932
14933 if (cfg->line_outs == 1) {
14934 const char *pfx = NULL;
14935 if (!cfg->hp_outs)
14936 pfx = "Master";
14937 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14938 pfx = "Speaker";
14939 if (pfx) {
14940 nid = spec->multiout.dac_nids[0];
14941 return alc861_create_out_sw(codec, pfx, nid, 3);
14942 }
14943 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014944
14945 for (i = 0; i < cfg->line_outs; i++) {
14946 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014947 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014948 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014949 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014950 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014951 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014952 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014953 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014954 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014955 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014956 return err;
14957 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014958 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014959 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014960 return err;
14961 }
14962 }
14963 return 0;
14964}
14965
Takashi Iwai1c209302009-07-22 15:17:45 +020014966static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014967{
Takashi Iwai1c209302009-07-22 15:17:45 +020014968 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014969 int err;
14970 hda_nid_t nid;
14971
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014972 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014973 return 0;
14974
14975 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014976 nid = alc861_look_for_dac(codec, pin);
14977 if (nid) {
14978 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14979 if (err < 0)
14980 return err;
14981 spec->multiout.hp_nid = nid;
14982 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014983 }
14984 return 0;
14985}
14986
14987/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014988static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014989 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014990{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014991 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014992}
14993
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014994static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14995 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014996 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014997{
Takashi Iwai1c209302009-07-22 15:17:45 +020014998 hda_nid_t mix, srcs[5];
14999 int i, num;
15000
Jacek Luczak564c5be2008-05-03 18:41:23 +020015001 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15002 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015003 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015004 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015005 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15006 return;
15007 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15008 if (num < 0)
15009 return;
15010 for (i = 0; i < num; i++) {
15011 unsigned int mute;
15012 if (srcs[i] == dac || srcs[i] == 0x15)
15013 mute = AMP_IN_UNMUTE(i);
15014 else
15015 mute = AMP_IN_MUTE(i);
15016 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15017 mute);
15018 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015019}
15020
15021static void alc861_auto_init_multi_out(struct hda_codec *codec)
15022{
15023 struct alc_spec *spec = codec->spec;
15024 int i;
15025
15026 for (i = 0; i < spec->autocfg.line_outs; i++) {
15027 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015028 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015029 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015030 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015031 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015032 }
15033}
15034
15035static void alc861_auto_init_hp_out(struct hda_codec *codec)
15036{
15037 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015038
Takashi Iwai15870f02009-10-05 08:25:13 +020015039 if (spec->autocfg.hp_outs)
15040 alc861_auto_set_output_and_unmute(codec,
15041 spec->autocfg.hp_pins[0],
15042 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015043 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015044 if (spec->autocfg.speaker_outs)
15045 alc861_auto_set_output_and_unmute(codec,
15046 spec->autocfg.speaker_pins[0],
15047 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015048 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015049}
15050
15051static void alc861_auto_init_analog_input(struct hda_codec *codec)
15052{
15053 struct alc_spec *spec = codec->spec;
15054 int i;
15055
15056 for (i = 0; i < AUTO_PIN_LAST; i++) {
15057 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010015058 if (nid >= 0x0c && nid <= 0x11)
15059 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010015060 }
15061}
15062
15063/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015064/* return 1 if successful, 0 if the proper config is not found,
15065 * or a negative error code
15066 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015067static int alc861_parse_auto_config(struct hda_codec *codec)
15068{
15069 struct alc_spec *spec = codec->spec;
15070 int err;
15071 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15072
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015073 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15074 alc861_ignore);
15075 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015076 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015077 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015078 return 0; /* can't find valid BIOS pin config */
15079
Takashi Iwai1c209302009-07-22 15:17:45 +020015080 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015081 if (err < 0)
15082 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015083 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015084 if (err < 0)
15085 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015086 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015087 if (err < 0)
15088 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015089 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015090 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015091 return err;
15092
15093 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15094
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015095 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015096 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
15097
Takashi Iwai603c4012008-07-30 15:01:44 +020015098 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015099 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015100
Takashi Iwaid88897e2008-10-31 15:01:37 +010015101 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015102
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015103 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015104 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015105
15106 spec->adc_nids = alc861_adc_nids;
15107 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015108 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015109
Kailang Yang6227cdc2010-02-25 08:36:52 +010015110 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015111
Kailang Yangdf694da2005-12-05 19:42:22 +010015112 return 1;
15113}
15114
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015115/* additional initialization for auto-configuration model */
15116static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015117{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015118 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015119 alc861_auto_init_multi_out(codec);
15120 alc861_auto_init_hp_out(codec);
15121 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015122 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015123 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015124}
15125
Takashi Iwaicb53c622007-08-10 17:21:45 +020015126#ifdef CONFIG_SND_HDA_POWER_SAVE
15127static struct hda_amp_list alc861_loopbacks[] = {
15128 { 0x15, HDA_INPUT, 0 },
15129 { 0x15, HDA_INPUT, 1 },
15130 { 0x15, HDA_INPUT, 2 },
15131 { 0x15, HDA_INPUT, 3 },
15132 { } /* end */
15133};
15134#endif
15135
Kailang Yangdf694da2005-12-05 19:42:22 +010015136
15137/*
15138 * configuration and preset
15139 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015140static const char *alc861_models[ALC861_MODEL_LAST] = {
15141 [ALC861_3ST] = "3stack",
15142 [ALC660_3ST] = "3stack-660",
15143 [ALC861_3ST_DIG] = "3stack-dig",
15144 [ALC861_6ST_DIG] = "6stack-dig",
15145 [ALC861_UNIWILL_M31] = "uniwill-m31",
15146 [ALC861_TOSHIBA] = "toshiba",
15147 [ALC861_ASUS] = "asus",
15148 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15149 [ALC861_AUTO] = "auto",
15150};
15151
15152static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015153 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015154 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15155 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15156 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015157 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015158 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015159 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015160 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15161 * Any other models that need this preset?
15162 */
15163 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015164 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15165 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015166 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15167 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15168 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15169 /* FIXME: the below seems conflict */
15170 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15171 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15172 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015173 {}
15174};
15175
15176static struct alc_config_preset alc861_presets[] = {
15177 [ALC861_3ST] = {
15178 .mixers = { alc861_3ST_mixer },
15179 .init_verbs = { alc861_threestack_init_verbs },
15180 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15181 .dac_nids = alc861_dac_nids,
15182 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15183 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015184 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015185 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15186 .adc_nids = alc861_adc_nids,
15187 .input_mux = &alc861_capture_source,
15188 },
15189 [ALC861_3ST_DIG] = {
15190 .mixers = { alc861_base_mixer },
15191 .init_verbs = { alc861_threestack_init_verbs },
15192 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15193 .dac_nids = alc861_dac_nids,
15194 .dig_out_nid = ALC861_DIGOUT_NID,
15195 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15196 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015197 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015198 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15199 .adc_nids = alc861_adc_nids,
15200 .input_mux = &alc861_capture_source,
15201 },
15202 [ALC861_6ST_DIG] = {
15203 .mixers = { alc861_base_mixer },
15204 .init_verbs = { alc861_base_init_verbs },
15205 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15206 .dac_nids = alc861_dac_nids,
15207 .dig_out_nid = ALC861_DIGOUT_NID,
15208 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
15209 .channel_mode = alc861_8ch_modes,
15210 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15211 .adc_nids = alc861_adc_nids,
15212 .input_mux = &alc861_capture_source,
15213 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015214 [ALC660_3ST] = {
15215 .mixers = { alc861_3ST_mixer },
15216 .init_verbs = { alc861_threestack_init_verbs },
15217 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
15218 .dac_nids = alc660_dac_nids,
15219 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15220 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015221 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015222 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15223 .adc_nids = alc861_adc_nids,
15224 .input_mux = &alc861_capture_source,
15225 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015226 [ALC861_UNIWILL_M31] = {
15227 .mixers = { alc861_uniwill_m31_mixer },
15228 .init_verbs = { alc861_uniwill_m31_init_verbs },
15229 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15230 .dac_nids = alc861_dac_nids,
15231 .dig_out_nid = ALC861_DIGOUT_NID,
15232 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
15233 .channel_mode = alc861_uniwill_m31_modes,
15234 .need_dac_fix = 1,
15235 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15236 .adc_nids = alc861_adc_nids,
15237 .input_mux = &alc861_capture_source,
15238 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015239 [ALC861_TOSHIBA] = {
15240 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015241 .init_verbs = { alc861_base_init_verbs,
15242 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015243 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15244 .dac_nids = alc861_dac_nids,
15245 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15246 .channel_mode = alc883_3ST_2ch_modes,
15247 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15248 .adc_nids = alc861_adc_nids,
15249 .input_mux = &alc861_capture_source,
15250 .unsol_event = alc861_toshiba_unsol_event,
15251 .init_hook = alc861_toshiba_automute,
15252 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015253 [ALC861_ASUS] = {
15254 .mixers = { alc861_asus_mixer },
15255 .init_verbs = { alc861_asus_init_verbs },
15256 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15257 .dac_nids = alc861_dac_nids,
15258 .dig_out_nid = ALC861_DIGOUT_NID,
15259 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
15260 .channel_mode = alc861_asus_modes,
15261 .need_dac_fix = 1,
15262 .hp_nid = 0x06,
15263 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15264 .adc_nids = alc861_adc_nids,
15265 .input_mux = &alc861_capture_source,
15266 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015267 [ALC861_ASUS_LAPTOP] = {
15268 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
15269 .init_verbs = { alc861_asus_init_verbs,
15270 alc861_asus_laptop_init_verbs },
15271 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15272 .dac_nids = alc861_dac_nids,
15273 .dig_out_nid = ALC861_DIGOUT_NID,
15274 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15275 .channel_mode = alc883_3ST_2ch_modes,
15276 .need_dac_fix = 1,
15277 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15278 .adc_nids = alc861_adc_nids,
15279 .input_mux = &alc861_capture_source,
15280 },
15281};
Kailang Yangdf694da2005-12-05 19:42:22 +010015282
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015283/* Pin config fixes */
15284enum {
15285 PINFIX_FSC_AMILO_PI1505,
15286};
15287
15288static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
15289 { 0x0b, 0x0221101f }, /* HP */
15290 { 0x0f, 0x90170310 }, /* speaker */
15291 { }
15292};
15293
15294static const struct alc_fixup alc861_fixups[] = {
15295 [PINFIX_FSC_AMILO_PI1505] = {
15296 .pins = alc861_fsc_amilo_pi1505_pinfix
15297 },
15298};
15299
15300static struct snd_pci_quirk alc861_fixup_tbl[] = {
15301 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
15302 {}
15303};
Kailang Yangdf694da2005-12-05 19:42:22 +010015304
15305static int patch_alc861(struct hda_codec *codec)
15306{
15307 struct alc_spec *spec;
15308 int board_config;
15309 int err;
15310
Robert P. J. Daydc041e02006-12-19 14:44:15 +010015311 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010015312 if (spec == NULL)
15313 return -ENOMEM;
15314
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015315 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015316
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015317 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
15318 alc861_models,
15319 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015320
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015321 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015322 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15323 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010015324 board_config = ALC861_AUTO;
15325 }
15326
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015327 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups);
15328
Kailang Yangdf694da2005-12-05 19:42:22 +010015329 if (board_config == ALC861_AUTO) {
15330 /* automatic parse from the BIOS config */
15331 err = alc861_parse_auto_config(codec);
15332 if (err < 0) {
15333 alc_free(codec);
15334 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015335 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015336 printk(KERN_INFO
15337 "hda_codec: Cannot set up configuration "
15338 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010015339 board_config = ALC861_3ST_DIG;
15340 }
15341 }
15342
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015343 err = snd_hda_attach_beep_device(codec, 0x23);
15344 if (err < 0) {
15345 alc_free(codec);
15346 return err;
15347 }
15348
Kailang Yangdf694da2005-12-05 19:42:22 +010015349 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015350 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015351
Kailang Yangdf694da2005-12-05 19:42:22 +010015352 spec->stream_analog_playback = &alc861_pcm_analog_playback;
15353 spec->stream_analog_capture = &alc861_pcm_analog_capture;
15354
Kailang Yangdf694da2005-12-05 19:42:22 +010015355 spec->stream_digital_playback = &alc861_pcm_digital_playback;
15356 spec->stream_digital_capture = &alc861_pcm_digital_capture;
15357
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010015358 if (!spec->cap_mixer)
15359 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015360 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
15361
Takashi Iwai2134ea42008-01-10 16:53:55 +010015362 spec->vmaster_nid = 0x03;
15363
Kailang Yangdf694da2005-12-05 19:42:22 +010015364 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050015365 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015366 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015367#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015368 spec->power_hook = alc_power_eapd;
15369#endif
15370 }
15371#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015372 if (!spec->loopback.amplist)
15373 spec->loopback.amplist = alc861_loopbacks;
15374#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015375
Kailang Yangdf694da2005-12-05 19:42:22 +010015376 return 0;
15377}
15378
15379/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015380 * ALC861-VD support
15381 *
15382 * Based on ALC882
15383 *
15384 * In addition, an independent DAC
15385 */
15386#define ALC861VD_DIGOUT_NID 0x06
15387
15388static hda_nid_t alc861vd_dac_nids[4] = {
15389 /* front, surr, clfe, side surr */
15390 0x02, 0x03, 0x04, 0x05
15391};
15392
15393/* dac_nids for ALC660vd are in a different order - according to
15394 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015395 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015396 * of ALC660vd codecs, but for now there is only 3stack mixer
15397 * - and it is the same as in 861vd.
15398 * adc_nids in ALC660vd are (is) the same as in 861vd
15399 */
15400static hda_nid_t alc660vd_dac_nids[3] = {
15401 /* front, rear, clfe, rear_surr */
15402 0x02, 0x04, 0x03
15403};
15404
15405static hda_nid_t alc861vd_adc_nids[1] = {
15406 /* ADC0 */
15407 0x09,
15408};
15409
Takashi Iwaie1406342008-02-11 18:32:32 +010015410static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
15411
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015412/* input MUX */
15413/* FIXME: should be a matrix-type input source selection */
15414static struct hda_input_mux alc861vd_capture_source = {
15415 .num_items = 4,
15416 .items = {
15417 { "Mic", 0x0 },
15418 { "Front Mic", 0x1 },
15419 { "Line", 0x2 },
15420 { "CD", 0x4 },
15421 },
15422};
15423
Kailang Yang272a5272007-05-14 11:00:38 +020015424static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010015425 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020015426 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010015427 { "Ext Mic", 0x0 },
15428 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020015429 },
15430};
15431
Kailang Yangd1a991a2007-08-15 16:21:59 +020015432static struct hda_input_mux alc861vd_hp_capture_source = {
15433 .num_items = 2,
15434 .items = {
15435 { "Front Mic", 0x0 },
15436 { "ATAPI Mic", 0x1 },
15437 },
15438};
15439
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015440/*
15441 * 2ch mode
15442 */
15443static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
15444 { 2, NULL }
15445};
15446
15447/*
15448 * 6ch mode
15449 */
15450static struct hda_verb alc861vd_6stack_ch6_init[] = {
15451 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15452 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15453 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15454 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15455 { } /* end */
15456};
15457
15458/*
15459 * 8ch mode
15460 */
15461static struct hda_verb alc861vd_6stack_ch8_init[] = {
15462 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15463 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15464 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15465 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15466 { } /* end */
15467};
15468
15469static struct hda_channel_mode alc861vd_6stack_modes[2] = {
15470 { 6, alc861vd_6stack_ch6_init },
15471 { 8, alc861vd_6stack_ch8_init },
15472};
15473
15474static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
15475 {
15476 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15477 .name = "Channel Mode",
15478 .info = alc_ch_mode_info,
15479 .get = alc_ch_mode_get,
15480 .put = alc_ch_mode_put,
15481 },
15482 { } /* end */
15483};
15484
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015485/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15486 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15487 */
15488static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
15489 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15490 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15491
15492 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15493 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
15494
15495 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
15496 HDA_OUTPUT),
15497 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
15498 HDA_OUTPUT),
15499 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
15500 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
15501
15502 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
15503 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
15504
15505 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15506
15507 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15508 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15509 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15510
15511 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15512 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15513 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15514
15515 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15516 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15517
15518 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15519 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15520
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015521 { } /* end */
15522};
15523
15524static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
15525 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15526 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15527
15528 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15529
15530 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15531 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15532 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15533
15534 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15535 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15536 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15537
15538 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15539 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15540
15541 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15542 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15543
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015544 { } /* end */
15545};
15546
Kailang Yangbdd148a2007-05-08 15:19:08 +020015547static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
15548 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15549 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
15550 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15551
15552 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15553
15554 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15555 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15556 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15557
15558 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15559 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15560 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15561
15562 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15563 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15564
15565 { } /* end */
15566};
15567
Tobin Davisb419f342008-03-07 11:57:51 +010015568/* Pin assignment: Speaker=0x14, HP = 0x15,
15569 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015570 */
15571static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015572 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15573 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015574 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15575 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015576 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15577 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15578 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15579 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15580 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15581 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015582 { } /* end */
15583};
15584
Kailang Yangd1a991a2007-08-15 16:21:59 +020015585/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15586 * Front Mic=0x18, ATAPI Mic = 0x19,
15587 */
15588static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15589 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15590 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15591 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15592 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15593 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15594 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15595 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15596 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015597
Kailang Yangd1a991a2007-08-15 16:21:59 +020015598 { } /* end */
15599};
15600
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015601/*
15602 * generic initialization of ADC, input mixers and output mixers
15603 */
15604static struct hda_verb alc861vd_volume_init_verbs[] = {
15605 /*
15606 * Unmute ADC0 and set the default input to mic-in
15607 */
15608 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15609 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15610
15611 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15612 * the analog-loopback mixer widget
15613 */
15614 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015615 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15616 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15617 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15618 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15619 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015620
15621 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015625 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015626
15627 /*
15628 * Set up output mixers (0x02 - 0x05)
15629 */
15630 /* set vol=0 to output mixers */
15631 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15632 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15633 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15634 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15635
15636 /* set up input amps for analog loopback */
15637 /* Amp Indices: DAC = 0, mixer = 1 */
15638 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15639 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15640 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15641 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15642 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15643 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15644 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15645 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15646
15647 { }
15648};
15649
15650/*
15651 * 3-stack pin configuration:
15652 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15653 */
15654static struct hda_verb alc861vd_3stack_init_verbs[] = {
15655 /*
15656 * Set pin mode and muting
15657 */
15658 /* set front pin widgets 0x14 for output */
15659 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15660 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15661 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15662
15663 /* Mic (rear) pin: input vref at 80% */
15664 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15665 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15666 /* Front Mic pin: input vref at 80% */
15667 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15668 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15669 /* Line In pin: input */
15670 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15671 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15672 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15673 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15674 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15675 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15676 /* CD pin widget for input */
15677 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15678
15679 { }
15680};
15681
15682/*
15683 * 6-stack pin configuration:
15684 */
15685static struct hda_verb alc861vd_6stack_init_verbs[] = {
15686 /*
15687 * Set pin mode and muting
15688 */
15689 /* set front pin widgets 0x14 for output */
15690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15692 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15693
15694 /* Rear Pin: output 1 (0x0d) */
15695 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15696 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15697 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15698 /* CLFE Pin: output 2 (0x0e) */
15699 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15700 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15701 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15702 /* Side Pin: output 3 (0x0f) */
15703 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15704 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15705 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15706
15707 /* Mic (rear) pin: input vref at 80% */
15708 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15709 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15710 /* Front Mic pin: input vref at 80% */
15711 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15712 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15713 /* Line In pin: input */
15714 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15715 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15716 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15717 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15718 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15719 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15720 /* CD pin widget for input */
15721 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15722
15723 { }
15724};
15725
Kailang Yangbdd148a2007-05-08 15:19:08 +020015726static struct hda_verb alc861vd_eapd_verbs[] = {
15727 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15728 { }
15729};
15730
Kailang Yangf9423e72008-05-27 12:32:25 +020015731static struct hda_verb alc660vd_eapd_verbs[] = {
15732 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15733 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15734 { }
15735};
15736
Kailang Yangbdd148a2007-05-08 15:19:08 +020015737static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15738 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15739 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15740 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15741 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015742 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015743 {}
15744};
15745
Kailang Yangbdd148a2007-05-08 15:19:08 +020015746static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15747{
15748 unsigned int present;
15749 unsigned char bits;
15750
Wu Fengguang864f92b2009-11-18 12:38:02 +080015751 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020015752 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080015753
Takashi Iwai47fd8302007-08-10 17:11:07 +020015754 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15755 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015756}
15757
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015758static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015759{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015760 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015761 spec->autocfg.hp_pins[0] = 0x1b;
15762 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015763}
15764
15765static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15766{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015767 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015768 alc861vd_lenovo_mic_automute(codec);
15769}
15770
15771static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15772 unsigned int res)
15773{
15774 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015775 case ALC880_MIC_EVENT:
15776 alc861vd_lenovo_mic_automute(codec);
15777 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015778 default:
15779 alc_automute_amp_unsol_event(codec, res);
15780 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015781 }
15782}
15783
Kailang Yang272a5272007-05-14 11:00:38 +020015784static struct hda_verb alc861vd_dallas_verbs[] = {
15785 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15786 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15787 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15788 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15789
15790 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15791 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15792 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15793 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15794 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15795 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15796 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15797 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015798
Kailang Yang272a5272007-05-14 11:00:38 +020015799 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15800 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15801 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15802 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15803 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15804 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15805 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15806 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15807
15808 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15809 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15810 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15811 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15812 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15813 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15814 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15815 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15816
15817 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15818 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15819 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15820 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15821
15822 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015823 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015824 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15825
15826 { } /* end */
15827};
15828
15829/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015830static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015831{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015832 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015833
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015834 spec->autocfg.hp_pins[0] = 0x15;
15835 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015836}
15837
Takashi Iwaicb53c622007-08-10 17:21:45 +020015838#ifdef CONFIG_SND_HDA_POWER_SAVE
15839#define alc861vd_loopbacks alc880_loopbacks
15840#endif
15841
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015842/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015843#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15844#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15845#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15846#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15847
15848/*
15849 * configuration and preset
15850 */
15851static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15852 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015853 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015854 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015855 [ALC861VD_3ST] = "3stack",
15856 [ALC861VD_3ST_DIG] = "3stack-digout",
15857 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015858 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015859 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015860 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015861 [ALC861VD_AUTO] = "auto",
15862};
15863
15864static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015865 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15866 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015867 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015868 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015869 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015870 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015871 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015872 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015873 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015874 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015875 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015876 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015877 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015878 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015879 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015880 {}
15881};
15882
15883static struct alc_config_preset alc861vd_presets[] = {
15884 [ALC660VD_3ST] = {
15885 .mixers = { alc861vd_3st_mixer },
15886 .init_verbs = { alc861vd_volume_init_verbs,
15887 alc861vd_3stack_init_verbs },
15888 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15889 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015890 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15891 .channel_mode = alc861vd_3stack_2ch_modes,
15892 .input_mux = &alc861vd_capture_source,
15893 },
Mike Crash6963f842007-06-25 12:12:51 +020015894 [ALC660VD_3ST_DIG] = {
15895 .mixers = { alc861vd_3st_mixer },
15896 .init_verbs = { alc861vd_volume_init_verbs,
15897 alc861vd_3stack_init_verbs },
15898 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15899 .dac_nids = alc660vd_dac_nids,
15900 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015901 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15902 .channel_mode = alc861vd_3stack_2ch_modes,
15903 .input_mux = &alc861vd_capture_source,
15904 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015905 [ALC861VD_3ST] = {
15906 .mixers = { alc861vd_3st_mixer },
15907 .init_verbs = { alc861vd_volume_init_verbs,
15908 alc861vd_3stack_init_verbs },
15909 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15910 .dac_nids = alc861vd_dac_nids,
15911 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15912 .channel_mode = alc861vd_3stack_2ch_modes,
15913 .input_mux = &alc861vd_capture_source,
15914 },
15915 [ALC861VD_3ST_DIG] = {
15916 .mixers = { alc861vd_3st_mixer },
15917 .init_verbs = { alc861vd_volume_init_verbs,
15918 alc861vd_3stack_init_verbs },
15919 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15920 .dac_nids = alc861vd_dac_nids,
15921 .dig_out_nid = ALC861VD_DIGOUT_NID,
15922 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15923 .channel_mode = alc861vd_3stack_2ch_modes,
15924 .input_mux = &alc861vd_capture_source,
15925 },
15926 [ALC861VD_6ST_DIG] = {
15927 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15928 .init_verbs = { alc861vd_volume_init_verbs,
15929 alc861vd_6stack_init_verbs },
15930 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15931 .dac_nids = alc861vd_dac_nids,
15932 .dig_out_nid = ALC861VD_DIGOUT_NID,
15933 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15934 .channel_mode = alc861vd_6stack_modes,
15935 .input_mux = &alc861vd_capture_source,
15936 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015937 [ALC861VD_LENOVO] = {
15938 .mixers = { alc861vd_lenovo_mixer },
15939 .init_verbs = { alc861vd_volume_init_verbs,
15940 alc861vd_3stack_init_verbs,
15941 alc861vd_eapd_verbs,
15942 alc861vd_lenovo_unsol_verbs },
15943 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15944 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015945 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15946 .channel_mode = alc861vd_3stack_2ch_modes,
15947 .input_mux = &alc861vd_capture_source,
15948 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015949 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015950 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015951 },
Kailang Yang272a5272007-05-14 11:00:38 +020015952 [ALC861VD_DALLAS] = {
15953 .mixers = { alc861vd_dallas_mixer },
15954 .init_verbs = { alc861vd_dallas_verbs },
15955 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15956 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015957 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15958 .channel_mode = alc861vd_3stack_2ch_modes,
15959 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015960 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015961 .setup = alc861vd_dallas_setup,
15962 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015963 },
15964 [ALC861VD_HP] = {
15965 .mixers = { alc861vd_hp_mixer },
15966 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15967 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15968 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015969 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015970 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15971 .channel_mode = alc861vd_3stack_2ch_modes,
15972 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015973 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015974 .setup = alc861vd_dallas_setup,
15975 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015976 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015977 [ALC660VD_ASUS_V1S] = {
15978 .mixers = { alc861vd_lenovo_mixer },
15979 .init_verbs = { alc861vd_volume_init_verbs,
15980 alc861vd_3stack_init_verbs,
15981 alc861vd_eapd_verbs,
15982 alc861vd_lenovo_unsol_verbs },
15983 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15984 .dac_nids = alc660vd_dac_nids,
15985 .dig_out_nid = ALC861VD_DIGOUT_NID,
15986 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15987 .channel_mode = alc861vd_3stack_2ch_modes,
15988 .input_mux = &alc861vd_capture_source,
15989 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015990 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015991 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015992 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015993};
15994
15995/*
15996 * BIOS auto configuration
15997 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015998static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15999 const struct auto_pin_cfg *cfg)
16000{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016001 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016002}
16003
16004
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016005static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16006 hda_nid_t nid, int pin_type, int dac_idx)
16007{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016008 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016009}
16010
16011static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16012{
16013 struct alc_spec *spec = codec->spec;
16014 int i;
16015
16016 for (i = 0; i <= HDA_SIDE; i++) {
16017 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016018 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016019 if (nid)
16020 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016021 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016022 }
16023}
16024
16025
16026static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16027{
16028 struct alc_spec *spec = codec->spec;
16029 hda_nid_t pin;
16030
16031 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016032 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016033 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016034 pin = spec->autocfg.speaker_pins[0];
16035 if (pin)
16036 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016037}
16038
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016039#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16040
16041static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16042{
16043 struct alc_spec *spec = codec->spec;
16044 int i;
16045
16046 for (i = 0; i < AUTO_PIN_LAST; i++) {
16047 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020016048 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016049 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016050 if (nid != ALC861VD_PIN_CD_NID &&
16051 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016052 snd_hda_codec_write(codec, nid, 0,
16053 AC_VERB_SET_AMP_GAIN_MUTE,
16054 AMP_OUT_MUTE);
16055 }
16056 }
16057}
16058
Takashi Iwaif511b012008-08-15 16:46:42 +020016059#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16060
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016061#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16062#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16063
16064/* add playback controls from the parsed DAC table */
16065/* Based on ALC880 version. But ALC861VD has separate,
16066 * different NIDs for mute/unmute switch and volume control */
16067static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16068 const struct auto_pin_cfg *cfg)
16069{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016070 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16071 hda_nid_t nid_v, nid_s;
16072 int i, err;
16073
16074 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016075 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016076 continue;
16077 nid_v = alc861vd_idx_to_mixer_vol(
16078 alc880_dac_to_idx(
16079 spec->multiout.dac_nids[i]));
16080 nid_s = alc861vd_idx_to_mixer_switch(
16081 alc880_dac_to_idx(
16082 spec->multiout.dac_nids[i]));
16083
16084 if (i == 2) {
16085 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016086 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16087 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016088 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16089 HDA_OUTPUT));
16090 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016091 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016092 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16093 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016094 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16095 HDA_OUTPUT));
16096 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016097 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016098 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16099 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016100 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16101 HDA_INPUT));
16102 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016103 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016104 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16105 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016106 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16107 HDA_INPUT));
16108 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016109 return err;
16110 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016111 const char *pfx;
16112 if (cfg->line_outs == 1 &&
16113 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16114 if (!cfg->hp_pins)
16115 pfx = "Speaker";
16116 else
16117 pfx = "PCM";
16118 } else
16119 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016120 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016121 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16122 HDA_OUTPUT));
16123 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016124 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016125 if (cfg->line_outs == 1 &&
16126 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16127 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016128 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016129 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016130 HDA_INPUT));
16131 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016132 return err;
16133 }
16134 }
16135 return 0;
16136}
16137
16138/* add playback controls for speaker and HP outputs */
16139/* Based on ALC880 version. But ALC861VD has separate,
16140 * different NIDs for mute/unmute switch and volume control */
16141static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16142 hda_nid_t pin, const char *pfx)
16143{
16144 hda_nid_t nid_v, nid_s;
16145 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016146
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016147 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016148 return 0;
16149
16150 if (alc880_is_fixed_pin(pin)) {
16151 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16152 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016153 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016154 spec->multiout.hp_nid = nid_v;
16155 else
16156 spec->multiout.extra_out_nid[0] = nid_v;
16157 /* control HP volume/switch on the output mixer amp */
16158 nid_v = alc861vd_idx_to_mixer_vol(
16159 alc880_fixed_pin_idx(pin));
16160 nid_s = alc861vd_idx_to_mixer_switch(
16161 alc880_fixed_pin_idx(pin));
16162
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016163 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016164 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16165 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016166 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016167 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016168 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16169 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016170 return err;
16171 } else if (alc880_is_multi_pin(pin)) {
16172 /* set manual connection */
16173 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016174 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016175 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16176 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016177 return err;
16178 }
16179 return 0;
16180}
16181
16182/* parse the BIOS configuration and set up the alc_spec
16183 * return 1 if successful, 0 if the proper config is not found,
16184 * or a negative error code
16185 * Based on ALC880 version - had to change it to override
16186 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16187static int alc861vd_parse_auto_config(struct hda_codec *codec)
16188{
16189 struct alc_spec *spec = codec->spec;
16190 int err;
16191 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16192
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016193 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16194 alc861vd_ignore);
16195 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016196 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016197 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016198 return 0; /* can't find valid BIOS pin config */
16199
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016200 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16201 if (err < 0)
16202 return err;
16203 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
16204 if (err < 0)
16205 return err;
16206 err = alc861vd_auto_create_extra_out(spec,
16207 spec->autocfg.speaker_pins[0],
16208 "Speaker");
16209 if (err < 0)
16210 return err;
16211 err = alc861vd_auto_create_extra_out(spec,
16212 spec->autocfg.hp_pins[0],
16213 "Headphone");
16214 if (err < 0)
16215 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016216 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016217 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016218 return err;
16219
16220 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16221
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016222 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016223 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
16224
Takashi Iwai603c4012008-07-30 15:01:44 +020016225 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016226 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016227
Takashi Iwaid88897e2008-10-31 15:01:37 +010016228 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016229
16230 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016231 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016232
Takashi Iwai776e1842007-08-29 15:07:11 +020016233 err = alc_auto_add_mic_boost(codec);
16234 if (err < 0)
16235 return err;
16236
Kailang Yang6227cdc2010-02-25 08:36:52 +010016237 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016238
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016239 return 1;
16240}
16241
16242/* additional initialization for auto-configuration model */
16243static void alc861vd_auto_init(struct hda_codec *codec)
16244{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016245 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016246 alc861vd_auto_init_multi_out(codec);
16247 alc861vd_auto_init_hp_out(codec);
16248 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016249 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016250 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016251 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016252}
16253
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016254enum {
16255 ALC660VD_FIX_ASUS_GPIO1
16256};
16257
16258/* reset GPIO1 */
16259static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
16260 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
16261 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
16262 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
16263 { }
16264};
16265
16266static const struct alc_fixup alc861vd_fixups[] = {
16267 [ALC660VD_FIX_ASUS_GPIO1] = {
16268 .verbs = alc660vd_fix_asus_gpio1_verbs,
16269 },
16270};
16271
16272static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
16273 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
16274 {}
16275};
16276
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016277static int patch_alc861vd(struct hda_codec *codec)
16278{
16279 struct alc_spec *spec;
16280 int err, board_config;
16281
16282 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16283 if (spec == NULL)
16284 return -ENOMEM;
16285
16286 codec->spec = spec;
16287
16288 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
16289 alc861vd_models,
16290 alc861vd_cfg_tbl);
16291
16292 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016293 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16294 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016295 board_config = ALC861VD_AUTO;
16296 }
16297
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016298 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
16299
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016300 if (board_config == ALC861VD_AUTO) {
16301 /* automatic parse from the BIOS config */
16302 err = alc861vd_parse_auto_config(codec);
16303 if (err < 0) {
16304 alc_free(codec);
16305 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016306 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016307 printk(KERN_INFO
16308 "hda_codec: Cannot set up configuration "
16309 "from BIOS. Using base mode...\n");
16310 board_config = ALC861VD_3ST;
16311 }
16312 }
16313
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016314 err = snd_hda_attach_beep_device(codec, 0x23);
16315 if (err < 0) {
16316 alc_free(codec);
16317 return err;
16318 }
16319
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016320 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016321 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016322
Kailang Yang2f893282008-05-27 12:14:47 +020016323 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020016324 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010016325 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020016326 }
16327
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016328 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
16329 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
16330
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016331 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
16332 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16333
Takashi Iwaidd704692009-08-11 08:45:11 +020016334 if (!spec->adc_nids) {
16335 spec->adc_nids = alc861vd_adc_nids;
16336 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
16337 }
16338 if (!spec->capsrc_nids)
16339 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016340
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016341 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016342 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016343
Takashi Iwai2134ea42008-01-10 16:53:55 +010016344 spec->vmaster_nid = 0x02;
16345
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016346 codec->patch_ops = alc_patch_ops;
16347
16348 if (board_config == ALC861VD_AUTO)
16349 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016350#ifdef CONFIG_SND_HDA_POWER_SAVE
16351 if (!spec->loopback.amplist)
16352 spec->loopback.amplist = alc861vd_loopbacks;
16353#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016354
16355 return 0;
16356}
16357
16358/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016359 * ALC662 support
16360 *
16361 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
16362 * configuration. Each pin widget can choose any input DACs and a mixer.
16363 * Each ADC is connected from a mixer of all inputs. This makes possible
16364 * 6-channel independent captures.
16365 *
16366 * In addition, an independent DAC for the multi-playback (not used in this
16367 * driver yet).
16368 */
16369#define ALC662_DIGOUT_NID 0x06
16370#define ALC662_DIGIN_NID 0x0a
16371
16372static hda_nid_t alc662_dac_nids[4] = {
16373 /* front, rear, clfe, rear_surr */
16374 0x02, 0x03, 0x04
16375};
16376
Kailang Yang622e84c2009-04-21 07:39:04 +020016377static hda_nid_t alc272_dac_nids[2] = {
16378 0x02, 0x03
16379};
16380
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016381static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016382 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016383 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016384};
Takashi Iwaie1406342008-02-11 18:32:32 +010016385
Kailang Yang622e84c2009-04-21 07:39:04 +020016386static hda_nid_t alc272_adc_nids[1] = {
16387 /* ADC1-2 */
16388 0x08,
16389};
16390
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016391static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016392static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
16393
Takashi Iwaie1406342008-02-11 18:32:32 +010016394
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016395/* input MUX */
16396/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016397static struct hda_input_mux alc662_capture_source = {
16398 .num_items = 4,
16399 .items = {
16400 { "Mic", 0x0 },
16401 { "Front Mic", 0x1 },
16402 { "Line", 0x2 },
16403 { "CD", 0x4 },
16404 },
16405};
16406
16407static struct hda_input_mux alc662_lenovo_101e_capture_source = {
16408 .num_items = 2,
16409 .items = {
16410 { "Mic", 0x1 },
16411 { "Line", 0x2 },
16412 },
16413};
Kailang Yang291702f2007-10-16 14:28:03 +020016414
Kailang Yang6dda9f42008-05-27 12:05:31 +020016415static struct hda_input_mux alc663_capture_source = {
16416 .num_items = 3,
16417 .items = {
16418 { "Mic", 0x0 },
16419 { "Front Mic", 0x1 },
16420 { "Line", 0x2 },
16421 },
16422};
16423
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016424#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020016425static struct hda_input_mux alc272_nc10_capture_source = {
16426 .num_items = 16,
16427 .items = {
16428 { "Autoselect Mic", 0x0 },
16429 { "Internal Mic", 0x1 },
16430 { "In-0x02", 0x2 },
16431 { "In-0x03", 0x3 },
16432 { "In-0x04", 0x4 },
16433 { "In-0x05", 0x5 },
16434 { "In-0x06", 0x6 },
16435 { "In-0x07", 0x7 },
16436 { "In-0x08", 0x8 },
16437 { "In-0x09", 0x9 },
16438 { "In-0x0a", 0x0a },
16439 { "In-0x0b", 0x0b },
16440 { "In-0x0c", 0x0c },
16441 { "In-0x0d", 0x0d },
16442 { "In-0x0e", 0x0e },
16443 { "In-0x0f", 0x0f },
16444 },
16445};
16446#endif
16447
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016448/*
16449 * 2ch mode
16450 */
16451static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
16452 { 2, NULL }
16453};
16454
16455/*
16456 * 2ch mode
16457 */
16458static struct hda_verb alc662_3ST_ch2_init[] = {
16459 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
16460 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16461 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
16462 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16463 { } /* end */
16464};
16465
16466/*
16467 * 6ch mode
16468 */
16469static struct hda_verb alc662_3ST_ch6_init[] = {
16470 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16471 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16472 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
16473 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16474 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16475 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
16476 { } /* end */
16477};
16478
16479static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
16480 { 2, alc662_3ST_ch2_init },
16481 { 6, alc662_3ST_ch6_init },
16482};
16483
16484/*
16485 * 2ch mode
16486 */
16487static struct hda_verb alc662_sixstack_ch6_init[] = {
16488 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16489 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16490 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16491 { } /* end */
16492};
16493
16494/*
16495 * 6ch mode
16496 */
16497static struct hda_verb alc662_sixstack_ch8_init[] = {
16498 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16499 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16500 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16501 { } /* end */
16502};
16503
16504static struct hda_channel_mode alc662_5stack_modes[2] = {
16505 { 2, alc662_sixstack_ch6_init },
16506 { 6, alc662_sixstack_ch8_init },
16507};
16508
16509/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16510 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16511 */
16512
16513static struct snd_kcontrol_new alc662_base_mixer[] = {
16514 /* output mixer control */
16515 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016516 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016517 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016518 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016519 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16520 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016521 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16522 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016523 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16524
16525 /*Input mixer control */
16526 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
16527 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
16528 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
16529 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
16530 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
16531 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
16532 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
16533 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016534 { } /* end */
16535};
16536
16537static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
16538 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016539 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016540 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16541 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16542 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16543 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16544 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16546 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16547 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16548 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016549 { } /* end */
16550};
16551
16552static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
16553 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016554 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016555 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016556 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016557 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16558 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016559 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16560 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016561 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16562 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16563 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16564 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16565 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16566 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16567 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16568 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16569 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016570 { } /* end */
16571};
16572
16573static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16574 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16575 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016576 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16577 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016578 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16579 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16580 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16581 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16582 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016583 { } /* end */
16584};
16585
Kailang Yang291702f2007-10-16 14:28:03 +020016586static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016587 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16588 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016589
16590 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16591 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16592 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16593
16594 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16595 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16596 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16597 { } /* end */
16598};
16599
Kailang Yang8c427222008-01-10 13:03:59 +010016600static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016601 ALC262_HIPPO_MASTER_SWITCH,
16602 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016603 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016604 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16605 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016606 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16607 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16608 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16609 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16610 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16611 { } /* end */
16612};
16613
Kailang Yangf1d4e282008-08-26 14:03:29 +020016614static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16615 .ops = &snd_hda_bind_vol,
16616 .values = {
16617 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16618 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16619 0
16620 },
16621};
16622
16623static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16624 .ops = &snd_hda_bind_sw,
16625 .values = {
16626 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16627 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16628 0
16629 },
16630};
16631
Kailang Yang6dda9f42008-05-27 12:05:31 +020016632static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016633 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16634 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16635 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16636 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16637 { } /* end */
16638};
16639
16640static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16641 .ops = &snd_hda_bind_sw,
16642 .values = {
16643 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16644 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16645 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16646 0
16647 },
16648};
16649
16650static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16651 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16652 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16653 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16654 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16655 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16656 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16657
16658 { } /* end */
16659};
16660
16661static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16662 .ops = &snd_hda_bind_sw,
16663 .values = {
16664 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16665 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16666 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16667 0
16668 },
16669};
16670
16671static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16672 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16673 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16674 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16675 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16676 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16677 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16678 { } /* end */
16679};
16680
16681static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016682 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16683 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016684 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16685 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16686 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16687 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16688 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16689 { } /* end */
16690};
16691
16692static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16693 .ops = &snd_hda_bind_vol,
16694 .values = {
16695 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16696 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16697 0
16698 },
16699};
16700
16701static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16702 .ops = &snd_hda_bind_sw,
16703 .values = {
16704 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16705 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16706 0
16707 },
16708};
16709
16710static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16711 HDA_BIND_VOL("Master Playback Volume",
16712 &alc663_asus_two_bind_master_vol),
16713 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16714 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016715 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16716 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16717 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016718 { } /* end */
16719};
16720
16721static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16722 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16723 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16724 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16725 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16726 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16727 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016728 { } /* end */
16729};
16730
16731static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16732 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16733 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16734 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16735 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16736 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16737
16738 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16739 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16740 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16741 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16742 { } /* end */
16743};
16744
16745static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16746 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16747 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16748 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16749
16750 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16751 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16752 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16753 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16754 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16755 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16756 { } /* end */
16757};
16758
Kailang Yangebb83ee2009-12-17 12:23:00 +010016759static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
16760 .ops = &snd_hda_bind_sw,
16761 .values = {
16762 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16763 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16764 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16765 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16766 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16767 0
16768 },
16769};
16770
16771static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
16772 .ops = &snd_hda_bind_sw,
16773 .values = {
16774 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16775 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16776 0
16777 },
16778};
16779
16780static struct snd_kcontrol_new alc663_mode7_mixer[] = {
16781 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16782 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16783 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16784 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16785 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16786 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16787 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16788 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16789 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16790 { } /* end */
16791};
16792
16793static struct snd_kcontrol_new alc663_mode8_mixer[] = {
16794 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16795 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16796 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16797 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16798 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16799 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16800 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16801 { } /* end */
16802};
16803
16804
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016805static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16806 {
16807 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16808 .name = "Channel Mode",
16809 .info = alc_ch_mode_info,
16810 .get = alc_ch_mode_get,
16811 .put = alc_ch_mode_put,
16812 },
16813 { } /* end */
16814};
16815
16816static struct hda_verb alc662_init_verbs[] = {
16817 /* ADC: mute amp left and right */
16818 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16819 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016820
Kailang Yangb60dd392007-09-20 12:50:29 +020016821 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16822 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16823 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16824 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16825 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16826 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016827
16828 /* Front Pin: output 0 (0x0c) */
16829 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16830 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16831
16832 /* Rear Pin: output 1 (0x0d) */
16833 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16834 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16835
16836 /* CLFE Pin: output 2 (0x0e) */
16837 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16838 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16839
16840 /* Mic (rear) pin: input vref at 80% */
16841 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16842 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16843 /* Front Mic pin: input vref at 80% */
16844 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16845 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16846 /* Line In pin: input */
16847 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16848 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16849 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16850 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16851 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16852 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16853 /* CD pin widget for input */
16854 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16855
16856 /* FIXME: use matrix-type input source selection */
16857 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16858 /* Input mixer */
16859 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016860 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016861
16862 /* always trun on EAPD */
16863 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16864 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16865
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016866 { }
16867};
16868
Kailang Yangcec27c82010-02-04 14:18:18 +010016869static struct hda_verb alc663_init_verbs[] = {
16870 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16871 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16872 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16873 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16874 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16875 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16876 { }
16877};
16878
16879static struct hda_verb alc272_init_verbs[] = {
16880 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16881 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16882 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16883 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16884 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16885 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16886 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16887 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16888 { }
16889};
16890
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016891static struct hda_verb alc662_sue_init_verbs[] = {
16892 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16893 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016894 {}
16895};
16896
16897static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16898 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16899 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16900 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016901};
16902
Kailang Yang8c427222008-01-10 13:03:59 +010016903/* Set Unsolicited Event*/
16904static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16905 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16906 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16907 {}
16908};
16909
Kailang Yang6dda9f42008-05-27 12:05:31 +020016910static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016911 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16912 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016913 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16914 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016915 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16916 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16917 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016918 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16919 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16920 {}
16921};
16922
Kailang Yangf1d4e282008-08-26 14:03:29 +020016923static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16924 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16925 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16926 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16927 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16928 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16929 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16930 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16931 {}
16932};
16933
16934static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16935 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16936 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16937 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16938 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16939 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16940 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16941 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16942 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16943 {}
16944};
16945
16946static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16947 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16948 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16949 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16950 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16951 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16952 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16953 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16954 {}
16955};
16956
16957static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16958 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16959 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16960 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16961 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16962 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16963 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16964 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16965 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16966 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16967 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16968 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16969 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16970 {}
16971};
16972
16973static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16974 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16975 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16976 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16977 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16978 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16979 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16980 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16981 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16982 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16983 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16984 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16985 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16986 {}
16987};
16988
Kailang Yang6dda9f42008-05-27 12:05:31 +020016989static struct hda_verb alc663_g71v_init_verbs[] = {
16990 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16991 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16992 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16993
16994 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16995 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16996 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16997
16998 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16999 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17000 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17001 {}
17002};
17003
17004static struct hda_verb alc663_g50v_init_verbs[] = {
17005 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17006 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17007 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17008
17009 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17010 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17011 {}
17012};
17013
Kailang Yangf1d4e282008-08-26 14:03:29 +020017014static struct hda_verb alc662_ecs_init_verbs[] = {
17015 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17016 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17017 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17018 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17019 {}
17020};
17021
Kailang Yang622e84c2009-04-21 07:39:04 +020017022static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17023 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17024 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17025 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17026 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17027 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17028 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17029 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17030 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17031 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17032 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17033 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17034 {}
17035};
17036
17037static struct hda_verb alc272_dell_init_verbs[] = {
17038 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17039 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17040 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17041 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17042 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17043 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17044 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17045 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17046 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17047 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17048 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17049 {}
17050};
17051
Kailang Yangebb83ee2009-12-17 12:23:00 +010017052static struct hda_verb alc663_mode7_init_verbs[] = {
17053 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17054 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17055 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17056 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17057 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17058 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17059 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17060 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17061 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17062 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17063 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17064 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17065 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17066 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17067 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17068 {}
17069};
17070
17071static struct hda_verb alc663_mode8_init_verbs[] = {
17072 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17073 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17074 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17075 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17076 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17077 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17078 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17079 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17080 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17081 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17082 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17083 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17084 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17085 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17086 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17087 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17088 {}
17089};
17090
Kailang Yangf1d4e282008-08-26 14:03:29 +020017091static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17092 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17093 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17094 { } /* end */
17095};
17096
Kailang Yang622e84c2009-04-21 07:39:04 +020017097static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17098 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17099 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17100 { } /* end */
17101};
17102
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017103static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17104{
17105 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017106 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017107
Wu Fengguang864f92b2009-11-18 12:38:02 +080017108 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017109 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017110
Takashi Iwai47fd8302007-08-10 17:11:07 +020017111 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17112 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017113}
17114
17115static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17116{
17117 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017118 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017119
Wu Fengguang864f92b2009-11-18 12:38:02 +080017120 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017121 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017122
Takashi Iwai47fd8302007-08-10 17:11:07 +020017123 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17124 HDA_AMP_MUTE, bits);
17125 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17126 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017127}
17128
17129static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17130 unsigned int res)
17131{
17132 if ((res >> 26) == ALC880_HP_EVENT)
17133 alc662_lenovo_101e_all_automute(codec);
17134 if ((res >> 26) == ALC880_FRONT_EVENT)
17135 alc662_lenovo_101e_ispeaker_automute(codec);
17136}
17137
Kailang Yang291702f2007-10-16 14:28:03 +020017138/* unsolicited event for HP jack sensing */
17139static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17140 unsigned int res)
17141{
Kailang Yang291702f2007-10-16 14:28:03 +020017142 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017143 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017144 else
17145 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017146}
17147
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017148static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017149{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017150 struct alc_spec *spec = codec->spec;
17151
17152 alc262_hippo1_setup(codec);
17153 spec->ext_mic.pin = 0x18;
17154 spec->ext_mic.mux_idx = 0;
17155 spec->int_mic.pin = 0x19;
17156 spec->int_mic.mux_idx = 1;
17157 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017158}
17159
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017160static void alc662_eeepc_inithook(struct hda_codec *codec)
17161{
17162 alc262_hippo_automute(codec);
17163 alc_mic_automute(codec);
17164}
17165
17166static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017167{
Takashi Iwai42171c12009-05-08 14:11:43 +020017168 struct alc_spec *spec = codec->spec;
17169
17170 spec->autocfg.hp_pins[0] = 0x14;
17171 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017172}
17173
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017174#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17175
Kailang Yang6dda9f42008-05-27 12:05:31 +020017176static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17177{
17178 unsigned int present;
17179 unsigned char bits;
17180
Wu Fengguang864f92b2009-11-18 12:38:02 +080017181 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017182 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017183 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017184 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017185 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017186 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017187}
17188
17189static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17190{
17191 unsigned int present;
17192 unsigned char bits;
17193
Wu Fengguang864f92b2009-11-18 12:38:02 +080017194 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017195 bits = present ? HDA_AMP_MUTE : 0;
17196 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017197 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017198 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017199 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017200 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017201 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017202 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017203 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017204}
17205
17206static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
17207{
17208 unsigned int present;
17209 unsigned char bits;
17210
Wu Fengguang864f92b2009-11-18 12:38:02 +080017211 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017212 bits = present ? HDA_AMP_MUTE : 0;
17213 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017214 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017215 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017216 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017217 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017218 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017219 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017220 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017221}
17222
17223static void alc662_f5z_speaker_automute(struct hda_codec *codec)
17224{
17225 unsigned int present;
17226 unsigned char bits;
17227
Wu Fengguang864f92b2009-11-18 12:38:02 +080017228 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017229 bits = present ? 0 : PIN_OUT;
17230 snd_hda_codec_write(codec, 0x14, 0,
17231 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
17232}
17233
17234static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
17235{
17236 unsigned int present1, present2;
17237
Wu Fengguang864f92b2009-11-18 12:38:02 +080017238 present1 = snd_hda_jack_detect(codec, 0x21);
17239 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017240
17241 if (present1 || present2) {
17242 snd_hda_codec_write_cache(codec, 0x14, 0,
17243 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17244 } else {
17245 snd_hda_codec_write_cache(codec, 0x14, 0,
17246 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17247 }
17248}
17249
17250static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
17251{
17252 unsigned int present1, present2;
17253
Wu Fengguang864f92b2009-11-18 12:38:02 +080017254 present1 = snd_hda_jack_detect(codec, 0x1b);
17255 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017256
17257 if (present1 || present2) {
17258 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017259 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017260 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017261 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017262 } else {
17263 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017264 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017265 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017266 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017267 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020017268}
17269
Kailang Yangebb83ee2009-12-17 12:23:00 +010017270static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
17271{
17272 unsigned int present1, present2;
17273
17274 present1 = snd_hda_codec_read(codec, 0x1b, 0,
17275 AC_VERB_GET_PIN_SENSE, 0)
17276 & AC_PINSENSE_PRESENCE;
17277 present2 = snd_hda_codec_read(codec, 0x21, 0,
17278 AC_VERB_GET_PIN_SENSE, 0)
17279 & AC_PINSENSE_PRESENCE;
17280
17281 if (present1 || present2) {
17282 snd_hda_codec_write_cache(codec, 0x14, 0,
17283 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17284 snd_hda_codec_write_cache(codec, 0x17, 0,
17285 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17286 } else {
17287 snd_hda_codec_write_cache(codec, 0x14, 0,
17288 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17289 snd_hda_codec_write_cache(codec, 0x17, 0,
17290 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17291 }
17292}
17293
17294static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
17295{
17296 unsigned int present1, present2;
17297
17298 present1 = snd_hda_codec_read(codec, 0x21, 0,
17299 AC_VERB_GET_PIN_SENSE, 0)
17300 & AC_PINSENSE_PRESENCE;
17301 present2 = snd_hda_codec_read(codec, 0x15, 0,
17302 AC_VERB_GET_PIN_SENSE, 0)
17303 & AC_PINSENSE_PRESENCE;
17304
17305 if (present1 || present2) {
17306 snd_hda_codec_write_cache(codec, 0x14, 0,
17307 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17308 snd_hda_codec_write_cache(codec, 0x17, 0,
17309 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17310 } else {
17311 snd_hda_codec_write_cache(codec, 0x14, 0,
17312 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17313 snd_hda_codec_write_cache(codec, 0x17, 0,
17314 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17315 }
17316}
17317
Kailang Yang6dda9f42008-05-27 12:05:31 +020017318static void alc663_m51va_unsol_event(struct hda_codec *codec,
17319 unsigned int res)
17320{
17321 switch (res >> 26) {
17322 case ALC880_HP_EVENT:
17323 alc663_m51va_speaker_automute(codec);
17324 break;
17325 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017326 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017327 break;
17328 }
17329}
17330
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017331static void alc663_m51va_setup(struct hda_codec *codec)
17332{
17333 struct alc_spec *spec = codec->spec;
17334 spec->ext_mic.pin = 0x18;
17335 spec->ext_mic.mux_idx = 0;
17336 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017337 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017338 spec->auto_mic = 1;
17339}
17340
Kailang Yang6dda9f42008-05-27 12:05:31 +020017341static void alc663_m51va_inithook(struct hda_codec *codec)
17342{
17343 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017344 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017345}
17346
Kailang Yangf1d4e282008-08-26 14:03:29 +020017347/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017348#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010017349
17350static void alc663_mode1_setup(struct hda_codec *codec)
17351{
17352 struct alc_spec *spec = codec->spec;
17353 spec->ext_mic.pin = 0x18;
17354 spec->ext_mic.mux_idx = 0;
17355 spec->int_mic.pin = 0x19;
17356 spec->int_mic.mux_idx = 1;
17357 spec->auto_mic = 1;
17358}
17359
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017360#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020017361
Kailang Yangf1d4e282008-08-26 14:03:29 +020017362/* ***************** Mode2 ******************************/
17363static void alc662_mode2_unsol_event(struct hda_codec *codec,
17364 unsigned int res)
17365{
17366 switch (res >> 26) {
17367 case ALC880_HP_EVENT:
17368 alc662_f5z_speaker_automute(codec);
17369 break;
17370 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017371 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017372 break;
17373 }
17374}
17375
Kailang Yangebb83ee2009-12-17 12:23:00 +010017376#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017377
Kailang Yangf1d4e282008-08-26 14:03:29 +020017378static void alc662_mode2_inithook(struct hda_codec *codec)
17379{
17380 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017381 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017382}
17383/* ***************** Mode3 ******************************/
17384static void alc663_mode3_unsol_event(struct hda_codec *codec,
17385 unsigned int res)
17386{
17387 switch (res >> 26) {
17388 case ALC880_HP_EVENT:
17389 alc663_two_hp_m1_speaker_automute(codec);
17390 break;
17391 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017392 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017393 break;
17394 }
17395}
17396
Kailang Yangebb83ee2009-12-17 12:23:00 +010017397#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017398
Kailang Yangf1d4e282008-08-26 14:03:29 +020017399static void alc663_mode3_inithook(struct hda_codec *codec)
17400{
17401 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017402 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017403}
17404/* ***************** Mode4 ******************************/
17405static void alc663_mode4_unsol_event(struct hda_codec *codec,
17406 unsigned int res)
17407{
17408 switch (res >> 26) {
17409 case ALC880_HP_EVENT:
17410 alc663_21jd_two_speaker_automute(codec);
17411 break;
17412 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017413 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017414 break;
17415 }
17416}
17417
Kailang Yangebb83ee2009-12-17 12:23:00 +010017418#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017419
Kailang Yangf1d4e282008-08-26 14:03:29 +020017420static void alc663_mode4_inithook(struct hda_codec *codec)
17421{
17422 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017423 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017424}
17425/* ***************** Mode5 ******************************/
17426static void alc663_mode5_unsol_event(struct hda_codec *codec,
17427 unsigned int res)
17428{
17429 switch (res >> 26) {
17430 case ALC880_HP_EVENT:
17431 alc663_15jd_two_speaker_automute(codec);
17432 break;
17433 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017434 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017435 break;
17436 }
17437}
17438
Kailang Yangebb83ee2009-12-17 12:23:00 +010017439#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017440
Kailang Yangf1d4e282008-08-26 14:03:29 +020017441static void alc663_mode5_inithook(struct hda_codec *codec)
17442{
17443 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017444 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017445}
17446/* ***************** Mode6 ******************************/
17447static void alc663_mode6_unsol_event(struct hda_codec *codec,
17448 unsigned int res)
17449{
17450 switch (res >> 26) {
17451 case ALC880_HP_EVENT:
17452 alc663_two_hp_m2_speaker_automute(codec);
17453 break;
17454 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017455 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017456 break;
17457 }
17458}
17459
Kailang Yangebb83ee2009-12-17 12:23:00 +010017460#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017461
Kailang Yangf1d4e282008-08-26 14:03:29 +020017462static void alc663_mode6_inithook(struct hda_codec *codec)
17463{
17464 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017465 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017466}
17467
Kailang Yangebb83ee2009-12-17 12:23:00 +010017468/* ***************** Mode7 ******************************/
17469static void alc663_mode7_unsol_event(struct hda_codec *codec,
17470 unsigned int res)
17471{
17472 switch (res >> 26) {
17473 case ALC880_HP_EVENT:
17474 alc663_two_hp_m7_speaker_automute(codec);
17475 break;
17476 case ALC880_MIC_EVENT:
17477 alc_mic_automute(codec);
17478 break;
17479 }
17480}
17481
17482#define alc663_mode7_setup alc663_mode1_setup
17483
17484static void alc663_mode7_inithook(struct hda_codec *codec)
17485{
17486 alc663_two_hp_m7_speaker_automute(codec);
17487 alc_mic_automute(codec);
17488}
17489
17490/* ***************** Mode8 ******************************/
17491static void alc663_mode8_unsol_event(struct hda_codec *codec,
17492 unsigned int res)
17493{
17494 switch (res >> 26) {
17495 case ALC880_HP_EVENT:
17496 alc663_two_hp_m8_speaker_automute(codec);
17497 break;
17498 case ALC880_MIC_EVENT:
17499 alc_mic_automute(codec);
17500 break;
17501 }
17502}
17503
17504#define alc663_mode8_setup alc663_m51va_setup
17505
17506static void alc663_mode8_inithook(struct hda_codec *codec)
17507{
17508 alc663_two_hp_m8_speaker_automute(codec);
17509 alc_mic_automute(codec);
17510}
17511
Kailang Yang6dda9f42008-05-27 12:05:31 +020017512static void alc663_g71v_hp_automute(struct hda_codec *codec)
17513{
17514 unsigned int present;
17515 unsigned char bits;
17516
Wu Fengguang864f92b2009-11-18 12:38:02 +080017517 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017518 bits = present ? HDA_AMP_MUTE : 0;
17519 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17520 HDA_AMP_MUTE, bits);
17521 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17522 HDA_AMP_MUTE, bits);
17523}
17524
17525static void alc663_g71v_front_automute(struct hda_codec *codec)
17526{
17527 unsigned int present;
17528 unsigned char bits;
17529
Wu Fengguang864f92b2009-11-18 12:38:02 +080017530 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017531 bits = present ? HDA_AMP_MUTE : 0;
17532 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17533 HDA_AMP_MUTE, bits);
17534}
17535
17536static void alc663_g71v_unsol_event(struct hda_codec *codec,
17537 unsigned int res)
17538{
17539 switch (res >> 26) {
17540 case ALC880_HP_EVENT:
17541 alc663_g71v_hp_automute(codec);
17542 break;
17543 case ALC880_FRONT_EVENT:
17544 alc663_g71v_front_automute(codec);
17545 break;
17546 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017547 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017548 break;
17549 }
17550}
17551
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017552#define alc663_g71v_setup alc663_m51va_setup
17553
Kailang Yang6dda9f42008-05-27 12:05:31 +020017554static void alc663_g71v_inithook(struct hda_codec *codec)
17555{
17556 alc663_g71v_front_automute(codec);
17557 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017558 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017559}
17560
17561static void alc663_g50v_unsol_event(struct hda_codec *codec,
17562 unsigned int res)
17563{
17564 switch (res >> 26) {
17565 case ALC880_HP_EVENT:
17566 alc663_m51va_speaker_automute(codec);
17567 break;
17568 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017569 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017570 break;
17571 }
17572}
17573
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017574#define alc663_g50v_setup alc663_m51va_setup
17575
Kailang Yang6dda9f42008-05-27 12:05:31 +020017576static void alc663_g50v_inithook(struct hda_codec *codec)
17577{
17578 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017579 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017580}
17581
Kailang Yangf1d4e282008-08-26 14:03:29 +020017582static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17583 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017584 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017585
17586 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17587 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17588 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17589
17590 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17591 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17592 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17593 { } /* end */
17594};
17595
Chris Pockelé9541ba12009-05-12 08:08:53 +020017596static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17597 /* Master Playback automatically created from Speaker and Headphone */
17598 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17599 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17600 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17601 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17602
17603 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17604 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17605 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17606
17607 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17608 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17609 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17610 { } /* end */
17611};
17612
Takashi Iwaicb53c622007-08-10 17:21:45 +020017613#ifdef CONFIG_SND_HDA_POWER_SAVE
17614#define alc662_loopbacks alc880_loopbacks
17615#endif
17616
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017617
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017618/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017619#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17620#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17621#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17622#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17623
17624/*
17625 * configuration and preset
17626 */
17627static const char *alc662_models[ALC662_MODEL_LAST] = {
17628 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17629 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17630 [ALC662_3ST_6ch] = "3stack-6ch",
17631 [ALC662_5ST_DIG] = "6stack-dig",
17632 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017633 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017634 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017635 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017636 [ALC663_ASUS_M51VA] = "m51va",
17637 [ALC663_ASUS_G71V] = "g71v",
17638 [ALC663_ASUS_H13] = "h13",
17639 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017640 [ALC663_ASUS_MODE1] = "asus-mode1",
17641 [ALC662_ASUS_MODE2] = "asus-mode2",
17642 [ALC663_ASUS_MODE3] = "asus-mode3",
17643 [ALC663_ASUS_MODE4] = "asus-mode4",
17644 [ALC663_ASUS_MODE5] = "asus-mode5",
17645 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017646 [ALC663_ASUS_MODE7] = "asus-mode7",
17647 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017648 [ALC272_DELL] = "dell",
17649 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017650 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017651 [ALC662_AUTO] = "auto",
17652};
17653
17654static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017655 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017656 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17657 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017658 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17659 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010017660 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017661 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17662 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17663 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17664 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017665 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17666 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017667 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017668 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17669 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17670 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17671 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17672 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017673 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017674 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17675 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017676 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17677 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17678 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17679 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017680 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017681 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17682 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17683 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017684 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17685 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17686 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17687 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017688 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017689 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17690 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017691 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017692 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17693 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17694 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017695 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010017696 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017697 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17698 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017699 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17700 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17701 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017702 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017703 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17704 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017705 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017706 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017707 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017708 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17709 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17710 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017711 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017712 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17713 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017714 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017715 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017716 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017717 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017718 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17719 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010017720 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017721 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030017722 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17723 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010017724 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017725 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017726 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017727 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020017728 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020017729 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017730 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17731 ALC663_ASUS_H13),
David Santinoli7aee6742009-12-09 12:34:26 +010017732 SND_PCI_QUIRK(0x8086, 0xd604, "Intel mobo", ALC662_3ST_2ch_DIG),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017733 {}
17734};
17735
17736static struct alc_config_preset alc662_presets[] = {
17737 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017738 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017739 .init_verbs = { alc662_init_verbs },
17740 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17741 .dac_nids = alc662_dac_nids,
17742 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017743 .dig_in_nid = ALC662_DIGIN_NID,
17744 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17745 .channel_mode = alc662_3ST_2ch_modes,
17746 .input_mux = &alc662_capture_source,
17747 },
17748 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017749 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017750 .init_verbs = { alc662_init_verbs },
17751 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17752 .dac_nids = alc662_dac_nids,
17753 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017754 .dig_in_nid = ALC662_DIGIN_NID,
17755 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17756 .channel_mode = alc662_3ST_6ch_modes,
17757 .need_dac_fix = 1,
17758 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017759 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017760 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017761 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017762 .init_verbs = { alc662_init_verbs },
17763 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17764 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017765 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17766 .channel_mode = alc662_3ST_6ch_modes,
17767 .need_dac_fix = 1,
17768 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017769 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017770 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017771 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017772 .init_verbs = { alc662_init_verbs },
17773 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17774 .dac_nids = alc662_dac_nids,
17775 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017776 .dig_in_nid = ALC662_DIGIN_NID,
17777 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
17778 .channel_mode = alc662_5stack_modes,
17779 .input_mux = &alc662_capture_source,
17780 },
17781 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017782 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017783 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
17784 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17785 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017786 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17787 .channel_mode = alc662_3ST_2ch_modes,
17788 .input_mux = &alc662_lenovo_101e_capture_source,
17789 .unsol_event = alc662_lenovo_101e_unsol_event,
17790 .init_hook = alc662_lenovo_101e_all_automute,
17791 },
Kailang Yang291702f2007-10-16 14:28:03 +020017792 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017793 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020017794 .init_verbs = { alc662_init_verbs,
17795 alc662_eeepc_sue_init_verbs },
17796 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17797 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020017798 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17799 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020017800 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017801 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020017802 .init_hook = alc662_eeepc_inithook,
17803 },
Kailang Yang8c427222008-01-10 13:03:59 +010017804 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017805 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010017806 alc662_chmode_mixer },
17807 .init_verbs = { alc662_init_verbs,
17808 alc662_eeepc_ep20_sue_init_verbs },
17809 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17810 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010017811 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17812 .channel_mode = alc662_3ST_6ch_modes,
17813 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020017814 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017815 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010017816 .init_hook = alc662_eeepc_ep20_inithook,
17817 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017818 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017819 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017820 .init_verbs = { alc662_init_verbs,
17821 alc662_ecs_init_verbs },
17822 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17823 .dac_nids = alc662_dac_nids,
17824 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17825 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017826 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017827 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017828 .init_hook = alc662_eeepc_inithook,
17829 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017830 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017831 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017832 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17833 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17834 .dac_nids = alc662_dac_nids,
17835 .dig_out_nid = ALC662_DIGOUT_NID,
17836 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17837 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017838 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017839 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017840 .init_hook = alc663_m51va_inithook,
17841 },
17842 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017843 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017844 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17845 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17846 .dac_nids = alc662_dac_nids,
17847 .dig_out_nid = ALC662_DIGOUT_NID,
17848 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17849 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017850 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017851 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017852 .init_hook = alc663_g71v_inithook,
17853 },
17854 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017855 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017856 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17857 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17858 .dac_nids = alc662_dac_nids,
17859 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17860 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017861 .unsol_event = alc663_m51va_unsol_event,
17862 .init_hook = alc663_m51va_inithook,
17863 },
17864 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017865 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017866 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17867 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17868 .dac_nids = alc662_dac_nids,
17869 .dig_out_nid = ALC662_DIGOUT_NID,
17870 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17871 .channel_mode = alc662_3ST_6ch_modes,
17872 .input_mux = &alc663_capture_source,
17873 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017874 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017875 .init_hook = alc663_g50v_inithook,
17876 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017877 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017878 .mixers = { alc663_m51va_mixer },
17879 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017880 .init_verbs = { alc662_init_verbs,
17881 alc663_21jd_amic_init_verbs },
17882 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17883 .hp_nid = 0x03,
17884 .dac_nids = alc662_dac_nids,
17885 .dig_out_nid = ALC662_DIGOUT_NID,
17886 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17887 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017888 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017889 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017890 .init_hook = alc663_mode1_inithook,
17891 },
17892 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017893 .mixers = { alc662_1bjd_mixer },
17894 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017895 .init_verbs = { alc662_init_verbs,
17896 alc662_1bjd_amic_init_verbs },
17897 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17898 .dac_nids = alc662_dac_nids,
17899 .dig_out_nid = ALC662_DIGOUT_NID,
17900 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17901 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017902 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017903 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017904 .init_hook = alc662_mode2_inithook,
17905 },
17906 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017907 .mixers = { alc663_two_hp_m1_mixer },
17908 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017909 .init_verbs = { alc662_init_verbs,
17910 alc663_two_hp_amic_m1_init_verbs },
17911 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17912 .hp_nid = 0x03,
17913 .dac_nids = alc662_dac_nids,
17914 .dig_out_nid = ALC662_DIGOUT_NID,
17915 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17916 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017917 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017918 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017919 .init_hook = alc663_mode3_inithook,
17920 },
17921 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017922 .mixers = { alc663_asus_21jd_clfe_mixer },
17923 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017924 .init_verbs = { alc662_init_verbs,
17925 alc663_21jd_amic_init_verbs},
17926 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17927 .hp_nid = 0x03,
17928 .dac_nids = alc662_dac_nids,
17929 .dig_out_nid = ALC662_DIGOUT_NID,
17930 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17931 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017932 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017933 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017934 .init_hook = alc663_mode4_inithook,
17935 },
17936 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017937 .mixers = { alc663_asus_15jd_clfe_mixer },
17938 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017939 .init_verbs = { alc662_init_verbs,
17940 alc663_15jd_amic_init_verbs },
17941 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17942 .hp_nid = 0x03,
17943 .dac_nids = alc662_dac_nids,
17944 .dig_out_nid = ALC662_DIGOUT_NID,
17945 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17946 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017947 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017948 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017949 .init_hook = alc663_mode5_inithook,
17950 },
17951 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017952 .mixers = { alc663_two_hp_m2_mixer },
17953 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017954 .init_verbs = { alc662_init_verbs,
17955 alc663_two_hp_amic_m2_init_verbs },
17956 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17957 .hp_nid = 0x03,
17958 .dac_nids = alc662_dac_nids,
17959 .dig_out_nid = ALC662_DIGOUT_NID,
17960 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17961 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017962 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017963 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017964 .init_hook = alc663_mode6_inithook,
17965 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017966 [ALC663_ASUS_MODE7] = {
17967 .mixers = { alc663_mode7_mixer },
17968 .cap_mixer = alc662_auto_capture_mixer,
17969 .init_verbs = { alc662_init_verbs,
17970 alc663_mode7_init_verbs },
17971 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17972 .hp_nid = 0x03,
17973 .dac_nids = alc662_dac_nids,
17974 .dig_out_nid = ALC662_DIGOUT_NID,
17975 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17976 .channel_mode = alc662_3ST_2ch_modes,
17977 .unsol_event = alc663_mode7_unsol_event,
17978 .setup = alc663_mode7_setup,
17979 .init_hook = alc663_mode7_inithook,
17980 },
17981 [ALC663_ASUS_MODE8] = {
17982 .mixers = { alc663_mode8_mixer },
17983 .cap_mixer = alc662_auto_capture_mixer,
17984 .init_verbs = { alc662_init_verbs,
17985 alc663_mode8_init_verbs },
17986 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17987 .hp_nid = 0x03,
17988 .dac_nids = alc662_dac_nids,
17989 .dig_out_nid = ALC662_DIGOUT_NID,
17990 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17991 .channel_mode = alc662_3ST_2ch_modes,
17992 .unsol_event = alc663_mode8_unsol_event,
17993 .setup = alc663_mode8_setup,
17994 .init_hook = alc663_mode8_inithook,
17995 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017996 [ALC272_DELL] = {
17997 .mixers = { alc663_m51va_mixer },
17998 .cap_mixer = alc272_auto_capture_mixer,
17999 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18000 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18001 .dac_nids = alc662_dac_nids,
18002 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18003 .adc_nids = alc272_adc_nids,
18004 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18005 .capsrc_nids = alc272_capsrc_nids,
18006 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018007 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018008 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018009 .init_hook = alc663_m51va_inithook,
18010 },
18011 [ALC272_DELL_ZM1] = {
18012 .mixers = { alc663_m51va_mixer },
18013 .cap_mixer = alc662_auto_capture_mixer,
18014 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18015 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18016 .dac_nids = alc662_dac_nids,
18017 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18018 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018019 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018020 .capsrc_nids = alc662_capsrc_nids,
18021 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018022 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018023 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018024 .init_hook = alc663_m51va_inithook,
18025 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018026 [ALC272_SAMSUNG_NC10] = {
18027 .mixers = { alc272_nc10_mixer },
18028 .init_verbs = { alc662_init_verbs,
18029 alc663_21jd_amic_init_verbs },
18030 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18031 .dac_nids = alc272_dac_nids,
18032 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18033 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018034 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018035 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018036 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018037 .init_hook = alc663_mode4_inithook,
18038 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018039};
18040
18041
18042/*
18043 * BIOS auto configuration
18044 */
18045
Takashi Iwai7085ec12009-10-02 09:03:58 +020018046/* convert from MIX nid to DAC */
18047static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18048{
18049 if (nid == 0x0f)
18050 return 0x02;
18051 else if (nid >= 0x0c && nid <= 0x0e)
18052 return nid - 0x0c + 0x02;
18053 else
18054 return 0;
18055}
18056
18057/* get MIX nid connected to the given pin targeted to DAC */
18058static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18059 hda_nid_t dac)
18060{
18061 hda_nid_t mix[4];
18062 int i, num;
18063
18064 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18065 for (i = 0; i < num; i++) {
18066 if (alc662_mix_to_dac(mix[i]) == dac)
18067 return mix[i];
18068 }
18069 return 0;
18070}
18071
18072/* look for an empty DAC slot */
18073static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18074{
18075 struct alc_spec *spec = codec->spec;
18076 hda_nid_t srcs[5];
18077 int i, j, num;
18078
18079 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18080 if (num < 0)
18081 return 0;
18082 for (i = 0; i < num; i++) {
18083 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18084 if (!nid)
18085 continue;
18086 for (j = 0; j < spec->multiout.num_dacs; j++)
18087 if (spec->multiout.dac_nids[j] == nid)
18088 break;
18089 if (j >= spec->multiout.num_dacs)
18090 return nid;
18091 }
18092 return 0;
18093}
18094
18095/* fill in the dac_nids table from the parsed pin configuration */
18096static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18097 const struct auto_pin_cfg *cfg)
18098{
18099 struct alc_spec *spec = codec->spec;
18100 int i;
18101 hda_nid_t dac;
18102
18103 spec->multiout.dac_nids = spec->private_dac_nids;
18104 for (i = 0; i < cfg->line_outs; i++) {
18105 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18106 if (!dac)
18107 continue;
18108 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18109 }
18110 return 0;
18111}
18112
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018113static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018114 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018115{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018116 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018117 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18118}
18119
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018120static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018121 hda_nid_t nid, unsigned int chs)
18122{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018123 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018124 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18125}
18126
18127#define alc662_add_stereo_vol(spec, pfx, nid) \
18128 alc662_add_vol_ctl(spec, pfx, nid, 3)
18129#define alc662_add_stereo_sw(spec, pfx, nid) \
18130 alc662_add_sw_ctl(spec, pfx, nid, 3)
18131
18132/* add playback controls from the parsed DAC table */
18133static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18134 const struct auto_pin_cfg *cfg)
18135{
18136 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018137 static const char *chname[4] = {
18138 "Front", "Surround", NULL /*CLFE*/, "Side"
18139 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018140 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018141 int i, err;
18142
18143 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018144 nid = spec->multiout.dac_nids[i];
18145 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018146 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018147 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18148 if (!mix)
18149 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018150 if (i == 2) {
18151 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018152 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018153 if (err < 0)
18154 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018155 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018156 if (err < 0)
18157 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018158 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018159 if (err < 0)
18160 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018161 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018162 if (err < 0)
18163 return err;
18164 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018165 const char *pfx;
18166 if (cfg->line_outs == 1 &&
18167 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018168 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018169 pfx = "Speaker";
18170 else
18171 pfx = "PCM";
18172 } else
18173 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018174 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018175 if (err < 0)
18176 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018177 if (cfg->line_outs == 1 &&
18178 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18179 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018180 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018181 if (err < 0)
18182 return err;
18183 }
18184 }
18185 return 0;
18186}
18187
18188/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018189/* return DAC nid if any new DAC is assigned */
18190static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018191 const char *pfx)
18192{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018193 struct alc_spec *spec = codec->spec;
18194 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018195 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018196
18197 if (!pin)
18198 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018199 nid = alc662_look_for_dac(codec, pin);
18200 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018201 /* the corresponding DAC is already occupied */
18202 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
18203 return 0; /* no way */
18204 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018205 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018206 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
18207 }
18208
18209 mix = alc662_dac_to_mix(codec, pin, nid);
18210 if (!mix)
18211 return 0;
18212 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
18213 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020018214 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018215 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
18216 if (err < 0)
18217 return err;
18218 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018219}
18220
18221/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020018222#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020018223 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018224
18225static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
18226 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018227 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018228{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018229 int i, num;
18230 hda_nid_t srcs[4];
18231
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018232 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018233 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018234 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
18235 if (num <= 1)
18236 return;
18237 for (i = 0; i < num; i++) {
18238 if (alc662_mix_to_dac(srcs[i]) != dac)
18239 continue;
18240 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
18241 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018242 }
18243}
18244
18245static void alc662_auto_init_multi_out(struct hda_codec *codec)
18246{
18247 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018248 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018249 int i;
18250
18251 for (i = 0; i <= HDA_SIDE; i++) {
18252 hda_nid_t nid = spec->autocfg.line_out_pins[i];
18253 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020018254 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018255 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018256 }
18257}
18258
18259static void alc662_auto_init_hp_out(struct hda_codec *codec)
18260{
18261 struct alc_spec *spec = codec->spec;
18262 hda_nid_t pin;
18263
18264 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018265 if (pin)
18266 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
18267 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018268 pin = spec->autocfg.speaker_pins[0];
18269 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018270 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
18271 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018272}
18273
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018274#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
18275
18276static void alc662_auto_init_analog_input(struct hda_codec *codec)
18277{
18278 struct alc_spec *spec = codec->spec;
18279 int i;
18280
18281 for (i = 0; i < AUTO_PIN_LAST; i++) {
18282 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020018283 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010018284 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010018285 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010018286 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018287 snd_hda_codec_write(codec, nid, 0,
18288 AC_VERB_SET_AMP_GAIN_MUTE,
18289 AMP_OUT_MUTE);
18290 }
18291 }
18292}
18293
Takashi Iwaif511b012008-08-15 16:46:42 +020018294#define alc662_auto_init_input_src alc882_auto_init_input_src
18295
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018296static int alc662_parse_auto_config(struct hda_codec *codec)
18297{
18298 struct alc_spec *spec = codec->spec;
18299 int err;
18300 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
18301
18302 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
18303 alc662_ignore);
18304 if (err < 0)
18305 return err;
18306 if (!spec->autocfg.line_outs)
18307 return 0; /* can't find valid BIOS pin config */
18308
Takashi Iwai7085ec12009-10-02 09:03:58 +020018309 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018310 if (err < 0)
18311 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018312 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018313 if (err < 0)
18314 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018315 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018316 spec->autocfg.speaker_pins[0],
18317 "Speaker");
18318 if (err < 0)
18319 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018320 if (err)
18321 spec->multiout.extra_out_nid[0] = err;
18322 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018323 "Headphone");
18324 if (err < 0)
18325 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018326 if (err)
18327 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018328 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018329 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018330 return err;
18331
18332 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18333
Takashi Iwai0852d7a2009-02-11 11:35:15 +010018334 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018335 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
18336
Takashi Iwai603c4012008-07-30 15:01:44 +020018337 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018338 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018339
18340 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018341 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018342
Kailang Yangcec27c82010-02-04 14:18:18 +010018343 add_verb(spec, alc662_init_verbs);
18344 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18345 codec->vendor_id == 0x10ec0665)
18346 add_verb(spec, alc663_init_verbs);
18347
18348 if (codec->vendor_id == 0x10ec0272)
18349 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020018350
18351 err = alc_auto_add_mic_boost(codec);
18352 if (err < 0)
18353 return err;
18354
Kailang Yang6227cdc2010-02-25 08:36:52 +010018355 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18356 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
18357 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
18358 else
18359 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018360
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018361 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018362}
18363
18364/* additional initialization for auto-configuration model */
18365static void alc662_auto_init(struct hda_codec *codec)
18366{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018367 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018368 alc662_auto_init_multi_out(codec);
18369 alc662_auto_init_hp_out(codec);
18370 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020018371 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018372 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018373 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018374}
18375
18376static int patch_alc662(struct hda_codec *codec)
18377{
18378 struct alc_spec *spec;
18379 int err, board_config;
18380
18381 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18382 if (!spec)
18383 return -ENOMEM;
18384
18385 codec->spec = spec;
18386
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018387 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18388
Kailang Yang274693f2009-12-03 10:07:50 +010018389 if (alc_read_coef_idx(codec, 0)==0x8020){
18390 kfree(codec->chip_name);
18391 codec->chip_name = kstrdup("ALC661", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018392 if (!codec->chip_name) {
18393 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018394 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018395 }
Kailang Yang274693f2009-12-03 10:07:50 +010018396 }
18397
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018398 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18399 alc662_models,
18400 alc662_cfg_tbl);
18401 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020018402 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18403 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018404 board_config = ALC662_AUTO;
18405 }
18406
18407 if (board_config == ALC662_AUTO) {
18408 /* automatic parse from the BIOS config */
18409 err = alc662_parse_auto_config(codec);
18410 if (err < 0) {
18411 alc_free(codec);
18412 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018413 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018414 printk(KERN_INFO
18415 "hda_codec: Cannot set up configuration "
18416 "from BIOS. Using base mode...\n");
18417 board_config = ALC662_3ST_2ch_DIG;
18418 }
18419 }
18420
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018421 err = snd_hda_attach_beep_device(codec, 0x1);
18422 if (err < 0) {
18423 alc_free(codec);
18424 return err;
18425 }
18426
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018427 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018428 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018429
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018430 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18431 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18432
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018433 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18434 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18435
Takashi Iwaidd704692009-08-11 08:45:11 +020018436 if (!spec->adc_nids) {
18437 spec->adc_nids = alc662_adc_nids;
18438 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
18439 }
18440 if (!spec->capsrc_nids)
18441 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018442
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018443 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018444 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018445
Kailang Yangcec27c82010-02-04 14:18:18 +010018446 switch (codec->vendor_id) {
18447 case 0x10ec0662:
18448 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18449 break;
18450 case 0x10ec0272:
18451 case 0x10ec0663:
18452 case 0x10ec0665:
18453 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
18454 break;
18455 case 0x10ec0273:
18456 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
18457 break;
18458 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010018459 spec->vmaster_nid = 0x02;
18460
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018461 codec->patch_ops = alc_patch_ops;
18462 if (board_config == ALC662_AUTO)
18463 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020018464#ifdef CONFIG_SND_HDA_POWER_SAVE
18465 if (!spec->loopback.amplist)
18466 spec->loopback.amplist = alc662_loopbacks;
18467#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018468
18469 return 0;
18470}
18471
Kailang Yang274693f2009-12-03 10:07:50 +010018472static int patch_alc888(struct hda_codec *codec)
18473{
18474 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
18475 kfree(codec->chip_name);
18476 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018477 if (!codec->chip_name) {
18478 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018479 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018480 }
18481 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018482 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018483 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018484}
18485
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018486/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070018487 * patch entries
18488 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018489static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070018490 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018491 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018492 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020018493 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018494 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018495 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020018496 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018497 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018498 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018499 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018500 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
18501 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
18502 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018503 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018504 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018505 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
18506 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018507 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010018508 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010018509 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018510 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018511 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018512 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020018513 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018514 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020018515 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018516 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018517 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018518 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020018519 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018520 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018521 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018522 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018523 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018524 {} /* terminator */
18525};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018526
18527MODULE_ALIAS("snd-hda-codec-id:10ec*");
18528
18529MODULE_LICENSE("GPL");
18530MODULE_DESCRIPTION("Realtek HD-audio codec");
18531
18532static struct hda_codec_preset_list realtek_list = {
18533 .preset = snd_hda_preset_realtek,
18534 .owner = THIS_MODULE,
18535};
18536
18537static int __init patch_realtek_init(void)
18538{
18539 return snd_hda_add_codec_preset(&realtek_list);
18540}
18541
18542static void __exit patch_realtek_exit(void)
18543{
18544 snd_hda_delete_codec_preset(&realtek_list);
18545}
18546
18547module_init(patch_realtek_init)
18548module_exit(patch_realtek_exit)