blob: fbbdfbc8a1ca76c7260edde955e5cebfd0a239cf [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,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200233 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100234 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200235 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200236 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200237 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200238 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200239 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200240 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100241 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100242 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430243 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100244 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100245 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800246 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200247 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200248 ALC889A_INTEL,
249 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200250 ALC888_ASUS_M90V,
251 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200252 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100253 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200254 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200255 ALC882_AUTO,
256 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200257};
258
Kailang Yangdf694da2005-12-05 19:42:22 +0100259/* for GPIO Poll */
260#define GPIO_MASK 0x03
261
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200262/* extra amp-initialization sequence types */
263enum {
264 ALC_INIT_NONE,
265 ALC_INIT_DEFAULT,
266 ALC_INIT_GPIO1,
267 ALC_INIT_GPIO2,
268 ALC_INIT_GPIO3,
269};
270
Takashi Iwai6c819492009-08-10 18:47:44 +0200271struct alc_mic_route {
272 hda_nid_t pin;
273 unsigned char mux_idx;
274 unsigned char amix_idx;
275};
276
277#define MUX_IDX_UNDEF ((unsigned char)-1)
278
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279struct alc_spec {
280 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100281 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100283 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100284 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200286 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200287 * don't forget NULL
288 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200289 */
290 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200292 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 struct hda_pcm_stream *stream_analog_playback;
294 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100295 struct hda_pcm_stream *stream_analog_alt_playback;
296 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200298 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 struct hda_pcm_stream *stream_digital_playback;
300 struct hda_pcm_stream *stream_digital_capture;
301
302 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200303 struct hda_multi_out multiout; /* playback set-up
304 * max_channels, dacs must be set
305 * dig_out_nid and hp_nid are optional
306 */
Takashi Iwai63300792008-01-24 15:31:36 +0100307 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100308 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100309 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310
311 /* capture */
312 unsigned int num_adc_nids;
313 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100314 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200315 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316
317 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200318 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 const struct hda_input_mux *input_mux;
320 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200321 struct alc_mic_route ext_mic;
322 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323
324 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100325 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200327 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200328 int const_channel_count;
329 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330
331 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100332 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200333
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200334 /* dynamic controls, init_verbs and input_mux */
335 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200336 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200337 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200338 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200339 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
340 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100341
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100342 /* hooks */
343 void (*init_hook)(struct hda_codec *codec);
344 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100345#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500346 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100347#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100348
Takashi Iwai834be882006-03-01 14:16:17 +0100349 /* for pin sensing */
350 unsigned int sense_updated: 1;
351 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100352 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200353 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200354
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100355 /* other flags */
356 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200357 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100358
Takashi Iwai2134ea42008-01-10 16:53:55 +0100359 /* for virtual master */
360 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200361#ifdef CONFIG_SND_HDA_POWER_SAVE
362 struct hda_loopback_check loopback;
363#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200364
365 /* for PLL fix */
366 hda_nid_t pll_nid;
367 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100368};
369
370/*
371 * configuration template - to be copied to the spec instance
372 */
373struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200374 struct snd_kcontrol_new *mixers[5]; /* should be identical size
375 * with spec
376 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100377 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100378 const struct hda_verb *init_verbs[5];
379 unsigned int num_dacs;
380 hda_nid_t *dac_nids;
381 hda_nid_t dig_out_nid; /* optional */
382 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800383 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100384 unsigned int num_adc_nids;
385 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100386 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100387 hda_nid_t dig_in_nid;
388 unsigned int num_channel_mode;
389 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200390 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200391 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200392 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100393 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100394 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200395 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100396 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200397#ifdef CONFIG_SND_HDA_POWER_SAVE
398 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500399 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200400#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401};
402
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403
404/*
405 * input MUX handling
406 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200407static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
408 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409{
410 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
411 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200412 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
413 if (mux_idx >= spec->num_mux_defs)
414 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100415 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
416 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200417 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418}
419
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200420static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
421 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422{
423 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
424 struct alc_spec *spec = codec->spec;
425 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
426
427 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
428 return 0;
429}
430
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200431static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
432 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433{
434 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
435 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100436 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100438 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100439 hda_nid_t nid = spec->capsrc_nids ?
440 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200441 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442
Takashi Iwaicd896c32008-11-18 12:36:33 +0100443 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
444 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100445 if (!imux->num_items && mux_idx > 0)
446 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100447
Takashi Iwaia22d5432009-07-27 12:54:26 +0200448 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200449 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100450 /* Matrix-mixer style (e.g. ALC882) */
451 unsigned int *cur_val = &spec->cur_mux[adc_idx];
452 unsigned int i, idx;
453
454 idx = ucontrol->value.enumerated.item[0];
455 if (idx >= imux->num_items)
456 idx = imux->num_items - 1;
457 if (*cur_val == idx)
458 return 0;
459 for (i = 0; i < imux->num_items; i++) {
460 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
461 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
462 imux->items[i].index,
463 HDA_AMP_MUTE, v);
464 }
465 *cur_val = idx;
466 return 1;
467 } else {
468 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100469 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100470 &spec->cur_mux[adc_idx]);
471 }
472}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200473
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474/*
475 * channel mode setting
476 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200477static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479{
480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
481 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100482 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
483 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484}
485
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200486static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
487 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488{
489 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
490 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100491 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200492 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200493 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494}
495
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200496static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
497 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498{
499 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
500 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200501 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
502 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200503 &spec->ext_channel_count);
504 if (err >= 0 && !spec->const_channel_count) {
505 spec->multiout.max_channels = spec->ext_channel_count;
506 if (spec->need_dac_fix)
507 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
508 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200509 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510}
511
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100513 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200514 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100515 * being part of a format specifier. Maximum allowed length of a value is
516 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100517 *
518 * Note: some retasking pin complexes seem to ignore requests for input
519 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
520 * are requested. Therefore order this list so that this behaviour will not
521 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200522 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
523 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200524 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100525static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100526 "Mic 50pc bias", "Mic 80pc bias",
527 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100528};
529static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100530 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100531};
532/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200533 * in the pin being assumed to be exclusively an input or an output pin. In
534 * addition, "input" pins may or may not process the mic bias option
535 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
536 * accept requests for bias as of chip versions up to March 2006) and/or
537 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100538 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200539#define ALC_PIN_DIR_IN 0x00
540#define ALC_PIN_DIR_OUT 0x01
541#define ALC_PIN_DIR_INOUT 0x02
542#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
543#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100544
Kailang Yangea1fb292008-08-26 12:58:38 +0200545/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100546 * For each direction the minimum and maximum values are given.
547 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200548static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100549 { 0, 2 }, /* ALC_PIN_DIR_IN */
550 { 3, 4 }, /* ALC_PIN_DIR_OUT */
551 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200552 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
553 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100554};
555#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
556#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
557#define alc_pin_mode_n_items(_dir) \
558 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
559
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200560static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
561 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200562{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100563 unsigned int item_num = uinfo->value.enumerated.item;
564 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
565
566 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200567 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100568 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
569
570 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
571 item_num = alc_pin_mode_min(dir);
572 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200573 return 0;
574}
575
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200576static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
577 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200578{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100579 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200580 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
581 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100582 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200583 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200584 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
585 AC_VERB_GET_PIN_WIDGET_CONTROL,
586 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200587
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100588 /* Find enumerated value for current pinctl setting */
589 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200590 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100591 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200592 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100593 return 0;
594}
595
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200596static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
597 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100598{
599 signed int change;
600 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
601 hda_nid_t nid = kcontrol->private_value & 0xffff;
602 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
603 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200604 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
605 AC_VERB_GET_PIN_WIDGET_CONTROL,
606 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100607
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200608 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100609 val = alc_pin_mode_min(dir);
610
611 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100612 if (change) {
613 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200614 snd_hda_codec_write_cache(codec, nid, 0,
615 AC_VERB_SET_PIN_WIDGET_CONTROL,
616 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100617
Kailang Yangea1fb292008-08-26 12:58:38 +0200618 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100619 * for the requested pin mode. Enum values of 2 or less are
620 * input modes.
621 *
622 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200623 * reduces noise slightly (particularly on input) so we'll
624 * do it. However, having both input and output buffers
625 * enabled simultaneously doesn't seem to be problematic if
626 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100627 */
628 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200629 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
630 HDA_AMP_MUTE, HDA_AMP_MUTE);
631 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
632 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100633 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200634 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
635 HDA_AMP_MUTE, HDA_AMP_MUTE);
636 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
637 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100638 }
639 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200640 return change;
641}
642
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100643#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200644 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100645 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100646 .info = alc_pin_mode_info, \
647 .get = alc_pin_mode_get, \
648 .put = alc_pin_mode_put, \
649 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100650
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100651/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
652 * together using a mask with more than one bit set. This control is
653 * currently used only by the ALC260 test model. At this stage they are not
654 * needed for any "production" models.
655 */
656#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200657#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200658
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200659static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
660 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100661{
662 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
663 hda_nid_t nid = kcontrol->private_value & 0xffff;
664 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
665 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200666 unsigned int val = snd_hda_codec_read(codec, nid, 0,
667 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100668
669 *valp = (val & mask) != 0;
670 return 0;
671}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200672static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
673 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100674{
675 signed int change;
676 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
677 hda_nid_t nid = kcontrol->private_value & 0xffff;
678 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
679 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200680 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
681 AC_VERB_GET_GPIO_DATA,
682 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100683
684 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200685 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
686 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100687 gpio_data &= ~mask;
688 else
689 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200690 snd_hda_codec_write_cache(codec, nid, 0,
691 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100692
693 return change;
694}
695#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
696 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100697 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100698 .info = alc_gpio_data_info, \
699 .get = alc_gpio_data_get, \
700 .put = alc_gpio_data_put, \
701 .private_value = nid | (mask<<16) }
702#endif /* CONFIG_SND_DEBUG */
703
Jonathan Woithe92621f12006-02-28 11:47:47 +0100704/* A switch control to allow the enabling of the digital IO pins on the
705 * ALC260. This is incredibly simplistic; the intention of this control is
706 * to provide something in the test model allowing digital outputs to be
707 * identified if present. If models are found which can utilise these
708 * outputs a more complete mixer control can be devised for those models if
709 * necessary.
710 */
711#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200712#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200713
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200714static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
715 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100716{
717 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
718 hda_nid_t nid = kcontrol->private_value & 0xffff;
719 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
720 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200721 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100722 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100723
724 *valp = (val & mask) != 0;
725 return 0;
726}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200727static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
728 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100729{
730 signed int change;
731 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
732 hda_nid_t nid = kcontrol->private_value & 0xffff;
733 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
734 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200735 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100736 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200737 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100738
739 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200740 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100741 if (val==0)
742 ctrl_data &= ~mask;
743 else
744 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200745 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
746 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100747
748 return change;
749}
750#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
751 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100752 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100753 .info = alc_spdif_ctrl_info, \
754 .get = alc_spdif_ctrl_get, \
755 .put = alc_spdif_ctrl_put, \
756 .private_value = nid | (mask<<16) }
757#endif /* CONFIG_SND_DEBUG */
758
Jonathan Woithef8225f62008-01-08 12:16:54 +0100759/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
760 * Again, this is only used in the ALC26x test models to help identify when
761 * the EAPD line must be asserted for features to work.
762 */
763#ifdef CONFIG_SND_DEBUG
764#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
765
766static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
767 struct snd_ctl_elem_value *ucontrol)
768{
769 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
770 hda_nid_t nid = kcontrol->private_value & 0xffff;
771 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
772 long *valp = ucontrol->value.integer.value;
773 unsigned int val = snd_hda_codec_read(codec, nid, 0,
774 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
775
776 *valp = (val & mask) != 0;
777 return 0;
778}
779
780static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
781 struct snd_ctl_elem_value *ucontrol)
782{
783 int change;
784 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
785 hda_nid_t nid = kcontrol->private_value & 0xffff;
786 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
787 long val = *ucontrol->value.integer.value;
788 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
789 AC_VERB_GET_EAPD_BTLENABLE,
790 0x00);
791
792 /* Set/unset the masked control bit(s) as needed */
793 change = (!val ? 0 : mask) != (ctrl_data & mask);
794 if (!val)
795 ctrl_data &= ~mask;
796 else
797 ctrl_data |= mask;
798 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
799 ctrl_data);
800
801 return change;
802}
803
804#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
805 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100806 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100807 .info = alc_eapd_ctrl_info, \
808 .get = alc_eapd_ctrl_get, \
809 .put = alc_eapd_ctrl_put, \
810 .private_value = nid | (mask<<16) }
811#endif /* CONFIG_SND_DEBUG */
812
Kailang Yangdf694da2005-12-05 19:42:22 +0100813/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100814 * set up the input pin config (depending on the given auto-pin type)
815 */
816static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
817 int auto_pin_type)
818{
819 unsigned int val = PIN_IN;
820
821 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
822 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100823 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100824 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
825 if (pincap & AC_PINCAP_VREF_80)
826 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200827 else if (pincap & AC_PINCAP_VREF_50)
828 val = PIN_VREF50;
829 else if (pincap & AC_PINCAP_VREF_100)
830 val = PIN_VREF100;
831 else if (pincap & AC_PINCAP_VREF_GRD)
832 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100833 }
834 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
835}
836
837/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100838 */
839static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
840{
841 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
842 return;
843 spec->mixers[spec->num_mixers++] = mix;
844}
845
846static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
847{
848 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
849 return;
850 spec->init_verbs[spec->num_init_verbs++] = verb;
851}
852
853/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100854 * set up from the preset table
855 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200856static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200857 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100858{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200859 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100860 int i;
861
862 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100863 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100864 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200865 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
866 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100867 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200868
Kailang Yangdf694da2005-12-05 19:42:22 +0100869 spec->channel_mode = preset->channel_mode;
870 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200871 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200872 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100873
Hector Martin3b315d72009-06-02 10:54:19 +0200874 if (preset->const_channel_count)
875 spec->multiout.max_channels = preset->const_channel_count;
876 else
877 spec->multiout.max_channels = spec->channel_mode[0].channels;
878 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100879
880 spec->multiout.num_dacs = preset->num_dacs;
881 spec->multiout.dac_nids = preset->dac_nids;
882 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800883 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100884 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200885
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200886 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200887 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200888 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100889 spec->input_mux = preset->input_mux;
890
891 spec->num_adc_nids = preset->num_adc_nids;
892 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100893 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100894 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100895
896 spec->unsol_event = preset->unsol_event;
897 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200898#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100899 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200900 spec->loopback.amplist = preset->loopbacks;
901#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200902
903 if (preset->setup)
904 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100905}
906
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200907/* Enable GPIO mask and set output */
908static struct hda_verb alc_gpio1_init_verbs[] = {
909 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
910 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
911 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
912 { }
913};
914
915static struct hda_verb alc_gpio2_init_verbs[] = {
916 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
917 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
918 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
919 { }
920};
921
Kailang Yangbdd148a2007-05-08 15:19:08 +0200922static struct hda_verb alc_gpio3_init_verbs[] = {
923 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
924 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
925 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
926 { }
927};
928
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200929/*
930 * Fix hardware PLL issue
931 * On some codecs, the analog PLL gating control must be off while
932 * the default value is 1.
933 */
934static void alc_fix_pll(struct hda_codec *codec)
935{
936 struct alc_spec *spec = codec->spec;
937 unsigned int val;
938
939 if (!spec->pll_nid)
940 return;
941 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
942 spec->pll_coef_idx);
943 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
944 AC_VERB_GET_PROC_COEF, 0);
945 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
946 spec->pll_coef_idx);
947 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
948 val & ~(1 << spec->pll_coef_bit));
949}
950
951static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
952 unsigned int coef_idx, unsigned int coef_bit)
953{
954 struct alc_spec *spec = codec->spec;
955 spec->pll_nid = nid;
956 spec->pll_coef_idx = coef_idx;
957 spec->pll_coef_bit = coef_bit;
958 alc_fix_pll(codec);
959}
960
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200961static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200962{
963 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200964 unsigned int nid = spec->autocfg.hp_pins[0];
965 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200966
Takashi Iwaiad87c642009-11-02 14:23:15 +0100967 if (!nid)
968 return;
Wu Fengguang864f92b2009-11-18 12:38:02 +0800969 spec->jack_present = snd_hda_jack_detect(codec, nid);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200970 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
971 nid = spec->autocfg.speaker_pins[i];
972 if (!nid)
973 break;
974 snd_hda_codec_write(codec, nid, 0,
975 AC_VERB_SET_PIN_WIDGET_CONTROL,
976 spec->jack_present ? 0 : PIN_OUT);
977 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200978}
979
Takashi Iwai6c819492009-08-10 18:47:44 +0200980static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
981 hda_nid_t nid)
982{
983 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
984 int i, nums;
985
986 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
987 for (i = 0; i < nums; i++)
988 if (conn[i] == nid)
989 return i;
990 return -1;
991}
992
Kailang Yang7fb0d782008-10-15 11:12:35 +0200993static void alc_mic_automute(struct hda_codec *codec)
994{
995 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +0200996 struct alc_mic_route *dead, *alive;
997 unsigned int present, type;
998 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200999
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001000 if (!spec->auto_mic)
1001 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001002 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1003 return;
1004 if (snd_BUG_ON(!spec->adc_nids))
1005 return;
1006
1007 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1008
Wu Fengguang864f92b2009-11-18 12:38:02 +08001009 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001010 if (present) {
1011 alive = &spec->ext_mic;
1012 dead = &spec->int_mic;
1013 } else {
1014 alive = &spec->int_mic;
1015 dead = &spec->ext_mic;
1016 }
1017
Takashi Iwai6c819492009-08-10 18:47:44 +02001018 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1019 if (type == AC_WID_AUD_MIX) {
1020 /* Matrix-mixer style (e.g. ALC882) */
1021 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1022 alive->mux_idx,
1023 HDA_AMP_MUTE, 0);
1024 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1025 dead->mux_idx,
1026 HDA_AMP_MUTE, HDA_AMP_MUTE);
1027 } else {
1028 /* MUX style (e.g. ALC880) */
1029 snd_hda_codec_write_cache(codec, cap_nid, 0,
1030 AC_VERB_SET_CONNECT_SEL,
1031 alive->mux_idx);
1032 }
1033
1034 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001035}
1036
Kailang Yangc9b58002007-10-16 14:30:01 +02001037/* unsolicited event for HP jack sensing */
1038static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1039{
1040 if (codec->vendor_id == 0x10ec0880)
1041 res >>= 28;
1042 else
1043 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001044 switch (res) {
1045 case ALC880_HP_EVENT:
1046 alc_automute_pin(codec);
1047 break;
1048 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001049 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001050 break;
1051 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001052}
1053
1054static void alc_inithook(struct hda_codec *codec)
1055{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001056 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001057 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001058}
1059
Kailang Yangf9423e72008-05-27 12:32:25 +02001060/* additional initialization for ALC888 variants */
1061static void alc888_coef_init(struct hda_codec *codec)
1062{
1063 unsigned int tmp;
1064
1065 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1066 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1067 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001068 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001069 /* alc888S-VC */
1070 snd_hda_codec_read(codec, 0x20, 0,
1071 AC_VERB_SET_PROC_COEF, 0x830);
1072 else
1073 /* alc888-VB */
1074 snd_hda_codec_read(codec, 0x20, 0,
1075 AC_VERB_SET_PROC_COEF, 0x3030);
1076}
1077
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001078static void alc889_coef_init(struct hda_codec *codec)
1079{
1080 unsigned int tmp;
1081
1082 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1083 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1084 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1085 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1086}
1087
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001088/* turn on/off EAPD control (only if available) */
1089static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1090{
1091 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1092 return;
1093 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1094 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1095 on ? 2 : 0);
1096}
1097
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001098static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001099{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001100 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001101
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001102 switch (type) {
1103 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001104 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1105 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001106 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001107 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1108 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001109 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001110 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1111 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001112 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001113 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001114 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001115 set_eapd(codec, 0x0f, 1);
1116 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001117 break;
1118 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001119 case 0x10ec0267:
1120 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001121 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001122 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001123 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001124 case 0x10ec0660:
1125 case 0x10ec0662:
1126 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001127 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001128 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001129 set_eapd(codec, 0x14, 1);
1130 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001131 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001132 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001133 switch (codec->vendor_id) {
1134 case 0x10ec0260:
1135 snd_hda_codec_write(codec, 0x1a, 0,
1136 AC_VERB_SET_COEF_INDEX, 7);
1137 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1138 AC_VERB_GET_PROC_COEF, 0);
1139 snd_hda_codec_write(codec, 0x1a, 0,
1140 AC_VERB_SET_COEF_INDEX, 7);
1141 snd_hda_codec_write(codec, 0x1a, 0,
1142 AC_VERB_SET_PROC_COEF,
1143 tmp | 0x2010);
1144 break;
1145 case 0x10ec0262:
1146 case 0x10ec0880:
1147 case 0x10ec0882:
1148 case 0x10ec0883:
1149 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001150 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001151 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001152 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001153 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001154 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001155 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001156 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001157#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001158 case 0x10ec0267:
1159 case 0x10ec0268:
1160 snd_hda_codec_write(codec, 0x20, 0,
1161 AC_VERB_SET_COEF_INDEX, 7);
1162 tmp = snd_hda_codec_read(codec, 0x20, 0,
1163 AC_VERB_GET_PROC_COEF, 0);
1164 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001165 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001166 snd_hda_codec_write(codec, 0x20, 0,
1167 AC_VERB_SET_PROC_COEF,
1168 tmp | 0x3000);
1169 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001170#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001171 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001172 break;
1173 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001174}
Kailang Yangea1fb292008-08-26 12:58:38 +02001175
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001176static void alc_init_auto_hp(struct hda_codec *codec)
1177{
1178 struct alc_spec *spec = codec->spec;
1179
1180 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001181 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001182
Kailang Yangc9b58002007-10-16 14:30:01 +02001183 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001184 if (spec->autocfg.line_out_pins[0] &&
1185 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001186 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001187 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001188 else
1189 return;
1190 }
1191
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001192 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1193 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001194 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1195 AC_VERB_SET_UNSOLICITED_ENABLE,
1196 AC_USRSP_EN | ALC880_HP_EVENT);
1197 spec->unsol_event = alc_sku_unsol_event;
1198}
1199
Takashi Iwai6c819492009-08-10 18:47:44 +02001200static void alc_init_auto_mic(struct hda_codec *codec)
1201{
1202 struct alc_spec *spec = codec->spec;
1203 struct auto_pin_cfg *cfg = &spec->autocfg;
1204 hda_nid_t fixed, ext;
1205 int i;
1206
1207 /* there must be only two mic inputs exclusively */
1208 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1209 if (cfg->input_pins[i])
1210 return;
1211
1212 fixed = ext = 0;
1213 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1214 hda_nid_t nid = cfg->input_pins[i];
1215 unsigned int defcfg;
1216 if (!nid)
1217 return;
1218 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1219 switch (get_defcfg_connect(defcfg)) {
1220 case AC_JACK_PORT_FIXED:
1221 if (fixed)
1222 return; /* already occupied */
1223 fixed = nid;
1224 break;
1225 case AC_JACK_PORT_COMPLEX:
1226 if (ext)
1227 return; /* already occupied */
1228 ext = nid;
1229 break;
1230 default:
1231 return; /* invalid entry */
1232 }
1233 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001234 if (!ext || !fixed)
1235 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001236 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1237 return; /* no unsol support */
1238 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1239 ext, fixed);
1240 spec->ext_mic.pin = ext;
1241 spec->int_mic.pin = fixed;
1242 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1243 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1244 spec->auto_mic = 1;
1245 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1246 AC_VERB_SET_UNSOLICITED_ENABLE,
1247 AC_USRSP_EN | ALC880_MIC_EVENT);
1248 spec->unsol_event = alc_sku_unsol_event;
1249}
1250
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001251/* check subsystem ID and set up device-specific initialization;
1252 * return 1 if initialized, 0 if invalid SSID
1253 */
1254/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1255 * 31 ~ 16 : Manufacture ID
1256 * 15 ~ 8 : SKU ID
1257 * 7 ~ 0 : Assembly ID
1258 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1259 */
1260static int alc_subsystem_id(struct hda_codec *codec,
1261 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001262 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001263{
1264 unsigned int ass, tmp, i;
1265 unsigned nid;
1266 struct alc_spec *spec = codec->spec;
1267
1268 ass = codec->subsystem_id & 0xffff;
1269 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1270 goto do_sku;
1271
1272 /* invalid SSID, check the special NID pin defcfg instead */
1273 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001274 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001275 * 29~21 : reserve
1276 * 20 : PCBEEP input
1277 * 19~16 : Check sum (15:1)
1278 * 15~1 : Custom
1279 * 0 : override
1280 */
1281 nid = 0x1d;
1282 if (codec->vendor_id == 0x10ec0260)
1283 nid = 0x17;
1284 ass = snd_hda_codec_get_pincfg(codec, nid);
1285 snd_printd("realtek: No valid SSID, "
1286 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001287 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001288 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001289 return 0;
1290 if ((ass >> 30) != 1) /* no physical connection */
1291 return 0;
1292
1293 /* check sum */
1294 tmp = 0;
1295 for (i = 1; i < 16; i++) {
1296 if ((ass >> i) & 1)
1297 tmp++;
1298 }
1299 if (((ass >> 16) & 0xf) != tmp)
1300 return 0;
1301do_sku:
1302 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1303 ass & 0xffff, codec->vendor_id);
1304 /*
1305 * 0 : override
1306 * 1 : Swap Jack
1307 * 2 : 0 --> Desktop, 1 --> Laptop
1308 * 3~5 : External Amplifier control
1309 * 7~6 : Reserved
1310 */
1311 tmp = (ass & 0x38) >> 3; /* external Amp control */
1312 switch (tmp) {
1313 case 1:
1314 spec->init_amp = ALC_INIT_GPIO1;
1315 break;
1316 case 3:
1317 spec->init_amp = ALC_INIT_GPIO2;
1318 break;
1319 case 7:
1320 spec->init_amp = ALC_INIT_GPIO3;
1321 break;
1322 case 5:
1323 spec->init_amp = ALC_INIT_DEFAULT;
1324 break;
1325 }
1326
1327 /* is laptop or Desktop and enable the function "Mute internal speaker
1328 * when the external headphone out jack is plugged"
1329 */
1330 if (!(ass & 0x8000))
1331 return 1;
1332 /*
1333 * 10~8 : Jack location
1334 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1335 * 14~13: Resvered
1336 * 15 : 1 --> enable the function "Mute internal speaker
1337 * when the external headphone out jack is plugged"
1338 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001339 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001340 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001341 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1342 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001343 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001344 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001345 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001346 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001347 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001348 else if (tmp == 3)
1349 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001350 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001351 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001352 for (i = 0; i < spec->autocfg.line_outs; i++)
1353 if (spec->autocfg.line_out_pins[i] == nid)
1354 return 1;
1355 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001356 }
1357
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001358 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001359 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001360 return 1;
1361}
Kailang Yangea1fb292008-08-26 12:58:38 +02001362
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001363static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001364 hda_nid_t porta, hda_nid_t porte,
1365 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001366{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001367 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001368 struct alc_spec *spec = codec->spec;
1369 snd_printd("realtek: "
1370 "Enable default setup for auto mode as fallback\n");
1371 spec->init_amp = ALC_INIT_DEFAULT;
1372 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001373 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001374 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001375}
1376
Takashi Iwai41e41f12005-06-08 14:48:49 +02001377/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001378 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001379 */
1380
1381struct alc_pincfg {
1382 hda_nid_t nid;
1383 u32 val;
1384};
1385
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001386struct alc_fixup {
1387 const struct alc_pincfg *pins;
1388 const struct hda_verb *verbs;
1389};
1390
1391static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001392 const struct snd_pci_quirk *quirk,
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001393 const struct alc_fixup *fix)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001394{
1395 const struct alc_pincfg *cfg;
1396
1397 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1398 if (!quirk)
1399 return;
1400
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001401 fix += quirk->value;
1402 cfg = fix->pins;
1403 if (cfg) {
1404 for (; cfg->nid; cfg++)
1405 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1406 }
1407 if (fix->verbs)
1408 add_verb(codec->spec, fix->verbs);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001409}
1410
Kailang Yang274693f2009-12-03 10:07:50 +01001411static int alc_read_coef_idx(struct hda_codec *codec,
1412 unsigned int coef_idx)
1413{
1414 unsigned int val;
1415 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1416 coef_idx);
1417 val = snd_hda_codec_read(codec, 0x20, 0,
1418 AC_VERB_GET_PROC_COEF, 0);
1419 return val;
1420}
1421
Takashi Iwaif95474e2007-07-10 00:47:43 +02001422/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001423 * ALC888
1424 */
1425
1426/*
1427 * 2ch mode
1428 */
1429static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1430/* Mic-in jack as mic in */
1431 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1432 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1433/* Line-in jack as Line in */
1434 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1435 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1436/* Line-Out as Front */
1437 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1438 { } /* end */
1439};
1440
1441/*
1442 * 4ch mode
1443 */
1444static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1445/* Mic-in jack as mic in */
1446 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1447 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1448/* Line-in jack as Surround */
1449 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1450 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1451/* Line-Out as Front */
1452 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1453 { } /* end */
1454};
1455
1456/*
1457 * 6ch mode
1458 */
1459static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1460/* Mic-in jack as CLFE */
1461 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1462 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1463/* Line-in jack as Surround */
1464 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1465 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1466/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1467 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1468 { } /* end */
1469};
1470
1471/*
1472 * 8ch mode
1473 */
1474static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1475/* Mic-in jack as CLFE */
1476 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1477 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1478/* Line-in jack as Surround */
1479 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1480 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1481/* Line-Out as Side */
1482 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1483 { } /* end */
1484};
1485
1486static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1487 { 2, alc888_4ST_ch2_intel_init },
1488 { 4, alc888_4ST_ch4_intel_init },
1489 { 6, alc888_4ST_ch6_intel_init },
1490 { 8, alc888_4ST_ch8_intel_init },
1491};
1492
1493/*
1494 * ALC888 Fujitsu Siemens Amillo xa3530
1495 */
1496
1497static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1498/* Front Mic: set to PIN_IN (empty by default) */
1499 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1500/* Connect Internal HP to Front */
1501 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1502 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1503 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1504/* Connect Bass HP to Front */
1505 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1506 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1507 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1508/* Connect Line-Out side jack (SPDIF) to Side */
1509 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1510 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1511 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1512/* Connect Mic jack to CLFE */
1513 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1514 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1515 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1516/* Connect Line-in jack to Surround */
1517 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1518 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1519 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1520/* Connect HP out jack to Front */
1521 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1522 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1523 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1524/* Enable unsolicited event for HP jack and Line-out jack */
1525 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1526 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1527 {}
1528};
1529
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001530static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001531{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001532 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001533 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001534 hda_nid_t nid;
1535 int i;
1536
1537 spec->jack_present = 0;
1538 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1539 nid = spec->autocfg.hp_pins[i];
1540 if (!nid)
1541 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001542 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001543 spec->jack_present = 1;
1544 break;
1545 }
1546 }
1547
1548 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001549 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001550 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1551 nid = spec->autocfg.speaker_pins[i];
1552 if (!nid)
1553 break;
1554 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1555 HDA_AMP_MUTE, mute);
1556 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001557}
1558
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001559static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1560 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001561{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001562 if (codec->vendor_id == 0x10ec0880)
1563 res >>= 28;
1564 else
1565 res >>= 26;
1566 if (res == ALC880_HP_EVENT)
1567 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001568}
1569
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001570static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001571{
1572 struct alc_spec *spec = codec->spec;
1573
1574 spec->autocfg.hp_pins[0] = 0x15;
1575 spec->autocfg.speaker_pins[0] = 0x14;
1576 spec->autocfg.speaker_pins[1] = 0x16;
1577 spec->autocfg.speaker_pins[2] = 0x17;
1578 spec->autocfg.speaker_pins[3] = 0x19;
1579 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001580}
1581
1582static void alc889_intel_init_hook(struct hda_codec *codec)
1583{
1584 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001585 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001586}
1587
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001588static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001589{
1590 struct alc_spec *spec = codec->spec;
1591
1592 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1593 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1594 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1595 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001596}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001597
1598/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001599 * ALC888 Acer Aspire 4930G model
1600 */
1601
1602static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1603/* Front Mic: set to PIN_IN (empty by default) */
1604 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1605/* Unselect Front Mic by default in input mixer 3 */
1606 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001607/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001608 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1609/* Connect Internal HP to front */
1610 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1611 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1612 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1613/* Connect HP out to front */
1614 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1615 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1616 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1617 { }
1618};
1619
Hector Martin3b315d72009-06-02 10:54:19 +02001620/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001621 * ALC888 Acer Aspire 6530G model
1622 */
1623
1624static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01001625/* Route to built-in subwoofer as well as speakers */
1626 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1627 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1628 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1629 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001630/* Bias voltage on for external mic port */
1631 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001632/* Front Mic: set to PIN_IN (empty by default) */
1633 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1634/* Unselect Front Mic by default in input mixer 3 */
1635 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001636/* Enable unsolicited event for HP jack */
1637 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1638/* Enable speaker output */
1639 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1640 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01001641 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001642/* Enable headphone output */
1643 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1644 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1645 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01001646 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001647 { }
1648};
1649
1650/*
Hector Martin018df412009-06-04 00:13:40 +02001651 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001652 */
1653
Hector Martin018df412009-06-04 00:13:40 +02001654static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001655/* Front Mic: set to PIN_IN (empty by default) */
1656 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1657/* Unselect Front Mic by default in input mixer 3 */
1658 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1659/* Enable unsolicited event for HP jack */
1660 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1661/* Connect Internal Front to Front */
1662 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1663 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1664 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1665/* Connect Internal Rear to Rear */
1666 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1667 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1668 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1669/* Connect Internal CLFE to CLFE */
1670 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1671 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1672 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1673/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001674 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001675 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1676 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1677/* Enable all DACs */
1678/* DAC DISABLE/MUTE 1? */
1679/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1680 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1681 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1682/* DAC DISABLE/MUTE 2? */
1683/* some bit here disables the other DACs. Init=0x4900 */
1684 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1685 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02001686/* DMIC fix
1687 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1688 * which makes the stereo useless. However, either the mic or the ALC889
1689 * makes the signal become a difference/sum signal instead of standard
1690 * stereo, which is annoying. So instead we flip this bit which makes the
1691 * codec replicate the sum signal to both channels, turning it into a
1692 * normal mono mic.
1693 */
1694/* DMIC_CONTROL? Init value = 0x0001 */
1695 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1696 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001697 { }
1698};
1699
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001700static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001701 /* Front mic only available on one ADC */
1702 {
1703 .num_items = 4,
1704 .items = {
1705 { "Mic", 0x0 },
1706 { "Line", 0x2 },
1707 { "CD", 0x4 },
1708 { "Front Mic", 0xb },
1709 },
1710 },
1711 {
1712 .num_items = 3,
1713 .items = {
1714 { "Mic", 0x0 },
1715 { "Line", 0x2 },
1716 { "CD", 0x4 },
1717 },
1718 }
1719};
1720
Tony Vroond2fd4b02009-06-21 00:40:10 +01001721static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1722 /* Interal mic only available on one ADC */
1723 {
Tony Vroon684a8842009-06-26 09:27:50 +01001724 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001725 .items = {
1726 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001727 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001728 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001729 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001730 { "Int Mic", 0xb },
1731 },
1732 },
1733 {
Tony Vroon684a8842009-06-26 09:27:50 +01001734 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001735 .items = {
1736 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001737 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001738 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001739 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001740 },
1741 }
1742};
1743
Hector Martin018df412009-06-04 00:13:40 +02001744static struct hda_input_mux alc889_capture_sources[3] = {
1745 /* Digital mic only available on first "ADC" */
1746 {
1747 .num_items = 5,
1748 .items = {
1749 { "Mic", 0x0 },
1750 { "Line", 0x2 },
1751 { "CD", 0x4 },
1752 { "Front Mic", 0xb },
1753 { "Input Mix", 0xa },
1754 },
1755 },
1756 {
1757 .num_items = 4,
1758 .items = {
1759 { "Mic", 0x0 },
1760 { "Line", 0x2 },
1761 { "CD", 0x4 },
1762 { "Input Mix", 0xa },
1763 },
1764 },
1765 {
1766 .num_items = 4,
1767 .items = {
1768 { "Mic", 0x0 },
1769 { "Line", 0x2 },
1770 { "CD", 0x4 },
1771 { "Input Mix", 0xa },
1772 },
1773 }
1774};
1775
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001776static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001777 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1778 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1779 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1780 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1781 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1782 HDA_OUTPUT),
1783 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1784 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1785 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1786 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1787 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1788 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1789 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1790 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1791 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1792 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1793 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1794 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001795 { } /* end */
1796};
1797
Hector Martin556eea92009-12-20 22:51:23 +01001798static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1799 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1800 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1801 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1802 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1803 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1804 HDA_OUTPUT),
1805 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1806 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1807 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1808 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1809 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1811 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1812 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1813 { } /* end */
1814};
1815
1816
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001817static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001818{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001819 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001820
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001821 spec->autocfg.hp_pins[0] = 0x15;
1822 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01001823 spec->autocfg.speaker_pins[1] = 0x16;
1824 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001825}
1826
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001827static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001828{
1829 struct alc_spec *spec = codec->spec;
1830
1831 spec->autocfg.hp_pins[0] = 0x15;
1832 spec->autocfg.speaker_pins[0] = 0x14;
1833 spec->autocfg.speaker_pins[1] = 0x16;
1834 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001835}
1836
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001837static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001838{
1839 struct alc_spec *spec = codec->spec;
1840
1841 spec->autocfg.hp_pins[0] = 0x15;
1842 spec->autocfg.speaker_pins[0] = 0x14;
1843 spec->autocfg.speaker_pins[1] = 0x16;
1844 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001845}
1846
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001847/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001848 * ALC880 3-stack model
1849 *
1850 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001851 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1852 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001853 */
1854
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001855static hda_nid_t alc880_dac_nids[4] = {
1856 /* front, rear, clfe, rear_surr */
1857 0x02, 0x05, 0x04, 0x03
1858};
1859
1860static hda_nid_t alc880_adc_nids[3] = {
1861 /* ADC0-2 */
1862 0x07, 0x08, 0x09,
1863};
1864
1865/* The datasheet says the node 0x07 is connected from inputs,
1866 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001867 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001868 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001869static hda_nid_t alc880_adc_nids_alt[2] = {
1870 /* ADC1-2 */
1871 0x08, 0x09,
1872};
1873
1874#define ALC880_DIGOUT_NID 0x06
1875#define ALC880_DIGIN_NID 0x0a
1876
1877static struct hda_input_mux alc880_capture_source = {
1878 .num_items = 4,
1879 .items = {
1880 { "Mic", 0x0 },
1881 { "Front Mic", 0x3 },
1882 { "Line", 0x2 },
1883 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001884 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001885};
1886
1887/* channel source setting (2/6 channel selection for 3-stack) */
1888/* 2ch mode */
1889static struct hda_verb alc880_threestack_ch2_init[] = {
1890 /* set line-in to input, mute it */
1891 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1892 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1893 /* set mic-in to input vref 80%, mute it */
1894 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1895 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001896 { } /* end */
1897};
1898
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001899/* 6ch mode */
1900static struct hda_verb alc880_threestack_ch6_init[] = {
1901 /* set line-in to output, unmute it */
1902 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1903 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1904 /* set mic-in to output, unmute it */
1905 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1906 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1907 { } /* end */
1908};
1909
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001910static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001911 { 2, alc880_threestack_ch2_init },
1912 { 6, alc880_threestack_ch6_init },
1913};
1914
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001915static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001916 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001917 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001918 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001919 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001920 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1921 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001922 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1923 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001924 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1925 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1926 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1927 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1928 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1929 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1930 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1931 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001932 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001933 {
1934 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1935 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001936 .info = alc_ch_mode_info,
1937 .get = alc_ch_mode_get,
1938 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001939 },
1940 { } /* end */
1941};
1942
1943/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001944static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1945 struct snd_ctl_elem_info *uinfo)
1946{
1947 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1948 struct alc_spec *spec = codec->spec;
1949 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001950
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001951 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001952 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1953 HDA_INPUT);
1954 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001955 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001956 return err;
1957}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001958
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001959static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1960 unsigned int size, unsigned int __user *tlv)
1961{
1962 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1963 struct alc_spec *spec = codec->spec;
1964 int err;
1965
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001966 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001967 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1968 HDA_INPUT);
1969 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001970 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001971 return err;
1972}
1973
1974typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1975 struct snd_ctl_elem_value *ucontrol);
1976
1977static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1978 struct snd_ctl_elem_value *ucontrol,
1979 getput_call_t func)
1980{
1981 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1982 struct alc_spec *spec = codec->spec;
1983 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1984 int err;
1985
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001986 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001987 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1988 3, 0, HDA_INPUT);
1989 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001990 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001991 return err;
1992}
1993
1994static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1995 struct snd_ctl_elem_value *ucontrol)
1996{
1997 return alc_cap_getput_caller(kcontrol, ucontrol,
1998 snd_hda_mixer_amp_volume_get);
1999}
2000
2001static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2002 struct snd_ctl_elem_value *ucontrol)
2003{
2004 return alc_cap_getput_caller(kcontrol, ucontrol,
2005 snd_hda_mixer_amp_volume_put);
2006}
2007
2008/* capture mixer elements */
2009#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2010
2011static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2012 struct snd_ctl_elem_value *ucontrol)
2013{
2014 return alc_cap_getput_caller(kcontrol, ucontrol,
2015 snd_hda_mixer_amp_switch_get);
2016}
2017
2018static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2019 struct snd_ctl_elem_value *ucontrol)
2020{
2021 return alc_cap_getput_caller(kcontrol, ucontrol,
2022 snd_hda_mixer_amp_switch_put);
2023}
2024
Takashi Iwaia23b6882009-03-23 15:21:36 +01002025#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002026 { \
2027 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2028 .name = "Capture Switch", \
2029 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2030 .count = num, \
2031 .info = alc_cap_sw_info, \
2032 .get = alc_cap_sw_get, \
2033 .put = alc_cap_sw_put, \
2034 }, \
2035 { \
2036 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2037 .name = "Capture Volume", \
2038 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2039 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2040 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2041 .count = num, \
2042 .info = alc_cap_vol_info, \
2043 .get = alc_cap_vol_get, \
2044 .put = alc_cap_vol_put, \
2045 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002046 }
2047
2048#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002049 { \
2050 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2051 /* .name = "Capture Source", */ \
2052 .name = "Input Source", \
2053 .count = num, \
2054 .info = alc_mux_enum_info, \
2055 .get = alc_mux_enum_get, \
2056 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002057 }
2058
2059#define DEFINE_CAPMIX(num) \
2060static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2061 _DEFINE_CAPMIX(num), \
2062 _DEFINE_CAPSRC(num), \
2063 { } /* end */ \
2064}
2065
2066#define DEFINE_CAPMIX_NOSRC(num) \
2067static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2068 _DEFINE_CAPMIX(num), \
2069 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002070}
2071
2072/* up to three ADCs */
2073DEFINE_CAPMIX(1);
2074DEFINE_CAPMIX(2);
2075DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002076DEFINE_CAPMIX_NOSRC(1);
2077DEFINE_CAPMIX_NOSRC(2);
2078DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002079
2080/*
2081 * ALC880 5-stack model
2082 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002083 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2084 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002085 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2086 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2087 */
2088
2089/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002090static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002091 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002092 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002093 { } /* end */
2094};
2095
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002096/* channel source setting (6/8 channel selection for 5-stack) */
2097/* 6ch mode */
2098static struct hda_verb alc880_fivestack_ch6_init[] = {
2099 /* set line-in to input, mute it */
2100 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2101 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002102 { } /* end */
2103};
2104
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002105/* 8ch mode */
2106static struct hda_verb alc880_fivestack_ch8_init[] = {
2107 /* set line-in to output, unmute it */
2108 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2109 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2110 { } /* end */
2111};
2112
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002113static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002114 { 6, alc880_fivestack_ch6_init },
2115 { 8, alc880_fivestack_ch8_init },
2116};
2117
2118
2119/*
2120 * ALC880 6-stack model
2121 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002122 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2123 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002124 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2125 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2126 */
2127
2128static hda_nid_t alc880_6st_dac_nids[4] = {
2129 /* front, rear, clfe, rear_surr */
2130 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002131};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002132
2133static struct hda_input_mux alc880_6stack_capture_source = {
2134 .num_items = 4,
2135 .items = {
2136 { "Mic", 0x0 },
2137 { "Front Mic", 0x1 },
2138 { "Line", 0x2 },
2139 { "CD", 0x4 },
2140 },
2141};
2142
2143/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002144static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002145 { 8, NULL },
2146};
2147
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002148static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002149 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002150 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002151 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002152 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002153 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2154 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002155 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2156 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002157 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002158 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002159 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2160 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2161 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2162 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2163 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2164 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2165 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2166 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002167 {
2168 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2169 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002170 .info = alc_ch_mode_info,
2171 .get = alc_ch_mode_get,
2172 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002173 },
2174 { } /* end */
2175};
2176
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002177
2178/*
2179 * ALC880 W810 model
2180 *
2181 * W810 has rear IO for:
2182 * Front (DAC 02)
2183 * Surround (DAC 03)
2184 * Center/LFE (DAC 04)
2185 * Digital out (06)
2186 *
2187 * The system also has a pair of internal speakers, and a headphone jack.
2188 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002189 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002190 * There is a variable resistor to control the speaker or headphone
2191 * volume. This is a hardware-only device without a software API.
2192 *
2193 * Plugging headphones in will disable the internal speakers. This is
2194 * implemented in hardware, not via the driver using jack sense. In
2195 * a similar fashion, plugging into the rear socket marked "front" will
2196 * disable both the speakers and headphones.
2197 *
2198 * For input, there's a microphone jack, and an "audio in" jack.
2199 * These may not do anything useful with this driver yet, because I
2200 * haven't setup any initialization verbs for these yet...
2201 */
2202
2203static hda_nid_t alc880_w810_dac_nids[3] = {
2204 /* front, rear/surround, clfe */
2205 0x02, 0x03, 0x04
2206};
2207
2208/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002209static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002210 { 6, NULL }
2211};
2212
2213/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002214static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002215 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002216 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002217 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002218 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002219 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2220 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002221 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2222 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002223 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2224 { } /* end */
2225};
2226
2227
2228/*
2229 * Z710V model
2230 *
2231 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002232 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2233 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002234 */
2235
2236static hda_nid_t alc880_z71v_dac_nids[1] = {
2237 0x02
2238};
2239#define ALC880_Z71V_HP_DAC 0x03
2240
2241/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002242static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002243 { 2, NULL }
2244};
2245
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002246static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002247 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002248 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002249 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002250 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002251 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2252 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2254 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2255 { } /* end */
2256};
2257
2258
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002259/*
2260 * ALC880 F1734 model
2261 *
2262 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2263 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2264 */
2265
2266static hda_nid_t alc880_f1734_dac_nids[1] = {
2267 0x03
2268};
2269#define ALC880_F1734_HP_DAC 0x02
2270
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002271static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002272 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002273 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002274 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2275 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002276 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2277 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002278 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2279 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002280 { } /* end */
2281};
2282
Takashi Iwai937b4162008-02-11 14:52:36 +01002283static struct hda_input_mux alc880_f1734_capture_source = {
2284 .num_items = 2,
2285 .items = {
2286 { "Mic", 0x1 },
2287 { "CD", 0x4 },
2288 },
2289};
2290
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002291
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002292/*
2293 * ALC880 ASUS model
2294 *
2295 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2296 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2297 * Mic = 0x18, Line = 0x1a
2298 */
2299
2300#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2301#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2302
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002303static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002304 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002305 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002306 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002307 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002308 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2309 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002310 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2311 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002312 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2313 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2314 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2315 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2316 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2317 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002318 {
2319 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2320 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002321 .info = alc_ch_mode_info,
2322 .get = alc_ch_mode_get,
2323 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002324 },
2325 { } /* end */
2326};
2327
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002328/*
2329 * ALC880 ASUS W1V model
2330 *
2331 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2332 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2333 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2334 */
2335
2336/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002337static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002338 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2339 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002340 { } /* end */
2341};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002342
Kailang Yangdf694da2005-12-05 19:42:22 +01002343/* TCL S700 */
2344static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2345 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2346 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2347 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2348 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2349 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2350 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2351 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2352 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2353 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002354 { } /* end */
2355};
2356
Kailang Yangccc656c2006-10-17 12:32:26 +02002357/* Uniwill */
2358static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002359 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2360 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2361 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2362 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002363 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2364 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2365 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2366 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2367 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2368 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2369 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2370 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2371 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2372 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2373 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2374 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002375 {
2376 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2377 .name = "Channel Mode",
2378 .info = alc_ch_mode_info,
2379 .get = alc_ch_mode_get,
2380 .put = alc_ch_mode_put,
2381 },
2382 { } /* end */
2383};
2384
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002385static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2386 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2387 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2388 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2389 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2390 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2391 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2392 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2393 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2394 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2395 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2396 { } /* end */
2397};
2398
Kailang Yangccc656c2006-10-17 12:32:26 +02002399static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002400 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2401 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2402 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2403 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002404 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2405 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2406 { } /* end */
2407};
2408
Linus Torvalds1da177e2005-04-16 15:20:36 -07002409/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002410 * virtual master controls
2411 */
2412
2413/*
2414 * slave controls for virtual master
2415 */
2416static const char *alc_slave_vols[] = {
2417 "Front Playback Volume",
2418 "Surround Playback Volume",
2419 "Center Playback Volume",
2420 "LFE Playback Volume",
2421 "Side Playback Volume",
2422 "Headphone Playback Volume",
2423 "Speaker Playback Volume",
2424 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002425 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002426 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002427 NULL,
2428};
2429
2430static const char *alc_slave_sws[] = {
2431 "Front Playback Switch",
2432 "Surround Playback Switch",
2433 "Center Playback Switch",
2434 "LFE Playback Switch",
2435 "Side Playback Switch",
2436 "Headphone Playback Switch",
2437 "Speaker Playback Switch",
2438 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002439 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002440 "Line-Out Playback Switch",
2441 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002442 NULL,
2443};
2444
2445/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002446 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002447 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002448
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002449#define NID_MAPPING (-1)
2450
2451#define SUBDEV_SPEAKER_ (0 << 6)
2452#define SUBDEV_HP_ (1 << 6)
2453#define SUBDEV_LINE_ (2 << 6)
2454#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2455#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2456#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2457
Takashi Iwai603c4012008-07-30 15:01:44 +02002458static void alc_free_kctls(struct hda_codec *codec);
2459
Takashi Iwai67d634c2009-11-16 15:35:59 +01002460#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002461/* additional beep mixers; the actual parameters are overwritten at build */
2462static struct snd_kcontrol_new alc_beep_mixer[] = {
2463 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002464 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002465 { } /* end */
2466};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002467#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002468
Linus Torvalds1da177e2005-04-16 15:20:36 -07002469static int alc_build_controls(struct hda_codec *codec)
2470{
2471 struct alc_spec *spec = codec->spec;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002472 struct snd_kcontrol *kctl;
2473 struct snd_kcontrol_new *knew;
2474 int i, j, err;
2475 unsigned int u;
2476 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002477
2478 for (i = 0; i < spec->num_mixers; i++) {
2479 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2480 if (err < 0)
2481 return err;
2482 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002483 if (spec->cap_mixer) {
2484 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2485 if (err < 0)
2486 return err;
2487 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002488 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002489 err = snd_hda_create_spdif_out_ctls(codec,
2490 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002491 if (err < 0)
2492 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002493 if (!spec->no_analog) {
2494 err = snd_hda_create_spdif_share_sw(codec,
2495 &spec->multiout);
2496 if (err < 0)
2497 return err;
2498 spec->multiout.share_spdif = 1;
2499 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002500 }
2501 if (spec->dig_in_nid) {
2502 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2503 if (err < 0)
2504 return err;
2505 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002506
Takashi Iwai67d634c2009-11-16 15:35:59 +01002507#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002508 /* create beep controls if needed */
2509 if (spec->beep_amp) {
2510 struct snd_kcontrol_new *knew;
2511 for (knew = alc_beep_mixer; knew->name; knew++) {
2512 struct snd_kcontrol *kctl;
2513 kctl = snd_ctl_new1(knew, codec);
2514 if (!kctl)
2515 return -ENOMEM;
2516 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002517 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002518 if (err < 0)
2519 return err;
2520 }
2521 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002522#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002523
Takashi Iwai2134ea42008-01-10 16:53:55 +01002524 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002525 if (!spec->no_analog &&
2526 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002527 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002528 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002529 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002530 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002531 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002532 if (err < 0)
2533 return err;
2534 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002535 if (!spec->no_analog &&
2536 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002537 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2538 NULL, alc_slave_sws);
2539 if (err < 0)
2540 return err;
2541 }
2542
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002543 /* assign Capture Source enums to NID */
2544 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2545 if (!kctl)
2546 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2547 for (i = 0; kctl && i < kctl->count; i++) {
Takashi Iwaid1409ae2009-12-17 15:01:31 +01002548 hda_nid_t *nids = spec->capsrc_nids;
2549 if (!nids)
2550 nids = spec->adc_nids;
Takashi Iwai21949f02009-12-23 08:31:59 +01002551 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002552 if (err < 0)
2553 return err;
2554 }
2555 if (spec->cap_mixer) {
2556 const char *kname = kctl ? kctl->id.name : NULL;
2557 for (knew = spec->cap_mixer; knew->name; knew++) {
2558 if (kname && strcmp(knew->name, kname) == 0)
2559 continue;
2560 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2561 for (i = 0; kctl && i < kctl->count; i++) {
2562 err = snd_hda_add_nid(codec, kctl, i,
2563 spec->adc_nids[i]);
2564 if (err < 0)
2565 return err;
2566 }
2567 }
2568 }
2569
2570 /* other nid->control mapping */
2571 for (i = 0; i < spec->num_mixers; i++) {
2572 for (knew = spec->mixers[i]; knew->name; knew++) {
2573 if (knew->iface != NID_MAPPING)
2574 continue;
2575 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2576 if (kctl == NULL)
2577 continue;
2578 u = knew->subdevice;
2579 for (j = 0; j < 4; j++, u >>= 8) {
2580 nid = u & 0x3f;
2581 if (nid == 0)
2582 continue;
2583 switch (u & 0xc0) {
2584 case SUBDEV_SPEAKER_:
2585 nid = spec->autocfg.speaker_pins[nid];
2586 break;
2587 case SUBDEV_LINE_:
2588 nid = spec->autocfg.line_out_pins[nid];
2589 break;
2590 case SUBDEV_HP_:
2591 nid = spec->autocfg.hp_pins[nid];
2592 break;
2593 default:
2594 continue;
2595 }
2596 err = snd_hda_add_nid(codec, kctl, 0, nid);
2597 if (err < 0)
2598 return err;
2599 }
2600 u = knew->private_value;
2601 for (j = 0; j < 4; j++, u >>= 8) {
2602 nid = u & 0xff;
2603 if (nid == 0)
2604 continue;
2605 err = snd_hda_add_nid(codec, kctl, 0, nid);
2606 if (err < 0)
2607 return err;
2608 }
2609 }
2610 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01002611
2612 alc_free_kctls(codec); /* no longer needed */
2613
Linus Torvalds1da177e2005-04-16 15:20:36 -07002614 return 0;
2615}
2616
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002617
Linus Torvalds1da177e2005-04-16 15:20:36 -07002618/*
2619 * initialize the codec volumes, etc
2620 */
2621
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002622/*
2623 * generic initialization of ADC, input mixers and output mixers
2624 */
2625static struct hda_verb alc880_volume_init_verbs[] = {
2626 /*
2627 * Unmute ADC0-2 and set the default input to mic-in
2628 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002629 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002630 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002631 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002632 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002633 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002634 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002635
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002636 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2637 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002638 * Note: PASD motherboards uses the Line In 2 as the input for front
2639 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002640 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002641 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2645 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2646 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2647 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2648 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002649
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002650 /*
2651 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002652 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002653 /* set vol=0 to output mixers */
2654 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2655 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2656 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2657 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2658 /* set up input amps for analog loopback */
2659 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002660 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2661 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002662 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2663 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002664 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2665 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002666 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2667 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002668
2669 { }
2670};
2671
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002672/*
2673 * 3-stack pin configuration:
2674 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2675 */
2676static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2677 /*
2678 * preset connection lists of input pins
2679 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2680 */
2681 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2682 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2683 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2684
2685 /*
2686 * Set pin mode and muting
2687 */
2688 /* set front pin widgets 0x14 for output */
2689 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2690 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2691 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2692 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2693 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2694 /* Mic2 (as headphone out) for HP output */
2695 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2696 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2697 /* Line In pin widget for input */
2698 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2699 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2700 /* Line2 (as front mic) pin widget for input and vref at 80% */
2701 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2702 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2703 /* CD pin widget for input */
2704 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2705
2706 { }
2707};
2708
2709/*
2710 * 5-stack pin configuration:
2711 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2712 * line-in/side = 0x1a, f-mic = 0x1b
2713 */
2714static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2715 /*
2716 * preset connection lists of input pins
2717 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2718 */
2719 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2720 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2721
2722 /*
2723 * Set pin mode and muting
2724 */
2725 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002726 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2727 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2728 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2729 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002730 /* unmute pins for output (no gain on this amp) */
2731 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2732 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2733 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2734 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2735
Linus Torvalds1da177e2005-04-16 15:20:36 -07002736 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002737 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002738 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2739 /* Mic2 (as headphone out) for HP output */
2740 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002741 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002742 /* Line In pin widget for input */
2743 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2744 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2745 /* Line2 (as front mic) pin widget for input and vref at 80% */
2746 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2747 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2748 /* CD pin widget for input */
2749 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002750
2751 { }
2752};
2753
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002754/*
2755 * W810 pin configuration:
2756 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2757 */
2758static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002759 /* hphone/speaker input selector: front DAC */
2760 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2761
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002762 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2763 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2764 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2765 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2766 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2767 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2768
2769 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002770 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002771
Linus Torvalds1da177e2005-04-16 15:20:36 -07002772 { }
2773};
2774
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002775/*
2776 * Z71V pin configuration:
2777 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2778 */
2779static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002780 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002781 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002782 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002783 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002784
Takashi Iwai16ded522005-06-10 19:58:24 +02002785 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002786 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002787 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002788 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002789
2790 { }
2791};
2792
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002793/*
2794 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002795 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2796 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002797 */
2798static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2799 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2800
Takashi Iwai16ded522005-06-10 19:58:24 +02002801 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002802 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002803 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002804 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002805 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002806 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002807 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002808 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2809
Takashi Iwai16ded522005-06-10 19:58:24 +02002810 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002811 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002812 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002813 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002814 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002815 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002816 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002817 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002818 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002819
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002820 { }
2821};
Takashi Iwai16ded522005-06-10 19:58:24 +02002822
Kailang Yangccc656c2006-10-17 12:32:26 +02002823/*
2824 * Uniwill pin configuration:
2825 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2826 * line = 0x1a
2827 */
2828static struct hda_verb alc880_uniwill_init_verbs[] = {
2829 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2830
2831 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2832 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2833 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2834 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2835 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2836 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2837 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2838 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2839 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2840 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2841 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2842 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2843 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2844 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2845
2846 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2847 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2848 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2849 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2850 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2851 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2852 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2853 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2854 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2855
2856 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2857 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2858
2859 { }
2860};
2861
2862/*
2863* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002864* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002865 */
2866static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2867 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2868
2869 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2870 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2871 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2872 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2873 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2874 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2875 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2876 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2877 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2878 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2879 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2880 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2881
2882 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2883 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2884 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2885 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2886 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2887 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2888
2889 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2890 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2891
2892 { }
2893};
2894
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002895static struct hda_verb alc880_beep_init_verbs[] = {
2896 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2897 { }
2898};
2899
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002900/* auto-toggle front mic */
2901static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2902{
2903 unsigned int present;
2904 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002905
Wu Fengguang864f92b2009-11-18 12:38:02 +08002906 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002907 bits = present ? HDA_AMP_MUTE : 0;
2908 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002909}
2910
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002911static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002912{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002913 struct alc_spec *spec = codec->spec;
2914
2915 spec->autocfg.hp_pins[0] = 0x14;
2916 spec->autocfg.speaker_pins[0] = 0x15;
2917 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002918}
2919
2920static void alc880_uniwill_init_hook(struct hda_codec *codec)
2921{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002922 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002923 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002924}
2925
2926static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2927 unsigned int res)
2928{
2929 /* Looks like the unsol event is incompatible with the standard
2930 * definition. 4bit tag is placed at 28 bit!
2931 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002932 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002933 case ALC880_MIC_EVENT:
2934 alc880_uniwill_mic_automute(codec);
2935 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002936 default:
2937 alc_automute_amp_unsol_event(codec, res);
2938 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002939 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002940}
2941
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002942static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002943{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002944 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002945
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002946 spec->autocfg.hp_pins[0] = 0x14;
2947 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002948}
2949
2950static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2951{
2952 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002953
Kailang Yangccc656c2006-10-17 12:32:26 +02002954 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002955 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2956 present &= HDA_AMP_VOLMASK;
2957 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2958 HDA_AMP_VOLMASK, present);
2959 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2960 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002961}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002962
Kailang Yangccc656c2006-10-17 12:32:26 +02002963static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2964 unsigned int res)
2965{
2966 /* Looks like the unsol event is incompatible with the standard
2967 * definition. 4bit tag is placed at 28 bit!
2968 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002969 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002970 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002971 else
2972 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002973}
2974
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002975/*
2976 * F1734 pin configuration:
2977 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2978 */
2979static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002980 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002981 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2982 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2983 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2984 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2985
2986 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2987 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2988 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2989 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2990
2991 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2992 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002993 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002994 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2995 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2996 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2997 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2998 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2999 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003000
Takashi Iwai937b4162008-02-11 14:52:36 +01003001 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3002 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3003
Takashi Iwai16ded522005-06-10 19:58:24 +02003004 { }
3005};
3006
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003007/*
3008 * ASUS pin configuration:
3009 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3010 */
3011static struct hda_verb alc880_pin_asus_init_verbs[] = {
3012 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3013 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3014 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3015 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3016
3017 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3018 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3019 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3020 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3021 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3022 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3023 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3024 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3025
3026 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3027 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3028 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3029 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3030 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3031 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3032 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3033 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3034 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003035
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003036 { }
3037};
3038
3039/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003040#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3041#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003042#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003043
Kailang Yangdf694da2005-12-05 19:42:22 +01003044/* Clevo m520g init */
3045static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3046 /* headphone output */
3047 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3048 /* line-out */
3049 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3050 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3051 /* Line-in */
3052 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3053 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3054 /* CD */
3055 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3056 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3057 /* Mic1 (rear panel) */
3058 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3059 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3060 /* Mic2 (front panel) */
3061 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3062 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3063 /* headphone */
3064 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3065 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3066 /* change to EAPD mode */
3067 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3068 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3069
3070 { }
3071};
3072
3073static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003074 /* change to EAPD mode */
3075 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3076 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3077
Kailang Yangdf694da2005-12-05 19:42:22 +01003078 /* Headphone output */
3079 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3080 /* Front output*/
3081 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3082 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3083
3084 /* Line In pin widget for input */
3085 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3086 /* CD pin widget for input */
3087 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3088 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3089 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3090
3091 /* change to EAPD mode */
3092 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3093 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3094
3095 { }
3096};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003097
3098/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003099 * LG m1 express dual
3100 *
3101 * Pin assignment:
3102 * Rear Line-In/Out (blue): 0x14
3103 * Build-in Mic-In: 0x15
3104 * Speaker-out: 0x17
3105 * HP-Out (green): 0x1b
3106 * Mic-In/Out (red): 0x19
3107 * SPDIF-Out: 0x1e
3108 */
3109
3110/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3111static hda_nid_t alc880_lg_dac_nids[3] = {
3112 0x05, 0x02, 0x03
3113};
3114
3115/* seems analog CD is not working */
3116static struct hda_input_mux alc880_lg_capture_source = {
3117 .num_items = 3,
3118 .items = {
3119 { "Mic", 0x1 },
3120 { "Line", 0x5 },
3121 { "Internal Mic", 0x6 },
3122 },
3123};
3124
3125/* 2,4,6 channel modes */
3126static struct hda_verb alc880_lg_ch2_init[] = {
3127 /* set line-in and mic-in to input */
3128 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3129 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3130 { }
3131};
3132
3133static struct hda_verb alc880_lg_ch4_init[] = {
3134 /* set line-in to out and mic-in to input */
3135 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3136 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3137 { }
3138};
3139
3140static struct hda_verb alc880_lg_ch6_init[] = {
3141 /* set line-in and mic-in to output */
3142 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3143 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3144 { }
3145};
3146
3147static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3148 { 2, alc880_lg_ch2_init },
3149 { 4, alc880_lg_ch4_init },
3150 { 6, alc880_lg_ch6_init },
3151};
3152
3153static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003154 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3155 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003156 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3157 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3158 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3159 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3160 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3161 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3164 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3165 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3166 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3167 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3168 {
3169 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3170 .name = "Channel Mode",
3171 .info = alc_ch_mode_info,
3172 .get = alc_ch_mode_get,
3173 .put = alc_ch_mode_put,
3174 },
3175 { } /* end */
3176};
3177
3178static struct hda_verb alc880_lg_init_verbs[] = {
3179 /* set capture source to mic-in */
3180 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3181 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3182 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3183 /* mute all amp mixer inputs */
3184 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003185 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3186 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003187 /* line-in to input */
3188 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3189 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3190 /* built-in mic */
3191 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3193 /* speaker-out */
3194 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3195 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3196 /* mic-in to input */
3197 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3198 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3199 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3200 /* HP-out */
3201 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3202 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3203 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3204 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003205 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003206 { }
3207};
3208
3209/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003210static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003211{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003212 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003213
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003214 spec->autocfg.hp_pins[0] = 0x1b;
3215 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003216}
3217
3218/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003219 * LG LW20
3220 *
3221 * Pin assignment:
3222 * Speaker-out: 0x14
3223 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003224 * Built-in Mic-In: 0x19
3225 * Line-In: 0x1b
3226 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003227 * SPDIF-Out: 0x1e
3228 */
3229
Takashi Iwaid6815182006-03-23 16:06:23 +01003230static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003231 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003232 .items = {
3233 { "Mic", 0x0 },
3234 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003235 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003236 },
3237};
3238
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003239#define alc880_lg_lw_modes alc880_threestack_modes
3240
Takashi Iwaid6815182006-03-23 16:06:23 +01003241static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003242 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3243 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3244 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3245 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3246 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3247 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3248 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3249 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3250 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3251 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003252 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3253 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3254 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3255 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003256 {
3257 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3258 .name = "Channel Mode",
3259 .info = alc_ch_mode_info,
3260 .get = alc_ch_mode_get,
3261 .put = alc_ch_mode_put,
3262 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003263 { } /* end */
3264};
3265
3266static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003267 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3268 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3269 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3270
Takashi Iwaid6815182006-03-23 16:06:23 +01003271 /* set capture source to mic-in */
3272 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3273 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3274 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003275 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003276 /* speaker-out */
3277 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3278 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3279 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003280 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3281 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3282 /* mic-in to input */
3283 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3284 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3285 /* built-in mic */
3286 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3287 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3288 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003289 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003290 { }
3291};
3292
3293/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003294static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003295{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003296 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003297
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003298 spec->autocfg.hp_pins[0] = 0x1b;
3299 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003300}
3301
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003302static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3303 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3304 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3305 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3306 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3307 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3308 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3309 { } /* end */
3310};
3311
3312static struct hda_input_mux alc880_medion_rim_capture_source = {
3313 .num_items = 2,
3314 .items = {
3315 { "Mic", 0x0 },
3316 { "Internal Mic", 0x1 },
3317 },
3318};
3319
3320static struct hda_verb alc880_medion_rim_init_verbs[] = {
3321 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3322
3323 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3324 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3325
3326 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3327 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3328 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3329 /* Mic2 (as headphone out) for HP output */
3330 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3331 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3332 /* Internal Speaker */
3333 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3334 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3335
3336 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3337 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3338
3339 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3340 { }
3341};
3342
3343/* toggle speaker-output according to the hp-jack state */
3344static void alc880_medion_rim_automute(struct hda_codec *codec)
3345{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003346 struct alc_spec *spec = codec->spec;
3347 alc_automute_amp(codec);
3348 /* toggle EAPD */
3349 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003350 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3351 else
3352 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3353}
3354
3355static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3356 unsigned int res)
3357{
3358 /* Looks like the unsol event is incompatible with the standard
3359 * definition. 4bit tag is placed at 28 bit!
3360 */
3361 if ((res >> 28) == ALC880_HP_EVENT)
3362 alc880_medion_rim_automute(codec);
3363}
3364
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003365static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003366{
3367 struct alc_spec *spec = codec->spec;
3368
3369 spec->autocfg.hp_pins[0] = 0x14;
3370 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003371}
3372
Takashi Iwaicb53c622007-08-10 17:21:45 +02003373#ifdef CONFIG_SND_HDA_POWER_SAVE
3374static struct hda_amp_list alc880_loopbacks[] = {
3375 { 0x0b, HDA_INPUT, 0 },
3376 { 0x0b, HDA_INPUT, 1 },
3377 { 0x0b, HDA_INPUT, 2 },
3378 { 0x0b, HDA_INPUT, 3 },
3379 { 0x0b, HDA_INPUT, 4 },
3380 { } /* end */
3381};
3382
3383static struct hda_amp_list alc880_lg_loopbacks[] = {
3384 { 0x0b, HDA_INPUT, 1 },
3385 { 0x0b, HDA_INPUT, 6 },
3386 { 0x0b, HDA_INPUT, 7 },
3387 { } /* end */
3388};
3389#endif
3390
Takashi Iwaid6815182006-03-23 16:06:23 +01003391/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003392 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003393 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003394
Linus Torvalds1da177e2005-04-16 15:20:36 -07003395static int alc_init(struct hda_codec *codec)
3396{
3397 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003398 unsigned int i;
3399
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003400 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003401 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003402
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003403 for (i = 0; i < spec->num_init_verbs; i++)
3404 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003405
3406 if (spec->init_hook)
3407 spec->init_hook(codec);
3408
Linus Torvalds1da177e2005-04-16 15:20:36 -07003409 return 0;
3410}
3411
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003412static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3413{
3414 struct alc_spec *spec = codec->spec;
3415
3416 if (spec->unsol_event)
3417 spec->unsol_event(codec, res);
3418}
3419
Takashi Iwaicb53c622007-08-10 17:21:45 +02003420#ifdef CONFIG_SND_HDA_POWER_SAVE
3421static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3422{
3423 struct alc_spec *spec = codec->spec;
3424 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3425}
3426#endif
3427
Linus Torvalds1da177e2005-04-16 15:20:36 -07003428/*
3429 * Analog playback callbacks
3430 */
3431static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3432 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003433 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003434{
3435 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003436 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3437 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003438}
3439
3440static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3441 struct hda_codec *codec,
3442 unsigned int stream_tag,
3443 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003444 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003445{
3446 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003447 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3448 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003449}
3450
3451static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3452 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003453 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003454{
3455 struct alc_spec *spec = codec->spec;
3456 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3457}
3458
3459/*
3460 * Digital out
3461 */
3462static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3463 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003464 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003465{
3466 struct alc_spec *spec = codec->spec;
3467 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3468}
3469
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003470static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3471 struct hda_codec *codec,
3472 unsigned int stream_tag,
3473 unsigned int format,
3474 struct snd_pcm_substream *substream)
3475{
3476 struct alc_spec *spec = codec->spec;
3477 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3478 stream_tag, format, substream);
3479}
3480
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003481static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3482 struct hda_codec *codec,
3483 struct snd_pcm_substream *substream)
3484{
3485 struct alc_spec *spec = codec->spec;
3486 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3487}
3488
Linus Torvalds1da177e2005-04-16 15:20:36 -07003489static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3490 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003491 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003492{
3493 struct alc_spec *spec = codec->spec;
3494 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3495}
3496
3497/*
3498 * Analog capture
3499 */
Takashi Iwai63300792008-01-24 15:31:36 +01003500static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003501 struct hda_codec *codec,
3502 unsigned int stream_tag,
3503 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003504 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003505{
3506 struct alc_spec *spec = codec->spec;
3507
Takashi Iwai63300792008-01-24 15:31:36 +01003508 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003509 stream_tag, 0, format);
3510 return 0;
3511}
3512
Takashi Iwai63300792008-01-24 15:31:36 +01003513static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003514 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003515 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003516{
3517 struct alc_spec *spec = codec->spec;
3518
Takashi Iwai888afa12008-03-18 09:57:50 +01003519 snd_hda_codec_cleanup_stream(codec,
3520 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003521 return 0;
3522}
3523
3524
3525/*
3526 */
3527static struct hda_pcm_stream alc880_pcm_analog_playback = {
3528 .substreams = 1,
3529 .channels_min = 2,
3530 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003531 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003532 .ops = {
3533 .open = alc880_playback_pcm_open,
3534 .prepare = alc880_playback_pcm_prepare,
3535 .cleanup = alc880_playback_pcm_cleanup
3536 },
3537};
3538
3539static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003540 .substreams = 1,
3541 .channels_min = 2,
3542 .channels_max = 2,
3543 /* NID is set in alc_build_pcms */
3544};
3545
3546static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3547 .substreams = 1,
3548 .channels_min = 2,
3549 .channels_max = 2,
3550 /* NID is set in alc_build_pcms */
3551};
3552
3553static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3554 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003555 .channels_min = 2,
3556 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003557 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003558 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003559 .prepare = alc880_alt_capture_pcm_prepare,
3560 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003561 },
3562};
3563
3564static struct hda_pcm_stream alc880_pcm_digital_playback = {
3565 .substreams = 1,
3566 .channels_min = 2,
3567 .channels_max = 2,
3568 /* NID is set in alc_build_pcms */
3569 .ops = {
3570 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003571 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003572 .prepare = alc880_dig_playback_pcm_prepare,
3573 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003574 },
3575};
3576
3577static struct hda_pcm_stream alc880_pcm_digital_capture = {
3578 .substreams = 1,
3579 .channels_min = 2,
3580 .channels_max = 2,
3581 /* NID is set in alc_build_pcms */
3582};
3583
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003584/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003585static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003586 .substreams = 0,
3587 .channels_min = 0,
3588 .channels_max = 0,
3589};
3590
Linus Torvalds1da177e2005-04-16 15:20:36 -07003591static int alc_build_pcms(struct hda_codec *codec)
3592{
3593 struct alc_spec *spec = codec->spec;
3594 struct hda_pcm *info = spec->pcm_rec;
3595 int i;
3596
3597 codec->num_pcms = 1;
3598 codec->pcm_info = info;
3599
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003600 if (spec->no_analog)
3601 goto skip_analog;
3602
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003603 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3604 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003605 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003606
Takashi Iwai4a471b72005-12-07 13:56:29 +01003607 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003608 if (snd_BUG_ON(!spec->multiout.dac_nids))
3609 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003610 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3611 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3612 }
3613 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003614 if (snd_BUG_ON(!spec->adc_nids))
3615 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003616 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3617 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3618 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003619
Takashi Iwai4a471b72005-12-07 13:56:29 +01003620 if (spec->channel_mode) {
3621 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3622 for (i = 0; i < spec->num_channel_mode; i++) {
3623 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3624 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3625 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003626 }
3627 }
3628
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003629 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003630 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003631 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003632 snprintf(spec->stream_name_digital,
3633 sizeof(spec->stream_name_digital),
3634 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003635 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003636 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003637 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003638 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003639 if (spec->dig_out_type)
3640 info->pcm_type = spec->dig_out_type;
3641 else
3642 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003643 if (spec->multiout.dig_out_nid &&
3644 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003645 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3646 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3647 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003648 if (spec->dig_in_nid &&
3649 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003650 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3651 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3652 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003653 /* FIXME: do we need this for all Realtek codec models? */
3654 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003655 }
3656
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003657 if (spec->no_analog)
3658 return 0;
3659
Takashi Iwaie08a0072006-09-07 17:52:14 +02003660 /* If the use of more than one ADC is requested for the current
3661 * model, configure a second analog capture-only PCM.
3662 */
3663 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003664 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3665 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003666 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003667 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003668 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003669 if (spec->alt_dac_nid) {
3670 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3671 *spec->stream_analog_alt_playback;
3672 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3673 spec->alt_dac_nid;
3674 } else {
3675 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3676 alc_pcm_null_stream;
3677 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3678 }
3679 if (spec->num_adc_nids > 1) {
3680 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3681 *spec->stream_analog_alt_capture;
3682 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3683 spec->adc_nids[1];
3684 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3685 spec->num_adc_nids - 1;
3686 } else {
3687 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3688 alc_pcm_null_stream;
3689 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003690 }
3691 }
3692
Linus Torvalds1da177e2005-04-16 15:20:36 -07003693 return 0;
3694}
3695
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003696static inline void alc_shutup(struct hda_codec *codec)
3697{
3698 snd_hda_shutup_pins(codec);
3699}
3700
Takashi Iwai603c4012008-07-30 15:01:44 +02003701static void alc_free_kctls(struct hda_codec *codec)
3702{
3703 struct alc_spec *spec = codec->spec;
3704
3705 if (spec->kctls.list) {
3706 struct snd_kcontrol_new *kctl = spec->kctls.list;
3707 int i;
3708 for (i = 0; i < spec->kctls.used; i++)
3709 kfree(kctl[i].name);
3710 }
3711 snd_array_free(&spec->kctls);
3712}
3713
Linus Torvalds1da177e2005-04-16 15:20:36 -07003714static void alc_free(struct hda_codec *codec)
3715{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003716 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003717
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003718 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003719 return;
3720
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003721 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02003722 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003723 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003724 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003725}
3726
Hector Martinf5de24b2009-12-20 22:51:31 +01003727#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05003728static void alc_power_eapd(struct hda_codec *codec)
3729{
3730 /* We currently only handle front, HP */
3731 switch (codec->vendor_id) {
3732 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003733 set_eapd(codec, 0x0f, 0);
3734 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003735 break;
3736 case 0x10ec0262:
3737 case 0x10ec0267:
3738 case 0x10ec0268:
3739 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003740 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05003741 case 0x10ec0272:
3742 case 0x10ec0660:
3743 case 0x10ec0662:
3744 case 0x10ec0663:
3745 case 0x10ec0862:
3746 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003747 set_eapd(codec, 0x14, 0);
3748 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003749 break;
3750 }
3751}
3752
Hector Martinf5de24b2009-12-20 22:51:31 +01003753static int alc_suspend(struct hda_codec *codec, pm_message_t state)
3754{
3755 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003756 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003757 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05003758 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003759 return 0;
3760}
3761#endif
3762
Takashi Iwaie044c392008-10-27 16:56:24 +01003763#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003764static int alc_resume(struct hda_codec *codec)
3765{
Takashi Iwaie044c392008-10-27 16:56:24 +01003766 codec->patch_ops.init(codec);
3767 snd_hda_codec_resume_amp(codec);
3768 snd_hda_codec_resume_cache(codec);
3769 return 0;
3770}
Takashi Iwaie044c392008-10-27 16:56:24 +01003771#endif
3772
Linus Torvalds1da177e2005-04-16 15:20:36 -07003773/*
3774 */
3775static struct hda_codec_ops alc_patch_ops = {
3776 .build_controls = alc_build_controls,
3777 .build_pcms = alc_build_pcms,
3778 .init = alc_init,
3779 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003780 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003781#ifdef SND_HDA_NEEDS_RESUME
3782 .resume = alc_resume,
3783#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003784#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01003785 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003786 .check_power_status = alc_check_power_status,
3787#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05003788 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003789};
3790
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003791
3792/*
3793 * Test configuration for debugging
3794 *
3795 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3796 * enum controls.
3797 */
3798#ifdef CONFIG_SND_DEBUG
3799static hda_nid_t alc880_test_dac_nids[4] = {
3800 0x02, 0x03, 0x04, 0x05
3801};
3802
3803static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003804 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003805 .items = {
3806 { "In-1", 0x0 },
3807 { "In-2", 0x1 },
3808 { "In-3", 0x2 },
3809 { "In-4", 0x3 },
3810 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003811 { "Front", 0x5 },
3812 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003813 },
3814};
3815
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003816static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003817 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003818 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003819 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003820 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003821};
3822
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003823static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3824 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003825{
3826 static char *texts[] = {
3827 "N/A", "Line Out", "HP Out",
3828 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3829 };
3830 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3831 uinfo->count = 1;
3832 uinfo->value.enumerated.items = 8;
3833 if (uinfo->value.enumerated.item >= 8)
3834 uinfo->value.enumerated.item = 7;
3835 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3836 return 0;
3837}
3838
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003839static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3840 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003841{
3842 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3843 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3844 unsigned int pin_ctl, item = 0;
3845
3846 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3847 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3848 if (pin_ctl & AC_PINCTL_OUT_EN) {
3849 if (pin_ctl & AC_PINCTL_HP_EN)
3850 item = 2;
3851 else
3852 item = 1;
3853 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3854 switch (pin_ctl & AC_PINCTL_VREFEN) {
3855 case AC_PINCTL_VREF_HIZ: item = 3; break;
3856 case AC_PINCTL_VREF_50: item = 4; break;
3857 case AC_PINCTL_VREF_GRD: item = 5; break;
3858 case AC_PINCTL_VREF_80: item = 6; break;
3859 case AC_PINCTL_VREF_100: item = 7; break;
3860 }
3861 }
3862 ucontrol->value.enumerated.item[0] = item;
3863 return 0;
3864}
3865
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003866static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3867 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003868{
3869 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3870 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3871 static unsigned int ctls[] = {
3872 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3873 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3874 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3875 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3876 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3877 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3878 };
3879 unsigned int old_ctl, new_ctl;
3880
3881 old_ctl = snd_hda_codec_read(codec, nid, 0,
3882 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3883 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3884 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003885 int val;
3886 snd_hda_codec_write_cache(codec, nid, 0,
3887 AC_VERB_SET_PIN_WIDGET_CONTROL,
3888 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003889 val = ucontrol->value.enumerated.item[0] >= 3 ?
3890 HDA_AMP_MUTE : 0;
3891 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3892 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003893 return 1;
3894 }
3895 return 0;
3896}
3897
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003898static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3899 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003900{
3901 static char *texts[] = {
3902 "Front", "Surround", "CLFE", "Side"
3903 };
3904 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3905 uinfo->count = 1;
3906 uinfo->value.enumerated.items = 4;
3907 if (uinfo->value.enumerated.item >= 4)
3908 uinfo->value.enumerated.item = 3;
3909 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3910 return 0;
3911}
3912
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003913static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3914 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003915{
3916 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3917 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3918 unsigned int sel;
3919
3920 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3921 ucontrol->value.enumerated.item[0] = sel & 3;
3922 return 0;
3923}
3924
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003925static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3926 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003927{
3928 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3929 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3930 unsigned int sel;
3931
3932 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3933 if (ucontrol->value.enumerated.item[0] != sel) {
3934 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003935 snd_hda_codec_write_cache(codec, nid, 0,
3936 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003937 return 1;
3938 }
3939 return 0;
3940}
3941
3942#define PIN_CTL_TEST(xname,nid) { \
3943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3944 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003945 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003946 .info = alc_test_pin_ctl_info, \
3947 .get = alc_test_pin_ctl_get, \
3948 .put = alc_test_pin_ctl_put, \
3949 .private_value = nid \
3950 }
3951
3952#define PIN_SRC_TEST(xname,nid) { \
3953 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3954 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003955 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003956 .info = alc_test_pin_src_info, \
3957 .get = alc_test_pin_src_get, \
3958 .put = alc_test_pin_src_put, \
3959 .private_value = nid \
3960 }
3961
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003962static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003963 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3964 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3965 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3966 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003967 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3968 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3969 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3970 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003971 PIN_CTL_TEST("Front Pin Mode", 0x14),
3972 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3973 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3974 PIN_CTL_TEST("Side Pin Mode", 0x17),
3975 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3976 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3977 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3978 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3979 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3980 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3981 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3982 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3983 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3984 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3985 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3986 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3987 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3988 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3989 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3990 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3991 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3992 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003993 {
3994 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3995 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003996 .info = alc_ch_mode_info,
3997 .get = alc_ch_mode_get,
3998 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003999 },
4000 { } /* end */
4001};
4002
4003static struct hda_verb alc880_test_init_verbs[] = {
4004 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004005 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4006 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4007 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4008 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4009 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4010 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4011 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4012 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004013 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004014 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4015 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4016 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4017 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004018 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004019 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4020 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4021 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4022 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004023 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004024 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4025 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4026 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4027 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004028 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004029 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4030 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004031 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4032 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4033 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004034 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004035 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4036 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4037 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4038 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004039 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004040 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004041 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004042 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004043 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004044 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004045 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004046 /* Analog input/passthru */
4047 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4048 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4049 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4050 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4051 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004052 { }
4053};
4054#endif
4055
Linus Torvalds1da177e2005-04-16 15:20:36 -07004056/*
4057 */
4058
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004059static const char *alc880_models[ALC880_MODEL_LAST] = {
4060 [ALC880_3ST] = "3stack",
4061 [ALC880_TCL_S700] = "tcl",
4062 [ALC880_3ST_DIG] = "3stack-digout",
4063 [ALC880_CLEVO] = "clevo",
4064 [ALC880_5ST] = "5stack",
4065 [ALC880_5ST_DIG] = "5stack-digout",
4066 [ALC880_W810] = "w810",
4067 [ALC880_Z71V] = "z71v",
4068 [ALC880_6ST] = "6stack",
4069 [ALC880_6ST_DIG] = "6stack-digout",
4070 [ALC880_ASUS] = "asus",
4071 [ALC880_ASUS_W1V] = "asus-w1v",
4072 [ALC880_ASUS_DIG] = "asus-dig",
4073 [ALC880_ASUS_DIG2] = "asus-dig2",
4074 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004075 [ALC880_UNIWILL_P53] = "uniwill-p53",
4076 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004077 [ALC880_F1734] = "F1734",
4078 [ALC880_LG] = "lg",
4079 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004080 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004081#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004082 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004083#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004084 [ALC880_AUTO] = "auto",
4085};
4086
4087static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004088 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004089 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4090 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4091 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4092 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4093 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4094 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4095 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4096 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004097 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4098 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004099 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4100 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4101 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4102 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4103 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4104 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4105 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4106 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4107 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4108 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004109 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004110 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4111 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4112 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004113 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004114 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004115 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4116 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004117 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4118 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004119 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4120 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4121 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4122 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004123 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4124 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004125 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004126 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004127 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004128 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004129 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4130 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004131 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004132 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004133 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004134 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004135 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004136 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004137 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004138 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004139 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004140 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4141 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004142 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004143 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4144 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4145 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4146 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004147 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4148 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004149 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004150 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004151 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4152 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004153 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4154 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4155 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004156 /* default Intel */
4157 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004158 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4159 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004160 {}
4161};
4162
Takashi Iwai16ded522005-06-10 19:58:24 +02004163/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004164 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004165 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004166static struct alc_config_preset alc880_presets[] = {
4167 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004168 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004169 .init_verbs = { alc880_volume_init_verbs,
4170 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004171 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004172 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004173 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4174 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004175 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004176 .input_mux = &alc880_capture_source,
4177 },
4178 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004179 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004180 .init_verbs = { alc880_volume_init_verbs,
4181 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004182 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004183 .dac_nids = alc880_dac_nids,
4184 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004185 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4186 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004187 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004188 .input_mux = &alc880_capture_source,
4189 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004190 [ALC880_TCL_S700] = {
4191 .mixers = { alc880_tcl_s700_mixer },
4192 .init_verbs = { alc880_volume_init_verbs,
4193 alc880_pin_tcl_S700_init_verbs,
4194 alc880_gpio2_init_verbs },
4195 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4196 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004197 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4198 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004199 .hp_nid = 0x03,
4200 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4201 .channel_mode = alc880_2_jack_modes,
4202 .input_mux = &alc880_capture_source,
4203 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004204 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004205 .mixers = { alc880_three_stack_mixer,
4206 alc880_five_stack_mixer},
4207 .init_verbs = { alc880_volume_init_verbs,
4208 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004209 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4210 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004211 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4212 .channel_mode = alc880_fivestack_modes,
4213 .input_mux = &alc880_capture_source,
4214 },
4215 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004216 .mixers = { alc880_three_stack_mixer,
4217 alc880_five_stack_mixer },
4218 .init_verbs = { alc880_volume_init_verbs,
4219 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004220 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4221 .dac_nids = alc880_dac_nids,
4222 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004223 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4224 .channel_mode = alc880_fivestack_modes,
4225 .input_mux = &alc880_capture_source,
4226 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004227 [ALC880_6ST] = {
4228 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004229 .init_verbs = { alc880_volume_init_verbs,
4230 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004231 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4232 .dac_nids = alc880_6st_dac_nids,
4233 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4234 .channel_mode = alc880_sixstack_modes,
4235 .input_mux = &alc880_6stack_capture_source,
4236 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004237 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004238 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004239 .init_verbs = { alc880_volume_init_verbs,
4240 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004241 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4242 .dac_nids = alc880_6st_dac_nids,
4243 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004244 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4245 .channel_mode = alc880_sixstack_modes,
4246 .input_mux = &alc880_6stack_capture_source,
4247 },
4248 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004249 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004250 .init_verbs = { alc880_volume_init_verbs,
4251 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004252 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004253 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4254 .dac_nids = alc880_w810_dac_nids,
4255 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004256 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4257 .channel_mode = alc880_w810_modes,
4258 .input_mux = &alc880_capture_source,
4259 },
4260 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004261 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004262 .init_verbs = { alc880_volume_init_verbs,
4263 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004264 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4265 .dac_nids = alc880_z71v_dac_nids,
4266 .dig_out_nid = ALC880_DIGOUT_NID,
4267 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004268 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4269 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004270 .input_mux = &alc880_capture_source,
4271 },
4272 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004273 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004274 .init_verbs = { alc880_volume_init_verbs,
4275 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004276 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4277 .dac_nids = alc880_f1734_dac_nids,
4278 .hp_nid = 0x02,
4279 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4280 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004281 .input_mux = &alc880_f1734_capture_source,
4282 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004283 .setup = alc880_uniwill_p53_setup,
4284 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004285 },
4286 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004287 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004288 .init_verbs = { alc880_volume_init_verbs,
4289 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004290 alc880_gpio1_init_verbs },
4291 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4292 .dac_nids = alc880_asus_dac_nids,
4293 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4294 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004295 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004296 .input_mux = &alc880_capture_source,
4297 },
4298 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004299 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004300 .init_verbs = { alc880_volume_init_verbs,
4301 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004302 alc880_gpio1_init_verbs },
4303 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4304 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004305 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004306 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4307 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004308 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004309 .input_mux = &alc880_capture_source,
4310 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004311 [ALC880_ASUS_DIG2] = {
4312 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004313 .init_verbs = { alc880_volume_init_verbs,
4314 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004315 alc880_gpio2_init_verbs }, /* use GPIO2 */
4316 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4317 .dac_nids = alc880_asus_dac_nids,
4318 .dig_out_nid = ALC880_DIGOUT_NID,
4319 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4320 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004321 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004322 .input_mux = &alc880_capture_source,
4323 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004324 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004325 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004326 .init_verbs = { alc880_volume_init_verbs,
4327 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004328 alc880_gpio1_init_verbs },
4329 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4330 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004331 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004332 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4333 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004334 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004335 .input_mux = &alc880_capture_source,
4336 },
4337 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004338 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004339 .init_verbs = { alc880_volume_init_verbs,
4340 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004341 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4342 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004343 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004344 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4345 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004346 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004347 .input_mux = &alc880_capture_source,
4348 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004349 [ALC880_UNIWILL] = {
4350 .mixers = { alc880_uniwill_mixer },
4351 .init_verbs = { alc880_volume_init_verbs,
4352 alc880_uniwill_init_verbs },
4353 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4354 .dac_nids = alc880_asus_dac_nids,
4355 .dig_out_nid = ALC880_DIGOUT_NID,
4356 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4357 .channel_mode = alc880_threestack_modes,
4358 .need_dac_fix = 1,
4359 .input_mux = &alc880_capture_source,
4360 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004361 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004362 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004363 },
4364 [ALC880_UNIWILL_P53] = {
4365 .mixers = { alc880_uniwill_p53_mixer },
4366 .init_verbs = { alc880_volume_init_verbs,
4367 alc880_uniwill_p53_init_verbs },
4368 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4369 .dac_nids = alc880_asus_dac_nids,
4370 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004371 .channel_mode = alc880_threestack_modes,
4372 .input_mux = &alc880_capture_source,
4373 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004374 .setup = alc880_uniwill_p53_setup,
4375 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004376 },
4377 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004378 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004379 .init_verbs = { alc880_volume_init_verbs,
4380 alc880_uniwill_p53_init_verbs,
4381 alc880_beep_init_verbs },
4382 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4383 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004384 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004385 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4386 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004387 .input_mux = &alc880_capture_source,
4388 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004389 .setup = alc880_uniwill_p53_setup,
4390 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004391 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004392 [ALC880_CLEVO] = {
4393 .mixers = { alc880_three_stack_mixer },
4394 .init_verbs = { alc880_volume_init_verbs,
4395 alc880_pin_clevo_init_verbs },
4396 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4397 .dac_nids = alc880_dac_nids,
4398 .hp_nid = 0x03,
4399 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4400 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004401 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004402 .input_mux = &alc880_capture_source,
4403 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004404 [ALC880_LG] = {
4405 .mixers = { alc880_lg_mixer },
4406 .init_verbs = { alc880_volume_init_verbs,
4407 alc880_lg_init_verbs },
4408 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4409 .dac_nids = alc880_lg_dac_nids,
4410 .dig_out_nid = ALC880_DIGOUT_NID,
4411 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4412 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004413 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004414 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004415 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004416 .setup = alc880_lg_setup,
4417 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004418#ifdef CONFIG_SND_HDA_POWER_SAVE
4419 .loopbacks = alc880_lg_loopbacks,
4420#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004421 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004422 [ALC880_LG_LW] = {
4423 .mixers = { alc880_lg_lw_mixer },
4424 .init_verbs = { alc880_volume_init_verbs,
4425 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004426 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004427 .dac_nids = alc880_dac_nids,
4428 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004429 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4430 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004431 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004432 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004433 .setup = alc880_lg_lw_setup,
4434 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004435 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004436 [ALC880_MEDION_RIM] = {
4437 .mixers = { alc880_medion_rim_mixer },
4438 .init_verbs = { alc880_volume_init_verbs,
4439 alc880_medion_rim_init_verbs,
4440 alc_gpio2_init_verbs },
4441 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4442 .dac_nids = alc880_dac_nids,
4443 .dig_out_nid = ALC880_DIGOUT_NID,
4444 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4445 .channel_mode = alc880_2_jack_modes,
4446 .input_mux = &alc880_medion_rim_capture_source,
4447 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004448 .setup = alc880_medion_rim_setup,
4449 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004450 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004451#ifdef CONFIG_SND_DEBUG
4452 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004453 .mixers = { alc880_test_mixer },
4454 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004455 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4456 .dac_nids = alc880_test_dac_nids,
4457 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004458 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4459 .channel_mode = alc880_test_modes,
4460 .input_mux = &alc880_test_capture_source,
4461 },
4462#endif
4463};
4464
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004465/*
4466 * Automatic parse of I/O pins from the BIOS configuration
4467 */
4468
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004469enum {
4470 ALC_CTL_WIDGET_VOL,
4471 ALC_CTL_WIDGET_MUTE,
4472 ALC_CTL_BIND_MUTE,
4473};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004474static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004475 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4476 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004477 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004478};
4479
4480/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004481static int add_control(struct alc_spec *spec, int type, const char *name,
4482 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004483{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004484 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004485
Takashi Iwai603c4012008-07-30 15:01:44 +02004486 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4487 knew = snd_array_new(&spec->kctls);
4488 if (!knew)
4489 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004490 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004491 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004492 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004493 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004494 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004495 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004496 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004497 return 0;
4498}
4499
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004500static int add_control_with_pfx(struct alc_spec *spec, int type,
4501 const char *pfx, const char *dir,
4502 const char *sfx, unsigned long val)
4503{
4504 char name[32];
4505 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4506 return add_control(spec, type, name, val);
4507}
4508
4509#define add_pb_vol_ctrl(spec, type, pfx, val) \
4510 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4511#define add_pb_sw_ctrl(spec, type, pfx, val) \
4512 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4513
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004514#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4515#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4516#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4517#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004518#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4519#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4520#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4521#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4522#define ALC880_PIN_CD_NID 0x1c
4523
4524/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004525static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4526 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004527{
4528 hda_nid_t nid;
4529 int assigned[4];
4530 int i, j;
4531
4532 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004533 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004534
4535 /* check the pins hardwired to audio widget */
4536 for (i = 0; i < cfg->line_outs; i++) {
4537 nid = cfg->line_out_pins[i];
4538 if (alc880_is_fixed_pin(nid)) {
4539 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004540 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004541 assigned[idx] = 1;
4542 }
4543 }
4544 /* left pins can be connect to any audio widget */
4545 for (i = 0; i < cfg->line_outs; i++) {
4546 nid = cfg->line_out_pins[i];
4547 if (alc880_is_fixed_pin(nid))
4548 continue;
4549 /* search for an empty channel */
4550 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004551 if (!assigned[j]) {
4552 spec->multiout.dac_nids[i] =
4553 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004554 assigned[j] = 1;
4555 break;
4556 }
4557 }
4558 }
4559 spec->multiout.num_dacs = cfg->line_outs;
4560 return 0;
4561}
4562
4563/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004564static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4565 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004566{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004567 static const char *chname[4] = {
4568 "Front", "Surround", NULL /*CLFE*/, "Side"
4569 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004570 hda_nid_t nid;
4571 int i, err;
4572
4573 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004574 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004575 continue;
4576 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4577 if (i == 2) {
4578 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004579 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4580 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004581 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4582 HDA_OUTPUT));
4583 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004584 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004585 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4586 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004587 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4588 HDA_OUTPUT));
4589 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004590 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004591 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4592 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004593 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4594 HDA_INPUT));
4595 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004596 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004597 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4598 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004599 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4600 HDA_INPUT));
4601 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004602 return err;
4603 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004604 const char *pfx;
4605 if (cfg->line_outs == 1 &&
4606 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4607 pfx = "Speaker";
4608 else
4609 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004610 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004611 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4612 HDA_OUTPUT));
4613 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004614 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004615 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004616 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4617 HDA_INPUT));
4618 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004619 return err;
4620 }
4621 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004622 return 0;
4623}
4624
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004625/* add playback controls for speaker and HP outputs */
4626static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4627 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004628{
4629 hda_nid_t nid;
4630 int err;
4631
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004632 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004633 return 0;
4634
4635 if (alc880_is_fixed_pin(pin)) {
4636 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004637 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004638 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004639 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004640 else
4641 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004642 /* control HP volume/switch on the output mixer amp */
4643 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004644 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004645 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4646 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004647 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004648 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004649 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4650 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004651 return err;
4652 } else if (alc880_is_multi_pin(pin)) {
4653 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004654 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004655 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004656 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4657 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004658 return err;
4659 }
4660 return 0;
4661}
4662
4663/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004664static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4665 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004666 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004667{
Kailang Yangdf694da2005-12-05 19:42:22 +01004668 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004669
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004670 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004671 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4672 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004673 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004674 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004675 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4676 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004677 return err;
4678 return 0;
4679}
4680
Takashi Iwai05f5f472009-08-25 13:10:18 +02004681static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004682{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004683 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4684 return (pincap & AC_PINCAP_IN) != 0;
4685}
4686
4687/* create playback/capture controls for input pins */
4688static int alc_auto_create_input_ctls(struct hda_codec *codec,
4689 const struct auto_pin_cfg *cfg,
4690 hda_nid_t mixer,
4691 hda_nid_t cap1, hda_nid_t cap2)
4692{
4693 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004694 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004695 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004696
4697 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004698 hda_nid_t pin;
4699
4700 pin = cfg->input_pins[i];
4701 if (!alc_is_input_pin(codec, pin))
4702 continue;
4703
4704 if (mixer) {
4705 idx = get_connection_index(codec, mixer, pin);
4706 if (idx >= 0) {
4707 err = new_analog_input(spec, pin,
4708 auto_pin_cfg_labels[i],
4709 idx, mixer);
4710 if (err < 0)
4711 return err;
4712 }
4713 }
4714
4715 if (!cap1)
4716 continue;
4717 idx = get_connection_index(codec, cap1, pin);
4718 if (idx < 0 && cap2)
4719 idx = get_connection_index(codec, cap2, pin);
4720 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004721 imux->items[imux->num_items].label =
4722 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004723 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004724 imux->num_items++;
4725 }
4726 }
4727 return 0;
4728}
4729
Takashi Iwai05f5f472009-08-25 13:10:18 +02004730static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4731 const struct auto_pin_cfg *cfg)
4732{
4733 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4734}
4735
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004736static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4737 unsigned int pin_type)
4738{
4739 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4740 pin_type);
4741 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004742 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4743 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004744}
4745
Kailang Yangdf694da2005-12-05 19:42:22 +01004746static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4747 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004748 int dac_idx)
4749{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004750 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004751 /* need the manual connection? */
4752 if (alc880_is_multi_pin(nid)) {
4753 struct alc_spec *spec = codec->spec;
4754 int idx = alc880_multi_pin_idx(nid);
4755 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4756 AC_VERB_SET_CONNECT_SEL,
4757 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4758 }
4759}
4760
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004761static int get_pin_type(int line_out_type)
4762{
4763 if (line_out_type == AUTO_PIN_HP_OUT)
4764 return PIN_HP;
4765 else
4766 return PIN_OUT;
4767}
4768
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004769static void alc880_auto_init_multi_out(struct hda_codec *codec)
4770{
4771 struct alc_spec *spec = codec->spec;
4772 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004773
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004774 for (i = 0; i < spec->autocfg.line_outs; i++) {
4775 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004776 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4777 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004778 }
4779}
4780
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004781static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004782{
4783 struct alc_spec *spec = codec->spec;
4784 hda_nid_t pin;
4785
Takashi Iwai82bc9552006-03-21 11:24:42 +01004786 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004787 if (pin) /* connect to front */
4788 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004789 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004790 if (pin) /* connect to front */
4791 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4792}
4793
4794static void alc880_auto_init_analog_input(struct hda_codec *codec)
4795{
4796 struct alc_spec *spec = codec->spec;
4797 int i;
4798
4799 for (i = 0; i < AUTO_PIN_LAST; i++) {
4800 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004801 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004802 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004803 if (nid != ALC880_PIN_CD_NID &&
4804 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004805 snd_hda_codec_write(codec, nid, 0,
4806 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004807 AMP_OUT_MUTE);
4808 }
4809 }
4810}
4811
4812/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004813/* return 1 if successful, 0 if the proper config is not found,
4814 * or a negative error code
4815 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004816static int alc880_parse_auto_config(struct hda_codec *codec)
4817{
4818 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004819 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004820 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004821
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004822 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4823 alc880_ignore);
4824 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004825 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004826 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004827 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004828
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004829 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4830 if (err < 0)
4831 return err;
4832 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4833 if (err < 0)
4834 return err;
4835 err = alc880_auto_create_extra_out(spec,
4836 spec->autocfg.speaker_pins[0],
4837 "Speaker");
4838 if (err < 0)
4839 return err;
4840 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4841 "Headphone");
4842 if (err < 0)
4843 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004844 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004845 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004846 return err;
4847
4848 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4849
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004850 /* check multiple SPDIF-out (for recent codecs) */
4851 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4852 hda_nid_t dig_nid;
4853 err = snd_hda_get_connections(codec,
4854 spec->autocfg.dig_out_pins[i],
4855 &dig_nid, 1);
4856 if (err < 0)
4857 continue;
4858 if (!i)
4859 spec->multiout.dig_out_nid = dig_nid;
4860 else {
4861 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004862 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004863 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004864 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004865 }
4866 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004867 if (spec->autocfg.dig_in_pin)
4868 spec->dig_in_nid = ALC880_DIGIN_NID;
4869
Takashi Iwai603c4012008-07-30 15:01:44 +02004870 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004871 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004872
Takashi Iwaid88897e2008-10-31 15:01:37 +01004873 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004874
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004875 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004876 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004877
Kailang Yang6227cdc2010-02-25 08:36:52 +01004878 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004879
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004880 return 1;
4881}
4882
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004883/* additional initialization for auto-configuration model */
4884static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004885{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004886 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004887 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004888 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004889 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004890 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004891 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004892}
4893
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004894/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4895 * one of two digital mic pins, e.g. on ALC272
4896 */
4897static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004898{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004899 struct alc_spec *spec = codec->spec;
4900 int i;
4901
4902 for (i = 0; i < spec->num_adc_nids; i++) {
4903 hda_nid_t cap = spec->capsrc_nids ?
4904 spec->capsrc_nids[i] : spec->adc_nids[i];
4905 int iidx, eidx;
4906
4907 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4908 if (iidx < 0)
4909 continue;
4910 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4911 if (eidx < 0)
4912 continue;
4913 spec->int_mic.mux_idx = iidx;
4914 spec->ext_mic.mux_idx = eidx;
4915 if (spec->capsrc_nids)
4916 spec->capsrc_nids += i;
4917 spec->adc_nids += i;
4918 spec->num_adc_nids = 1;
4919 return;
4920 }
4921 snd_printd(KERN_INFO "hda_codec: %s: "
4922 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4923 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4924 spec->auto_mic = 0; /* disable auto-mic to be sure */
4925}
4926
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004927/* choose the ADC/MUX containing the input pin and initialize the setup */
4928static void fixup_single_adc(struct hda_codec *codec)
4929{
4930 struct alc_spec *spec = codec->spec;
Frederik Deweerdtd2db09b2010-03-05 16:34:31 +01004931 hda_nid_t pin = 0;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004932 int i;
4933
4934 /* search for the input pin; there must be only one */
4935 for (i = 0; i < AUTO_PIN_LAST; i++) {
4936 if (spec->autocfg.input_pins[i]) {
4937 pin = spec->autocfg.input_pins[i];
4938 break;
4939 }
4940 }
4941 if (!pin)
4942 return;
4943
4944 /* set the default connection to that pin */
4945 for (i = 0; i < spec->num_adc_nids; i++) {
4946 hda_nid_t cap = spec->capsrc_nids ?
4947 spec->capsrc_nids[i] : spec->adc_nids[i];
4948 int idx;
4949
4950 idx = get_connection_index(codec, cap, pin);
4951 if (idx < 0)
4952 continue;
4953 /* use only this ADC */
4954 if (spec->capsrc_nids)
4955 spec->capsrc_nids += i;
4956 spec->adc_nids += i;
4957 spec->num_adc_nids = 1;
4958 /* select or unmute this route */
4959 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
4960 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
4961 HDA_AMP_MUTE, 0);
4962 } else {
4963 snd_hda_codec_write_cache(codec, cap, 0,
4964 AC_VERB_SET_CONNECT_SEL, idx);
4965 }
4966 return;
4967 }
4968}
4969
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004970static void set_capture_mixer(struct hda_codec *codec)
4971{
4972 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004973 static struct snd_kcontrol_new *caps[2][3] = {
4974 { alc_capture_mixer_nosrc1,
4975 alc_capture_mixer_nosrc2,
4976 alc_capture_mixer_nosrc3 },
4977 { alc_capture_mixer1,
4978 alc_capture_mixer2,
4979 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004980 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004981 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004982 int mux = 0;
4983 if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004984 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004985 else if (spec->input_mux) {
4986 if (spec->input_mux->num_items > 1)
4987 mux = 1;
4988 else if (spec->input_mux->num_items == 1)
4989 fixup_single_adc(codec);
4990 }
Takashi Iwaia23b6882009-03-23 15:21:36 +01004991 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4992 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004993}
4994
Takashi Iwai66946352010-03-29 17:21:45 +02004995/* fill adc_nids (and capsrc_nids) containing all active input pins */
4996static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
4997 int num_nids)
4998{
4999 struct alc_spec *spec = codec->spec;
5000 int n;
5001 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5002
5003 for (n = 0; n < num_nids; n++) {
5004 hda_nid_t adc, cap;
5005 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5006 int nconns, i, j;
5007
5008 adc = nids[n];
5009 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5010 continue;
5011 cap = adc;
5012 nconns = snd_hda_get_connections(codec, cap, conn,
5013 ARRAY_SIZE(conn));
5014 if (nconns == 1) {
5015 cap = conn[0];
5016 nconns = snd_hda_get_connections(codec, cap, conn,
5017 ARRAY_SIZE(conn));
5018 }
5019 if (nconns <= 0)
5020 continue;
5021 if (!fallback_adc) {
5022 fallback_adc = adc;
5023 fallback_cap = cap;
5024 }
5025 for (i = 0; i < AUTO_PIN_LAST; i++) {
5026 hda_nid_t nid = spec->autocfg.input_pins[i];
5027 if (!nid)
5028 continue;
5029 for (j = 0; j < nconns; j++) {
5030 if (conn[j] == nid)
5031 break;
5032 }
5033 if (j >= nconns)
5034 break;
5035 }
5036 if (i >= AUTO_PIN_LAST) {
5037 int num_adcs = spec->num_adc_nids;
5038 spec->private_adc_nids[num_adcs] = adc;
5039 spec->private_capsrc_nids[num_adcs] = cap;
5040 spec->num_adc_nids++;
5041 spec->adc_nids = spec->private_adc_nids;
5042 if (adc != cap)
5043 spec->capsrc_nids = spec->private_capsrc_nids;
5044 }
5045 }
5046 if (!spec->num_adc_nids) {
5047 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005048 " using fallback 0x%x\n",
5049 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005050 spec->private_adc_nids[0] = fallback_adc;
5051 spec->adc_nids = spec->private_adc_nids;
5052 if (fallback_adc != fallback_cap) {
5053 spec->private_capsrc_nids[0] = fallback_cap;
5054 spec->capsrc_nids = spec->private_adc_nids;
5055 }
5056 }
5057}
5058
Takashi Iwai67d634c2009-11-16 15:35:59 +01005059#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005060#define set_beep_amp(spec, nid, idx, dir) \
5061 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01005062#else
5063#define set_beep_amp(spec, nid, idx, dir) /* NOP */
5064#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005065
5066/*
5067 * OK, here we have finally the patch for ALC880
5068 */
5069
Linus Torvalds1da177e2005-04-16 15:20:36 -07005070static int patch_alc880(struct hda_codec *codec)
5071{
5072 struct alc_spec *spec;
5073 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005074 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005075
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005076 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005077 if (spec == NULL)
5078 return -ENOMEM;
5079
5080 codec->spec = spec;
5081
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005082 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5083 alc880_models,
5084 alc880_cfg_tbl);
5085 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005086 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5087 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005088 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005089 }
5090
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005091 if (board_config == ALC880_AUTO) {
5092 /* automatic parse from the BIOS config */
5093 err = alc880_parse_auto_config(codec);
5094 if (err < 0) {
5095 alc_free(codec);
5096 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005097 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005098 printk(KERN_INFO
5099 "hda_codec: Cannot set up configuration "
5100 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005101 board_config = ALC880_3ST;
5102 }
5103 }
5104
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005105 err = snd_hda_attach_beep_device(codec, 0x1);
5106 if (err < 0) {
5107 alc_free(codec);
5108 return err;
5109 }
5110
Kailang Yangdf694da2005-12-05 19:42:22 +01005111 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005112 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005113
Linus Torvalds1da177e2005-04-16 15:20:36 -07005114 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5115 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005116 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005117
Linus Torvalds1da177e2005-04-16 15:20:36 -07005118 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5119 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5120
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005121 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005122 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005123 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005124 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005125 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005126 if (wcap != AC_WID_AUD_IN) {
5127 spec->adc_nids = alc880_adc_nids_alt;
5128 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005129 } else {
5130 spec->adc_nids = alc880_adc_nids;
5131 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005132 }
5133 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005134 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005135 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005136
Takashi Iwai2134ea42008-01-10 16:53:55 +01005137 spec->vmaster_nid = 0x0c;
5138
Linus Torvalds1da177e2005-04-16 15:20:36 -07005139 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005140 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005141 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005142#ifdef CONFIG_SND_HDA_POWER_SAVE
5143 if (!spec->loopback.amplist)
5144 spec->loopback.amplist = alc880_loopbacks;
5145#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005146
5147 return 0;
5148}
5149
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005150
Linus Torvalds1da177e2005-04-16 15:20:36 -07005151/*
5152 * ALC260 support
5153 */
5154
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005155static hda_nid_t alc260_dac_nids[1] = {
5156 /* front */
5157 0x02,
5158};
5159
5160static hda_nid_t alc260_adc_nids[1] = {
5161 /* ADC0 */
5162 0x04,
5163};
5164
Kailang Yangdf694da2005-12-05 19:42:22 +01005165static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005166 /* ADC1 */
5167 0x05,
5168};
5169
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005170/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5171 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5172 */
5173static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005174 /* ADC0, ADC1 */
5175 0x04, 0x05
5176};
5177
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005178#define ALC260_DIGOUT_NID 0x03
5179#define ALC260_DIGIN_NID 0x06
5180
5181static struct hda_input_mux alc260_capture_source = {
5182 .num_items = 4,
5183 .items = {
5184 { "Mic", 0x0 },
5185 { "Front Mic", 0x1 },
5186 { "Line", 0x2 },
5187 { "CD", 0x4 },
5188 },
5189};
5190
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005191/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005192 * headphone jack and the internal CD lines since these are the only pins at
5193 * which audio can appear. For flexibility, also allow the option of
5194 * recording the mixer output on the second ADC (ADC0 doesn't have a
5195 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005196 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005197static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5198 {
5199 .num_items = 3,
5200 .items = {
5201 { "Mic/Line", 0x0 },
5202 { "CD", 0x4 },
5203 { "Headphone", 0x2 },
5204 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005205 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005206 {
5207 .num_items = 4,
5208 .items = {
5209 { "Mic/Line", 0x0 },
5210 { "CD", 0x4 },
5211 { "Headphone", 0x2 },
5212 { "Mixer", 0x5 },
5213 },
5214 },
5215
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005216};
5217
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005218/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5219 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005220 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005221static struct hda_input_mux alc260_acer_capture_sources[2] = {
5222 {
5223 .num_items = 4,
5224 .items = {
5225 { "Mic", 0x0 },
5226 { "Line", 0x2 },
5227 { "CD", 0x4 },
5228 { "Headphone", 0x5 },
5229 },
5230 },
5231 {
5232 .num_items = 5,
5233 .items = {
5234 { "Mic", 0x0 },
5235 { "Line", 0x2 },
5236 { "CD", 0x4 },
5237 { "Headphone", 0x6 },
5238 { "Mixer", 0x5 },
5239 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005240 },
5241};
Michael Schwingencc959482009-02-22 18:58:45 +01005242
5243/* Maxdata Favorit 100XS */
5244static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5245 {
5246 .num_items = 2,
5247 .items = {
5248 { "Line/Mic", 0x0 },
5249 { "CD", 0x4 },
5250 },
5251 },
5252 {
5253 .num_items = 3,
5254 .items = {
5255 { "Line/Mic", 0x0 },
5256 { "CD", 0x4 },
5257 { "Mixer", 0x5 },
5258 },
5259 },
5260};
5261
Linus Torvalds1da177e2005-04-16 15:20:36 -07005262/*
5263 * This is just place-holder, so there's something for alc_build_pcms to look
5264 * at when it calculates the maximum number of channels. ALC260 has no mixer
5265 * element which allows changing the channel mode, so the verb list is
5266 * never used.
5267 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005268static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005269 { 2, NULL },
5270};
5271
Kailang Yangdf694da2005-12-05 19:42:22 +01005272
5273/* Mixer combinations
5274 *
5275 * basic: base_output + input + pc_beep + capture
5276 * HP: base_output + input + capture_alt
5277 * HP_3013: hp_3013 + input + capture
5278 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005279 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005280 */
5281
5282static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005283 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005284 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005285 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5286 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5287 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5288 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5289 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005290};
Kailang Yangdf694da2005-12-05 19:42:22 +01005291
5292static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005293 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5294 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5295 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5296 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5297 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5298 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5299 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5300 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005301 { } /* end */
5302};
5303
Takashi Iwaibec15c32008-01-28 18:16:30 +01005304/* update HP, line and mono out pins according to the master switch */
5305static void alc260_hp_master_update(struct hda_codec *codec,
5306 hda_nid_t hp, hda_nid_t line,
5307 hda_nid_t mono)
5308{
5309 struct alc_spec *spec = codec->spec;
5310 unsigned int val = spec->master_sw ? PIN_HP : 0;
5311 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005312 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005313 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005314 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005315 val);
5316 /* mono (speaker) depending on the HP jack sense */
5317 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005318 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005319 val);
5320}
5321
5322static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5323 struct snd_ctl_elem_value *ucontrol)
5324{
5325 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5326 struct alc_spec *spec = codec->spec;
5327 *ucontrol->value.integer.value = spec->master_sw;
5328 return 0;
5329}
5330
5331static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5332 struct snd_ctl_elem_value *ucontrol)
5333{
5334 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5335 struct alc_spec *spec = codec->spec;
5336 int val = !!*ucontrol->value.integer.value;
5337 hda_nid_t hp, line, mono;
5338
5339 if (val == spec->master_sw)
5340 return 0;
5341 spec->master_sw = val;
5342 hp = (kcontrol->private_value >> 16) & 0xff;
5343 line = (kcontrol->private_value >> 8) & 0xff;
5344 mono = kcontrol->private_value & 0xff;
5345 alc260_hp_master_update(codec, hp, line, mono);
5346 return 1;
5347}
5348
5349static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5350 {
5351 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5352 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005353 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005354 .info = snd_ctl_boolean_mono_info,
5355 .get = alc260_hp_master_sw_get,
5356 .put = alc260_hp_master_sw_put,
5357 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5358 },
5359 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5360 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5361 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5362 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5363 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5364 HDA_OUTPUT),
5365 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5366 { } /* end */
5367};
5368
5369static struct hda_verb alc260_hp_unsol_verbs[] = {
5370 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5371 {},
5372};
5373
5374static void alc260_hp_automute(struct hda_codec *codec)
5375{
5376 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005377
Wu Fengguang864f92b2009-11-18 12:38:02 +08005378 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005379 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5380}
5381
5382static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5383{
5384 if ((res >> 26) == ALC880_HP_EVENT)
5385 alc260_hp_automute(codec);
5386}
5387
Kailang Yangdf694da2005-12-05 19:42:22 +01005388static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005389 {
5390 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5391 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005392 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005393 .info = snd_ctl_boolean_mono_info,
5394 .get = alc260_hp_master_sw_get,
5395 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005396 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005397 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005398 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5399 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5400 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5401 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5402 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5403 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005404 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5405 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005406 { } /* end */
5407};
5408
Kailang Yang3f878302008-08-26 13:02:23 +02005409static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5410 .ops = &snd_hda_bind_vol,
5411 .values = {
5412 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5413 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5414 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5415 0
5416 },
5417};
5418
5419static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5420 .ops = &snd_hda_bind_sw,
5421 .values = {
5422 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5423 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5424 0
5425 },
5426};
5427
5428static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5429 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5430 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5431 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5432 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5433 { } /* end */
5434};
5435
Takashi Iwaibec15c32008-01-28 18:16:30 +01005436static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5437 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5438 {},
5439};
5440
5441static void alc260_hp_3013_automute(struct hda_codec *codec)
5442{
5443 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005444
Wu Fengguang864f92b2009-11-18 12:38:02 +08005445 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005446 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005447}
5448
5449static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5450 unsigned int res)
5451{
5452 if ((res >> 26) == ALC880_HP_EVENT)
5453 alc260_hp_3013_automute(codec);
5454}
5455
Kailang Yang3f878302008-08-26 13:02:23 +02005456static void alc260_hp_3012_automute(struct hda_codec *codec)
5457{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005458 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005459
Kailang Yang3f878302008-08-26 13:02:23 +02005460 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5461 bits);
5462 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5463 bits);
5464 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5465 bits);
5466}
5467
5468static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5469 unsigned int res)
5470{
5471 if ((res >> 26) == ALC880_HP_EVENT)
5472 alc260_hp_3012_automute(codec);
5473}
5474
5475/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005476 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5477 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005478static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005479 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005480 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005481 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005482 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5483 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5484 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5485 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005486 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005487 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5488 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005489 { } /* end */
5490};
5491
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005492/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5493 * versions of the ALC260 don't act on requests to enable mic bias from NID
5494 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5495 * datasheet doesn't mention this restriction. At this stage it's not clear
5496 * whether this behaviour is intentional or is a hardware bug in chip
5497 * revisions available in early 2006. Therefore for now allow the
5498 * "Headphone Jack Mode" control to span all choices, but if it turns out
5499 * that the lack of mic bias for this NID is intentional we could change the
5500 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5501 *
5502 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5503 * don't appear to make the mic bias available from the "line" jack, even
5504 * though the NID used for this jack (0x14) can supply it. The theory is
5505 * that perhaps Acer have included blocking capacitors between the ALC260
5506 * and the output jack. If this turns out to be the case for all such
5507 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5508 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005509 *
5510 * The C20x Tablet series have a mono internal speaker which is controlled
5511 * via the chip's Mono sum widget and pin complex, so include the necessary
5512 * controls for such models. On models without a "mono speaker" the control
5513 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005514 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005515static struct snd_kcontrol_new alc260_acer_mixer[] = {
5516 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5517 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005518 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005519 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005520 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005521 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005522 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005523 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5524 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5525 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5526 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5527 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5528 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5529 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5530 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005531 { } /* end */
5532};
5533
Michael Schwingencc959482009-02-22 18:58:45 +01005534/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5535 */
5536static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5537 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5538 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5539 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5540 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5541 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5542 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5543 { } /* end */
5544};
5545
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005546/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5547 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5548 */
5549static struct snd_kcontrol_new alc260_will_mixer[] = {
5550 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5551 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5552 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5553 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5554 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5555 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5556 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5557 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5558 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5559 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005560 { } /* end */
5561};
5562
5563/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5564 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5565 */
5566static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5567 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5568 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5569 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5570 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5571 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5572 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5573 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5574 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5575 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5576 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5577 { } /* end */
5578};
5579
Kailang Yangdf694da2005-12-05 19:42:22 +01005580/*
5581 * initialization verbs
5582 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005583static struct hda_verb alc260_init_verbs[] = {
5584 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005585 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005586 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005587 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005588 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005589 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005590 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005591 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005592 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005593 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005594 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005595 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005596 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005597 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005598 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005599 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005600 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005601 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5602 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005603 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005604 /* set connection select to line in (default select for this ADC) */
5605 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005606 /* mute capture amp left and right */
5607 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5608 /* set connection select to line in (default select for this ADC) */
5609 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005610 /* set vol=0 Line-Out mixer amp left and right */
5611 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5612 /* unmute pin widget amp left and right (no gain on this amp) */
5613 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5614 /* set vol=0 HP mixer amp left and right */
5615 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5616 /* unmute pin widget amp left and right (no gain on this amp) */
5617 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5618 /* set vol=0 Mono mixer amp left and right */
5619 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5620 /* unmute pin widget amp left and right (no gain on this amp) */
5621 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5622 /* unmute LINE-2 out pin */
5623 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005624 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5625 * Line In 2 = 0x03
5626 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005627 /* mute analog inputs */
5628 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5629 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5630 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5631 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5632 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005633 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005634 /* mute Front out path */
5635 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5636 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5637 /* mute Headphone out path */
5638 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5639 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5640 /* mute Mono out path */
5641 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5642 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005643 { }
5644};
5645
Takashi Iwai474167d2006-05-17 17:17:43 +02005646#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005647static struct hda_verb alc260_hp_init_verbs[] = {
5648 /* Headphone and output */
5649 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5650 /* mono output */
5651 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5652 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5653 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5654 /* Mic2 (front panel) pin widget for input and vref at 80% */
5655 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5656 /* Line In pin widget for input */
5657 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5658 /* Line-2 pin widget for output */
5659 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5660 /* CD pin widget for input */
5661 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5662 /* unmute amp left and right */
5663 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5664 /* set connection select to line in (default select for this ADC) */
5665 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5666 /* unmute Line-Out mixer amp left and right (volume = 0) */
5667 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5668 /* mute pin widget amp left and right (no gain on this amp) */
5669 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5670 /* unmute HP mixer amp left and right (volume = 0) */
5671 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5672 /* mute pin widget amp left and right (no gain on this amp) */
5673 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005674 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5675 * Line In 2 = 0x03
5676 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005677 /* mute analog inputs */
5678 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5679 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5680 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5681 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5682 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005683 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5684 /* Unmute Front out path */
5685 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5686 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5687 /* Unmute Headphone out path */
5688 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5689 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5690 /* Unmute Mono out path */
5691 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5692 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5693 { }
5694};
Takashi Iwai474167d2006-05-17 17:17:43 +02005695#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005696
5697static struct hda_verb alc260_hp_3013_init_verbs[] = {
5698 /* Line out and output */
5699 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5700 /* mono output */
5701 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5702 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5703 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5704 /* Mic2 (front panel) pin widget for input and vref at 80% */
5705 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5706 /* Line In pin widget for input */
5707 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5708 /* Headphone pin widget for output */
5709 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5710 /* CD pin widget for input */
5711 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5712 /* unmute amp left and right */
5713 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5714 /* set connection select to line in (default select for this ADC) */
5715 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5716 /* unmute Line-Out mixer amp left and right (volume = 0) */
5717 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5718 /* mute pin widget amp left and right (no gain on this amp) */
5719 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5720 /* unmute HP mixer amp left and right (volume = 0) */
5721 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5722 /* mute pin widget amp left and right (no gain on this amp) */
5723 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005724 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5725 * Line In 2 = 0x03
5726 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005727 /* mute analog inputs */
5728 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5729 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5730 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5731 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5732 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005733 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5734 /* Unmute Front out path */
5735 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5736 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5737 /* Unmute Headphone out path */
5738 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5739 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5740 /* Unmute Mono out path */
5741 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5742 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5743 { }
5744};
5745
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005746/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005747 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5748 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005749 */
5750static struct hda_verb alc260_fujitsu_init_verbs[] = {
5751 /* Disable all GPIOs */
5752 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5753 /* Internal speaker is connected to headphone pin */
5754 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5755 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5756 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005757 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5758 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5759 /* Ensure all other unused pins are disabled and muted. */
5760 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5761 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005762 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005763 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005764 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005765 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5766 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5767 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005768
Jonathan Woithef7ace402006-02-28 11:46:14 +01005769 /* Disable digital (SPDIF) pins */
5770 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5771 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005772
Kailang Yangea1fb292008-08-26 12:58:38 +02005773 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005774 * when acting as an output.
5775 */
5776 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5777
5778 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005779 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5780 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5781 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5782 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5783 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5784 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5785 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5786 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5787 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005788
Jonathan Woithef7ace402006-02-28 11:46:14 +01005789 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5790 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5791 /* Unmute Line1 pin widget output buffer since it starts as an output.
5792 * If the pin mode is changed by the user the pin mode control will
5793 * take care of enabling the pin's input/output buffers as needed.
5794 * Therefore there's no need to enable the input buffer at this
5795 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005796 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005797 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005798 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005799 * mixer ctrl)
5800 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005801 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005802
Jonathan Woithef7ace402006-02-28 11:46:14 +01005803 /* Mute capture amp left and right */
5804 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005805 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005806 * in (on mic1 pin)
5807 */
5808 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005809
Jonathan Woithef7ace402006-02-28 11:46:14 +01005810 /* Do the same for the second ADC: mute capture input amp and
5811 * set ADC connection to line in (on mic1 pin)
5812 */
5813 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5814 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005815
Jonathan Woithef7ace402006-02-28 11:46:14 +01005816 /* Mute all inputs to mixer widget (even unconnected ones) */
5817 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5818 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5819 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5820 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5821 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5822 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5823 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5824 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005825
5826 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005827};
5828
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005829/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5830 * similar laptops (adapted from Fujitsu init verbs).
5831 */
5832static struct hda_verb alc260_acer_init_verbs[] = {
5833 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5834 * the headphone jack. Turn this on and rely on the standard mute
5835 * methods whenever the user wants to turn these outputs off.
5836 */
5837 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5838 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5839 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5840 /* Internal speaker/Headphone jack is connected to Line-out pin */
5841 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5842 /* Internal microphone/Mic jack is connected to Mic1 pin */
5843 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5844 /* Line In jack is connected to Line1 pin */
5845 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005846 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5847 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005848 /* Ensure all other unused pins are disabled and muted. */
5849 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5850 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005851 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5852 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5853 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5854 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5855 /* Disable digital (SPDIF) pins */
5856 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5857 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5858
Kailang Yangea1fb292008-08-26 12:58:38 +02005859 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005860 * bus when acting as outputs.
5861 */
5862 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5863 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5864
5865 /* Start with output sum widgets muted and their output gains at min */
5866 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5867 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5868 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5869 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5870 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5871 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5872 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5873 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5874 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5875
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005876 /* Unmute Line-out pin widget amp left and right
5877 * (no equiv mixer ctrl)
5878 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005879 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005880 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5881 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005882 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5883 * inputs. If the pin mode is changed by the user the pin mode control
5884 * will take care of enabling the pin's input/output buffers as needed.
5885 * Therefore there's no need to enable the input buffer at this
5886 * stage.
5887 */
5888 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5889 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5890
5891 /* Mute capture amp left and right */
5892 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5893 /* Set ADC connection select to match default mixer setting - mic
5894 * (on mic1 pin)
5895 */
5896 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5897
5898 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005899 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005900 */
5901 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005902 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005903
5904 /* Mute all inputs to mixer widget (even unconnected ones) */
5905 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5906 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5907 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5908 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5909 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5910 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5911 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5912 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5913
5914 { }
5915};
5916
Michael Schwingencc959482009-02-22 18:58:45 +01005917/* Initialisation sequence for Maxdata Favorit 100XS
5918 * (adapted from Acer init verbs).
5919 */
5920static struct hda_verb alc260_favorit100_init_verbs[] = {
5921 /* GPIO 0 enables the output jack.
5922 * Turn this on and rely on the standard mute
5923 * methods whenever the user wants to turn these outputs off.
5924 */
5925 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5926 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5927 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5928 /* Line/Mic input jack is connected to Mic1 pin */
5929 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5930 /* Ensure all other unused pins are disabled and muted. */
5931 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5932 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5933 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5934 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5935 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5936 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5937 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5938 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5939 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5940 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5941 /* Disable digital (SPDIF) pins */
5942 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5943 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5944
5945 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5946 * bus when acting as outputs.
5947 */
5948 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5949 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5950
5951 /* Start with output sum widgets muted and their output gains at min */
5952 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5953 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5954 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5955 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5956 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5957 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5958 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5959 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5960 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5961
5962 /* Unmute Line-out pin widget amp left and right
5963 * (no equiv mixer ctrl)
5964 */
5965 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5966 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5967 * inputs. If the pin mode is changed by the user the pin mode control
5968 * will take care of enabling the pin's input/output buffers as needed.
5969 * Therefore there's no need to enable the input buffer at this
5970 * stage.
5971 */
5972 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5973
5974 /* Mute capture amp left and right */
5975 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5976 /* Set ADC connection select to match default mixer setting - mic
5977 * (on mic1 pin)
5978 */
5979 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5980
5981 /* Do similar with the second ADC: mute capture input amp and
5982 * set ADC connection to mic to match ALSA's default state.
5983 */
5984 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5985 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5986
5987 /* Mute all inputs to mixer widget (even unconnected ones) */
5988 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5989 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5990 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5991 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5992 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5993 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5994 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5995 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5996
5997 { }
5998};
5999
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006000static struct hda_verb alc260_will_verbs[] = {
6001 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6002 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6003 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6004 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6005 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6006 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6007 {}
6008};
6009
6010static struct hda_verb alc260_replacer_672v_verbs[] = {
6011 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6012 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6013 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6014
6015 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6016 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6017 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6018
6019 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6020 {}
6021};
6022
6023/* toggle speaker-output according to the hp-jack state */
6024static void alc260_replacer_672v_automute(struct hda_codec *codec)
6025{
6026 unsigned int present;
6027
6028 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006029 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006030 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006031 snd_hda_codec_write_cache(codec, 0x01, 0,
6032 AC_VERB_SET_GPIO_DATA, 1);
6033 snd_hda_codec_write_cache(codec, 0x0f, 0,
6034 AC_VERB_SET_PIN_WIDGET_CONTROL,
6035 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006036 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006037 snd_hda_codec_write_cache(codec, 0x01, 0,
6038 AC_VERB_SET_GPIO_DATA, 0);
6039 snd_hda_codec_write_cache(codec, 0x0f, 0,
6040 AC_VERB_SET_PIN_WIDGET_CONTROL,
6041 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006042 }
6043}
6044
6045static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6046 unsigned int res)
6047{
6048 if ((res >> 26) == ALC880_HP_EVENT)
6049 alc260_replacer_672v_automute(codec);
6050}
6051
Kailang Yang3f878302008-08-26 13:02:23 +02006052static struct hda_verb alc260_hp_dc7600_verbs[] = {
6053 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6054 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6055 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6056 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6057 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6058 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6059 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6060 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6061 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6062 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6063 {}
6064};
6065
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006066/* Test configuration for debugging, modelled after the ALC880 test
6067 * configuration.
6068 */
6069#ifdef CONFIG_SND_DEBUG
6070static hda_nid_t alc260_test_dac_nids[1] = {
6071 0x02,
6072};
6073static hda_nid_t alc260_test_adc_nids[2] = {
6074 0x04, 0x05,
6075};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006076/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006077 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006078 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006079 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006080static struct hda_input_mux alc260_test_capture_sources[2] = {
6081 {
6082 .num_items = 7,
6083 .items = {
6084 { "MIC1 pin", 0x0 },
6085 { "MIC2 pin", 0x1 },
6086 { "LINE1 pin", 0x2 },
6087 { "LINE2 pin", 0x3 },
6088 { "CD pin", 0x4 },
6089 { "LINE-OUT pin", 0x5 },
6090 { "HP-OUT pin", 0x6 },
6091 },
6092 },
6093 {
6094 .num_items = 8,
6095 .items = {
6096 { "MIC1 pin", 0x0 },
6097 { "MIC2 pin", 0x1 },
6098 { "LINE1 pin", 0x2 },
6099 { "LINE2 pin", 0x3 },
6100 { "CD pin", 0x4 },
6101 { "Mixer", 0x5 },
6102 { "LINE-OUT pin", 0x6 },
6103 { "HP-OUT pin", 0x7 },
6104 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006105 },
6106};
6107static struct snd_kcontrol_new alc260_test_mixer[] = {
6108 /* Output driver widgets */
6109 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6110 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6111 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6112 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6113 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6114 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6115
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006116 /* Modes for retasking pin widgets
6117 * Note: the ALC260 doesn't seem to act on requests to enable mic
6118 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6119 * mention this restriction. At this stage it's not clear whether
6120 * this behaviour is intentional or is a hardware bug in chip
6121 * revisions available at least up until early 2006. Therefore for
6122 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6123 * choices, but if it turns out that the lack of mic bias for these
6124 * NIDs is intentional we could change their modes from
6125 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6126 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006127 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6128 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6129 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6130 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6131 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6132 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6133
6134 /* Loopback mixer controls */
6135 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6136 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6137 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6138 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6139 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6140 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6141 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6142 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6143 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6144 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006145 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6146 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6147 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6148 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006149
6150 /* Controls for GPIO pins, assuming they are configured as outputs */
6151 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6152 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6153 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6154 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6155
Jonathan Woithe92621f12006-02-28 11:47:47 +01006156 /* Switches to allow the digital IO pins to be enabled. The datasheet
6157 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006158 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006159 */
6160 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6161 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6162
Jonathan Woithef8225f62008-01-08 12:16:54 +01006163 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6164 * this output to turn on an external amplifier.
6165 */
6166 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6167 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6168
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006169 { } /* end */
6170};
6171static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006172 /* Enable all GPIOs as outputs with an initial value of 0 */
6173 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6174 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6175 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6176
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006177 /* Enable retasking pins as output, initially without power amp */
6178 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6179 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6180 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6181 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6182 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6183 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6184
Jonathan Woithe92621f12006-02-28 11:47:47 +01006185 /* Disable digital (SPDIF) pins initially, but users can enable
6186 * them via a mixer switch. In the case of SPDIF-out, this initverb
6187 * payload also sets the generation to 0, output to be in "consumer"
6188 * PCM format, copyright asserted, no pre-emphasis and no validity
6189 * control.
6190 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006191 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6192 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6193
Kailang Yangea1fb292008-08-26 12:58:38 +02006194 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006195 * OUT1 sum bus when acting as an output.
6196 */
6197 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6198 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6199 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6200 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6201
6202 /* Start with output sum widgets muted and their output gains at min */
6203 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6204 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6205 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6206 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6207 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6208 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6209 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6210 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6211 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6212
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006213 /* Unmute retasking pin widget output buffers since the default
6214 * state appears to be output. As the pin mode is changed by the
6215 * user the pin mode control will take care of enabling the pin's
6216 * input/output buffers as needed.
6217 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006218 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6219 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6220 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6221 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6222 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6223 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6224 /* Also unmute the mono-out pin widget */
6225 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6226
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006227 /* Mute capture amp left and right */
6228 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006229 /* Set ADC connection select to match default mixer setting (mic1
6230 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006231 */
6232 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6233
6234 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006235 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006236 */
6237 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6238 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6239
6240 /* Mute all inputs to mixer widget (even unconnected ones) */
6241 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6242 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6243 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6244 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6245 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6246 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6249
6250 { }
6251};
6252#endif
6253
Takashi Iwai63300792008-01-24 15:31:36 +01006254#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6255#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006256
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006257#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6258#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6259
Kailang Yangdf694da2005-12-05 19:42:22 +01006260/*
6261 * for BIOS auto-configuration
6262 */
6263
6264static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006265 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006266{
6267 hda_nid_t nid_vol;
6268 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006269 int err;
6270
6271 if (nid >= 0x0f && nid < 0x11) {
6272 nid_vol = nid - 0x7;
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 if (nid == 0x11) {
6276 nid_vol = nid - 0x7;
6277 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6278 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6279 } else if (nid >= 0x12 && nid <= 0x15) {
6280 nid_vol = 0x08;
6281 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6282 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6283 } else
6284 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006285
Takashi Iwai863b4512008-10-21 17:01:47 +02006286 if (!(*vol_bits & (1 << nid_vol))) {
6287 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006288 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006289 if (err < 0)
6290 return err;
6291 *vol_bits |= (1 << nid_vol);
6292 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006293 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006294 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006295 return err;
6296 return 1;
6297}
6298
6299/* add playback controls from the parsed DAC table */
6300static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6301 const struct auto_pin_cfg *cfg)
6302{
6303 hda_nid_t nid;
6304 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006305 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006306
6307 spec->multiout.num_dacs = 1;
6308 spec->multiout.dac_nids = spec->private_dac_nids;
6309 spec->multiout.dac_nids[0] = 0x02;
6310
6311 nid = cfg->line_out_pins[0];
6312 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006313 const char *pfx;
6314 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6315 pfx = "Master";
6316 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6317 pfx = "Speaker";
6318 else
6319 pfx = "Front";
6320 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006321 if (err < 0)
6322 return err;
6323 }
6324
Takashi Iwai82bc9552006-03-21 11:24:42 +01006325 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006326 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006327 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006328 if (err < 0)
6329 return err;
6330 }
6331
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006332 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006333 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006334 err = alc260_add_playback_controls(spec, nid, "Headphone",
6335 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006336 if (err < 0)
6337 return err;
6338 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006339 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006340}
6341
6342/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006343static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006344 const struct auto_pin_cfg *cfg)
6345{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006346 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006347}
6348
6349static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6350 hda_nid_t nid, int pin_type,
6351 int sel_idx)
6352{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006353 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006354 /* need the manual connection? */
6355 if (nid >= 0x12) {
6356 int idx = nid - 0x12;
6357 snd_hda_codec_write(codec, idx + 0x0b, 0,
6358 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006359 }
6360}
6361
6362static void alc260_auto_init_multi_out(struct hda_codec *codec)
6363{
6364 struct alc_spec *spec = codec->spec;
6365 hda_nid_t nid;
6366
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006367 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006368 if (nid) {
6369 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6370 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6371 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006372
Takashi Iwai82bc9552006-03-21 11:24:42 +01006373 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006374 if (nid)
6375 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6376
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006377 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006378 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006379 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006380}
Kailang Yangdf694da2005-12-05 19:42:22 +01006381
6382#define ALC260_PIN_CD_NID 0x16
6383static void alc260_auto_init_analog_input(struct hda_codec *codec)
6384{
6385 struct alc_spec *spec = codec->spec;
6386 int i;
6387
6388 for (i = 0; i < AUTO_PIN_LAST; i++) {
6389 hda_nid_t nid = spec->autocfg.input_pins[i];
6390 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006391 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006392 if (nid != ALC260_PIN_CD_NID &&
6393 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006394 snd_hda_codec_write(codec, nid, 0,
6395 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006396 AMP_OUT_MUTE);
6397 }
6398 }
6399}
6400
6401/*
6402 * generic initialization of ADC, input mixers and output mixers
6403 */
6404static struct hda_verb alc260_volume_init_verbs[] = {
6405 /*
6406 * Unmute ADC0-1 and set the default input to mic-in
6407 */
6408 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6409 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6410 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6411 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006412
Kailang Yangdf694da2005-12-05 19:42:22 +01006413 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6414 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006415 * Note: PASD motherboards uses the Line In 2 as the input for
6416 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006417 */
6418 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006419 /* mute analog inputs */
6420 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6421 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6422 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6423 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6424 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006425
6426 /*
6427 * Set up output mixers (0x08 - 0x0a)
6428 */
6429 /* set vol=0 to output mixers */
6430 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6431 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6432 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6433 /* set up input amps for analog loopback */
6434 /* Amp Indices: DAC = 0, mixer = 1 */
6435 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6436 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6437 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6438 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6439 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6440 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006441
Kailang Yangdf694da2005-12-05 19:42:22 +01006442 { }
6443};
6444
6445static int alc260_parse_auto_config(struct hda_codec *codec)
6446{
6447 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006448 int err;
6449 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6450
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006451 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6452 alc260_ignore);
6453 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006454 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006455 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6456 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006457 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006458 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006459 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006460 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006461 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006462 return err;
6463
6464 spec->multiout.max_channels = 2;
6465
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006466 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006467 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006468 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006469 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006470
Takashi Iwaid88897e2008-10-31 15:01:37 +01006471 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006472
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006473 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006474 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006475
Kailang Yang6227cdc2010-02-25 08:36:52 +01006476 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006477
Kailang Yangdf694da2005-12-05 19:42:22 +01006478 return 1;
6479}
6480
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006481/* additional initialization for auto-configuration model */
6482static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006483{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006484 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006485 alc260_auto_init_multi_out(codec);
6486 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006487 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006488 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006489}
6490
Takashi Iwaicb53c622007-08-10 17:21:45 +02006491#ifdef CONFIG_SND_HDA_POWER_SAVE
6492static struct hda_amp_list alc260_loopbacks[] = {
6493 { 0x07, HDA_INPUT, 0 },
6494 { 0x07, HDA_INPUT, 1 },
6495 { 0x07, HDA_INPUT, 2 },
6496 { 0x07, HDA_INPUT, 3 },
6497 { 0x07, HDA_INPUT, 4 },
6498 { } /* end */
6499};
6500#endif
6501
Kailang Yangdf694da2005-12-05 19:42:22 +01006502/*
6503 * ALC260 configurations
6504 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006505static const char *alc260_models[ALC260_MODEL_LAST] = {
6506 [ALC260_BASIC] = "basic",
6507 [ALC260_HP] = "hp",
6508 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006509 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006510 [ALC260_FUJITSU_S702X] = "fujitsu",
6511 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006512 [ALC260_WILL] = "will",
6513 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006514 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006515#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006516 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006517#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006518 [ALC260_AUTO] = "auto",
6519};
6520
6521static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006522 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006523 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006524 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006525 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006526 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006527 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006528 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006529 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006530 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006531 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6532 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6533 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6534 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6535 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6536 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6537 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6538 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6539 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006540 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006541 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006542 {}
6543};
6544
Kailang Yangdf694da2005-12-05 19:42:22 +01006545static struct alc_config_preset alc260_presets[] = {
6546 [ALC260_BASIC] = {
6547 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006548 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006549 .init_verbs = { alc260_init_verbs },
6550 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6551 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006552 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01006553 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006554 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6555 .channel_mode = alc260_modes,
6556 .input_mux = &alc260_capture_source,
6557 },
6558 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006559 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006560 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006561 .init_verbs = { alc260_init_verbs,
6562 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006563 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6564 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006565 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6566 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006567 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6568 .channel_mode = alc260_modes,
6569 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006570 .unsol_event = alc260_hp_unsol_event,
6571 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006572 },
Kailang Yang3f878302008-08-26 13:02:23 +02006573 [ALC260_HP_DC7600] = {
6574 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006575 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006576 .init_verbs = { alc260_init_verbs,
6577 alc260_hp_dc7600_verbs },
6578 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6579 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006580 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6581 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006582 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6583 .channel_mode = alc260_modes,
6584 .input_mux = &alc260_capture_source,
6585 .unsol_event = alc260_hp_3012_unsol_event,
6586 .init_hook = alc260_hp_3012_automute,
6587 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006588 [ALC260_HP_3013] = {
6589 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006590 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006591 .init_verbs = { alc260_hp_3013_init_verbs,
6592 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006593 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6594 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006595 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6596 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006597 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6598 .channel_mode = alc260_modes,
6599 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006600 .unsol_event = alc260_hp_3013_unsol_event,
6601 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006602 },
6603 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006604 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006605 .init_verbs = { alc260_fujitsu_init_verbs },
6606 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6607 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006608 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6609 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006610 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6611 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006612 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6613 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006614 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006615 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006616 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006617 .init_verbs = { alc260_acer_init_verbs },
6618 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6619 .dac_nids = alc260_dac_nids,
6620 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6621 .adc_nids = alc260_dual_adc_nids,
6622 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6623 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006624 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6625 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006626 },
Michael Schwingencc959482009-02-22 18:58:45 +01006627 [ALC260_FAVORIT100] = {
6628 .mixers = { alc260_favorit100_mixer },
6629 .init_verbs = { alc260_favorit100_init_verbs },
6630 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6631 .dac_nids = alc260_dac_nids,
6632 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6633 .adc_nids = alc260_dual_adc_nids,
6634 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6635 .channel_mode = alc260_modes,
6636 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6637 .input_mux = alc260_favorit100_capture_sources,
6638 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006639 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006640 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006641 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6642 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6643 .dac_nids = alc260_dac_nids,
6644 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6645 .adc_nids = alc260_adc_nids,
6646 .dig_out_nid = ALC260_DIGOUT_NID,
6647 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6648 .channel_mode = alc260_modes,
6649 .input_mux = &alc260_capture_source,
6650 },
6651 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006652 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006653 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6654 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6655 .dac_nids = alc260_dac_nids,
6656 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6657 .adc_nids = alc260_adc_nids,
6658 .dig_out_nid = ALC260_DIGOUT_NID,
6659 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6660 .channel_mode = alc260_modes,
6661 .input_mux = &alc260_capture_source,
6662 .unsol_event = alc260_replacer_672v_unsol_event,
6663 .init_hook = alc260_replacer_672v_automute,
6664 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006665#ifdef CONFIG_SND_DEBUG
6666 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006667 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006668 .init_verbs = { alc260_test_init_verbs },
6669 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6670 .dac_nids = alc260_test_dac_nids,
6671 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6672 .adc_nids = alc260_test_adc_nids,
6673 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6674 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006675 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6676 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006677 },
6678#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006679};
6680
Linus Torvalds1da177e2005-04-16 15:20:36 -07006681static int patch_alc260(struct hda_codec *codec)
6682{
6683 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006684 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006685
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006686 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006687 if (spec == NULL)
6688 return -ENOMEM;
6689
6690 codec->spec = spec;
6691
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006692 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6693 alc260_models,
6694 alc260_cfg_tbl);
6695 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006696 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006697 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006698 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006699 }
6700
Kailang Yangdf694da2005-12-05 19:42:22 +01006701 if (board_config == ALC260_AUTO) {
6702 /* automatic parse from the BIOS config */
6703 err = alc260_parse_auto_config(codec);
6704 if (err < 0) {
6705 alc_free(codec);
6706 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006707 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006708 printk(KERN_INFO
6709 "hda_codec: Cannot set up configuration "
6710 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006711 board_config = ALC260_BASIC;
6712 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006713 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006714
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006715 err = snd_hda_attach_beep_device(codec, 0x1);
6716 if (err < 0) {
6717 alc_free(codec);
6718 return err;
6719 }
6720
Kailang Yangdf694da2005-12-05 19:42:22 +01006721 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006722 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006723
Linus Torvalds1da177e2005-04-16 15:20:36 -07006724 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6725 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6726
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006727 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6728 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6729
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006730 if (!spec->adc_nids && spec->input_mux) {
6731 /* check whether NID 0x04 is valid */
6732 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006733 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006734 /* get type */
6735 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6736 spec->adc_nids = alc260_adc_nids_alt;
6737 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6738 } else {
6739 spec->adc_nids = alc260_adc_nids;
6740 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6741 }
6742 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006743 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006744 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006745
Takashi Iwai2134ea42008-01-10 16:53:55 +01006746 spec->vmaster_nid = 0x08;
6747
Linus Torvalds1da177e2005-04-16 15:20:36 -07006748 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006749 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006750 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006751#ifdef CONFIG_SND_HDA_POWER_SAVE
6752 if (!spec->loopback.amplist)
6753 spec->loopback.amplist = alc260_loopbacks;
6754#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006755
6756 return 0;
6757}
6758
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006759
Linus Torvalds1da177e2005-04-16 15:20:36 -07006760/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006761 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006762 *
6763 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6764 * configuration. Each pin widget can choose any input DACs and a mixer.
6765 * Each ADC is connected from a mixer of all inputs. This makes possible
6766 * 6-channel independent captures.
6767 *
6768 * In addition, an independent DAC for the multi-playback (not used in this
6769 * driver yet).
6770 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006771#define ALC882_DIGOUT_NID 0x06
6772#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006773#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6774#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6775#define ALC1200_DIGOUT_NID 0x10
6776
Linus Torvalds1da177e2005-04-16 15:20:36 -07006777
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006778static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006779 { 8, NULL }
6780};
6781
Takashi Iwai4953550a2009-06-30 15:28:30 +02006782/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006783static hda_nid_t alc882_dac_nids[4] = {
6784 /* front, rear, clfe, rear_surr */
6785 0x02, 0x03, 0x04, 0x05
6786};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006787#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006788
Takashi Iwai4953550a2009-06-30 15:28:30 +02006789/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006790#define alc882_adc_nids alc880_adc_nids
6791#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006792#define alc883_adc_nids alc882_adc_nids_alt
6793static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6794static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6795#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006796
Takashi Iwaie1406342008-02-11 18:32:32 +01006797static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6798static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006799#define alc883_capsrc_nids alc882_capsrc_nids_alt
6800static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6801#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006802
Linus Torvalds1da177e2005-04-16 15:20:36 -07006803/* input MUX */
6804/* FIXME: should be a matrix-type input source selection */
6805
6806static struct hda_input_mux alc882_capture_source = {
6807 .num_items = 4,
6808 .items = {
6809 { "Mic", 0x0 },
6810 { "Front Mic", 0x1 },
6811 { "Line", 0x2 },
6812 { "CD", 0x4 },
6813 },
6814};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006815
Takashi Iwai4953550a2009-06-30 15:28:30 +02006816#define alc883_capture_source alc882_capture_source
6817
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006818static struct hda_input_mux alc889_capture_source = {
6819 .num_items = 3,
6820 .items = {
6821 { "Front Mic", 0x0 },
6822 { "Mic", 0x3 },
6823 { "Line", 0x2 },
6824 },
6825};
6826
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006827static struct hda_input_mux mb5_capture_source = {
6828 .num_items = 3,
6829 .items = {
6830 { "Mic", 0x1 },
6831 { "Line", 0x2 },
6832 { "CD", 0x4 },
6833 },
6834};
6835
Luke Yelaviche458b1f2010-02-12 16:28:29 +11006836static struct hda_input_mux macmini3_capture_source = {
6837 .num_items = 2,
6838 .items = {
6839 { "Line", 0x2 },
6840 { "CD", 0x4 },
6841 },
6842};
6843
Takashi Iwai4953550a2009-06-30 15:28:30 +02006844static struct hda_input_mux alc883_3stack_6ch_intel = {
6845 .num_items = 4,
6846 .items = {
6847 { "Mic", 0x1 },
6848 { "Front Mic", 0x0 },
6849 { "Line", 0x2 },
6850 { "CD", 0x4 },
6851 },
6852};
6853
6854static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6855 .num_items = 2,
6856 .items = {
6857 { "Mic", 0x1 },
6858 { "Line", 0x2 },
6859 },
6860};
6861
6862static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6863 .num_items = 4,
6864 .items = {
6865 { "Mic", 0x0 },
6866 { "iMic", 0x1 },
6867 { "Line", 0x2 },
6868 { "CD", 0x4 },
6869 },
6870};
6871
6872static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6873 .num_items = 2,
6874 .items = {
6875 { "Mic", 0x0 },
6876 { "Int Mic", 0x1 },
6877 },
6878};
6879
6880static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6881 .num_items = 3,
6882 .items = {
6883 { "Mic", 0x0 },
6884 { "Front Mic", 0x1 },
6885 { "Line", 0x4 },
6886 },
6887};
6888
6889static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6890 .num_items = 2,
6891 .items = {
6892 { "Mic", 0x0 },
6893 { "Line", 0x2 },
6894 },
6895};
6896
6897static struct hda_input_mux alc889A_mb31_capture_source = {
6898 .num_items = 2,
6899 .items = {
6900 { "Mic", 0x0 },
6901 /* Front Mic (0x01) unused */
6902 { "Line", 0x2 },
6903 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02006904 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006905 },
6906};
6907
6908/*
6909 * 2ch mode
6910 */
6911static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6912 { 2, NULL }
6913};
6914
Kailang Yangdf694da2005-12-05 19:42:22 +01006915/*
Kailang Yang272a5272007-05-14 11:00:38 +02006916 * 2ch mode
6917 */
6918static struct hda_verb alc882_3ST_ch2_init[] = {
6919 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6920 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6921 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6922 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6923 { } /* end */
6924};
6925
6926/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006927 * 4ch mode
6928 */
6929static struct hda_verb alc882_3ST_ch4_init[] = {
6930 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6931 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6932 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6933 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6934 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6935 { } /* end */
6936};
6937
6938/*
Kailang Yang272a5272007-05-14 11:00:38 +02006939 * 6ch mode
6940 */
6941static struct hda_verb alc882_3ST_ch6_init[] = {
6942 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6943 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6944 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6945 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6946 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6947 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6948 { } /* end */
6949};
6950
Takashi Iwai4953550a2009-06-30 15:28:30 +02006951static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006952 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006953 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006954 { 6, alc882_3ST_ch6_init },
6955};
6956
Takashi Iwai4953550a2009-06-30 15:28:30 +02006957#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6958
Kailang Yang272a5272007-05-14 11:00:38 +02006959/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306960 * 2ch mode
6961 */
6962static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6963 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6964 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6965 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6966 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6967 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6968 { } /* end */
6969};
6970
6971/*
6972 * 4ch mode
6973 */
6974static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6975 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6976 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6977 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6978 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6979 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6980 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6981 { } /* end */
6982};
6983
6984/*
6985 * 6ch mode
6986 */
6987static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6988 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6989 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6990 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6991 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6992 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6993 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6994 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6995 { } /* end */
6996};
6997
6998static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6999 { 2, alc883_3ST_ch2_clevo_init },
7000 { 4, alc883_3ST_ch4_clevo_init },
7001 { 6, alc883_3ST_ch6_clevo_init },
7002};
7003
7004
7005/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007006 * 6ch mode
7007 */
7008static struct hda_verb alc882_sixstack_ch6_init[] = {
7009 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7010 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7011 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7012 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7013 { } /* end */
7014};
7015
7016/*
7017 * 8ch mode
7018 */
7019static struct hda_verb alc882_sixstack_ch8_init[] = {
7020 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7021 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7022 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7023 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7024 { } /* end */
7025};
7026
7027static struct hda_channel_mode alc882_sixstack_modes[2] = {
7028 { 6, alc882_sixstack_ch6_init },
7029 { 8, alc882_sixstack_ch8_init },
7030};
7031
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007032
7033/* Macbook Air 2,1 */
7034
7035static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7036 { 2, NULL },
7037};
7038
Takashi Iwai87350ad2007-08-16 18:19:38 +02007039/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007040 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007041 */
7042
7043/*
7044 * 2ch mode
7045 */
7046static struct hda_verb alc885_mbp_ch2_init[] = {
7047 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7048 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7049 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7050 { } /* end */
7051};
7052
7053/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007054 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007055 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007056static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007057 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7058 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7059 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7060 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7061 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7062 { } /* end */
7063};
7064
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007065static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007066 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007067 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007068};
7069
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007070/*
7071 * 2ch
7072 * Speakers/Woofer/HP = Front
7073 * LineIn = Input
7074 */
7075static struct hda_verb alc885_mb5_ch2_init[] = {
7076 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7077 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7078 { } /* end */
7079};
7080
7081/*
7082 * 6ch mode
7083 * Speakers/HP = Front
7084 * Woofer = LFE
7085 * LineIn = Surround
7086 */
7087static struct hda_verb alc885_mb5_ch6_init[] = {
7088 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7089 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7090 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7091 { } /* end */
7092};
7093
7094static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7095 { 2, alc885_mb5_ch2_init },
7096 { 6, alc885_mb5_ch6_init },
7097};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007098
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007099#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007100
7101/*
7102 * 2ch mode
7103 */
7104static struct hda_verb alc883_4ST_ch2_init[] = {
7105 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7106 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7107 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7108 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7109 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7110 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7111 { } /* end */
7112};
7113
7114/*
7115 * 4ch mode
7116 */
7117static struct hda_verb alc883_4ST_ch4_init[] = {
7118 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7119 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7120 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7121 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7122 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7123 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7124 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7125 { } /* end */
7126};
7127
7128/*
7129 * 6ch mode
7130 */
7131static struct hda_verb alc883_4ST_ch6_init[] = {
7132 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7133 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7134 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7135 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7136 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7137 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7138 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7139 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7140 { } /* end */
7141};
7142
7143/*
7144 * 8ch mode
7145 */
7146static struct hda_verb alc883_4ST_ch8_init[] = {
7147 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7148 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7149 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7150 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7151 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7152 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7153 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7154 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7155 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7156 { } /* end */
7157};
7158
7159static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7160 { 2, alc883_4ST_ch2_init },
7161 { 4, alc883_4ST_ch4_init },
7162 { 6, alc883_4ST_ch6_init },
7163 { 8, alc883_4ST_ch8_init },
7164};
7165
7166
7167/*
7168 * 2ch mode
7169 */
7170static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7171 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7172 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7173 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7174 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7175 { } /* end */
7176};
7177
7178/*
7179 * 4ch mode
7180 */
7181static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7182 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7183 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7184 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7185 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7186 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7187 { } /* end */
7188};
7189
7190/*
7191 * 6ch mode
7192 */
7193static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7194 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7195 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7196 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7197 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7198 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7199 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7200 { } /* end */
7201};
7202
7203static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7204 { 2, alc883_3ST_ch2_intel_init },
7205 { 4, alc883_3ST_ch4_intel_init },
7206 { 6, alc883_3ST_ch6_intel_init },
7207};
7208
7209/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007210 * 2ch mode
7211 */
7212static struct hda_verb alc889_ch2_intel_init[] = {
7213 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7214 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7215 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7216 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7217 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7218 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7219 { } /* end */
7220};
7221
7222/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007223 * 6ch mode
7224 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007225static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007226 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7227 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7228 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7229 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7230 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007231 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7232 { } /* end */
7233};
7234
7235/*
7236 * 8ch mode
7237 */
7238static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007239 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7240 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7241 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7242 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7243 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007244 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7245 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007246 { } /* end */
7247};
7248
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007249static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7250 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007251 { 6, alc889_ch6_intel_init },
7252 { 8, alc889_ch8_intel_init },
7253};
7254
7255/*
7256 * 6ch mode
7257 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007258static struct hda_verb alc883_sixstack_ch6_init[] = {
7259 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7260 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7261 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7262 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7263 { } /* end */
7264};
7265
7266/*
7267 * 8ch mode
7268 */
7269static struct hda_verb alc883_sixstack_ch8_init[] = {
7270 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7271 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7272 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7273 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7274 { } /* end */
7275};
7276
7277static struct hda_channel_mode alc883_sixstack_modes[2] = {
7278 { 6, alc883_sixstack_ch6_init },
7279 { 8, alc883_sixstack_ch8_init },
7280};
7281
7282
Linus Torvalds1da177e2005-04-16 15:20:36 -07007283/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7284 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7285 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007286static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007287 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007288 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007289 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007290 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007291 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7292 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007293 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7294 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007295 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007296 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007297 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7298 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7299 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7300 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7301 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7302 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007303 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007304 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7305 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007306 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007307 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007308 { } /* end */
7309};
7310
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007311/* Macbook Air 2,1 same control for HP and internal Speaker */
7312
7313static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7314 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7315 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7316 { }
7317};
7318
7319
Takashi Iwai87350ad2007-08-16 18:19:38 +02007320static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007321 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7322 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7323 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7324 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7325 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007326 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7327 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007328 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7329 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007330 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007331 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7332 { } /* end */
7333};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007334
7335static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007336 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7337 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7338 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7339 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7340 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7341 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307342 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7343 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007344 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7345 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7346 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7347 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7348 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7349 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7350 { } /* end */
7351};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007352
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007353static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7354 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7355 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7356 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7357 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7358 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7359 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7360 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7361 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7362 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7363 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7364 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7365 { } /* end */
7366};
7367
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007368static struct snd_kcontrol_new alc885_imac91_mixer[] = {
7369 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7370 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
7371 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
7372 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7373 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7374 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7375 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7376 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7377 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7378 { } /* end */
7379};
7380
7381
Kailang Yangbdd148a2007-05-08 15:19:08 +02007382static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7383 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7384 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7385 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7386 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7387 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7388 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7389 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7390 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7391 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007392 { } /* end */
7393};
7394
Kailang Yang272a5272007-05-14 11:00:38 +02007395static struct snd_kcontrol_new alc882_targa_mixer[] = {
7396 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7397 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7398 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7399 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7400 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7401 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7402 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7403 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7404 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007405 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007406 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7407 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007408 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007409 { } /* end */
7410};
7411
7412/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7413 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7414 */
7415static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7416 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7417 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7418 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7419 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7420 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7421 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7422 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7423 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7424 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7425 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7426 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7427 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007428 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007429 { } /* end */
7430};
7431
Takashi Iwai914759b2007-09-06 14:52:04 +02007432static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7433 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7434 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7435 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7436 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7437 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7438 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7439 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7440 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7441 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7442 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007443 { } /* end */
7444};
7445
Kailang Yangdf694da2005-12-05 19:42:22 +01007446static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7447 {
7448 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7449 .name = "Channel Mode",
7450 .info = alc_ch_mode_info,
7451 .get = alc_ch_mode_get,
7452 .put = alc_ch_mode_put,
7453 },
7454 { } /* end */
7455};
7456
Takashi Iwai4953550a2009-06-30 15:28:30 +02007457static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007458 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007459 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7460 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007461 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007462 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7463 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007464 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007465 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7466 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007467 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007468 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7469 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007470
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007471 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007472 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007473 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007474 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007475 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007476 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007477 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007478 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007479 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007480 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007481 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007482 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007483 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007484 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007485 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007486 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007487 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007488 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007489 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7490 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007491 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007492 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7493 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007494 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007495 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7496 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7497 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7498 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7499 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007500 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007501 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007502
7503 /* FIXME: use matrix-type input source selection */
7504 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007505 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007506 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007507 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007508 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007509 /* ADC2: mute amp left and right */
7510 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007511 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007512 /* ADC3: mute amp left and right */
7513 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007514 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007515
7516 { }
7517};
7518
Takashi Iwai4953550a2009-06-30 15:28:30 +02007519static struct hda_verb alc882_adc1_init_verbs[] = {
7520 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7521 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7522 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7523 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7524 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7525 /* ADC1: mute amp left and right */
7526 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7527 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7528 { }
7529};
7530
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007531static struct hda_verb alc882_eapd_verbs[] = {
7532 /* change to EAPD mode */
7533 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007534 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007535 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007536};
7537
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007538static struct hda_verb alc889_eapd_verbs[] = {
7539 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7540 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7541 { }
7542};
7543
Wu Fengguang6732bd02009-07-30 09:19:14 +02007544static struct hda_verb alc_hp15_unsol_verbs[] = {
7545 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7546 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7547 {}
7548};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007549
7550static struct hda_verb alc885_init_verbs[] = {
7551 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01007552 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007554 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007555 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7556 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007557 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007558 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7559 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007560 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007561 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7562 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007563
7564 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007565 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007566 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7567 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7568 /* Front Pin: output 0 (0x0c) */
7569 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7570 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7571 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7572 /* Rear Pin: output 1 (0x0d) */
7573 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7574 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7575 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7576 /* CLFE Pin: output 2 (0x0e) */
7577 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7578 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7579 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7580 /* Side Pin: output 3 (0x0f) */
7581 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7582 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7583 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7584 /* Mic (rear) pin: input vref at 80% */
7585 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7586 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7587 /* Front Mic pin: input vref at 80% */
7588 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7589 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7590 /* Line In pin: input */
7591 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7592 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7593
7594 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7595 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01007596 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007597 /* Input mixer2 */
7598 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007599 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01007600 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007601 /* ADC2: mute amp left and right */
7602 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7603 /* ADC3: mute amp left and right */
7604 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7605
7606 { }
7607};
7608
7609static struct hda_verb alc885_init_input_verbs[] = {
7610 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7611 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7612 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7613 { }
7614};
7615
7616
7617/* Unmute Selector 24h and set the default input to front mic */
7618static struct hda_verb alc889_init_input_verbs[] = {
7619 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7620 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7621 { }
7622};
7623
7624
Takashi Iwai4953550a2009-06-30 15:28:30 +02007625#define alc883_init_verbs alc882_base_init_verbs
7626
Tobin Davis9102cd12006-12-15 10:02:12 +01007627/* Mac Pro test */
7628static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7629 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7630 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7631 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7632 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7633 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007634 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007635 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7636 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007637 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007638 { } /* end */
7639};
7640
7641static struct hda_verb alc882_macpro_init_verbs[] = {
7642 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7643 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7644 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7645 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7646 /* Front Pin: output 0 (0x0c) */
7647 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7648 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7649 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7650 /* Front Mic pin: input vref at 80% */
7651 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7652 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7653 /* Speaker: output */
7654 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7655 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7656 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7657 /* Headphone output (output 0 - 0x0c) */
7658 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7659 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7660 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7661
7662 /* FIXME: use matrix-type input source selection */
7663 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7664 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7665 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7666 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7667 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7668 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7669 /* Input mixer2 */
7670 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7671 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7672 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7673 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7674 /* Input mixer3 */
7675 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7676 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7677 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7678 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7679 /* ADC1: mute amp left and right */
7680 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7681 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7682 /* ADC2: mute amp left and right */
7683 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7684 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7685 /* ADC3: mute amp left and right */
7686 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7687 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7688
7689 { }
7690};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007691
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007692/* Macbook 5,1 */
7693static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007694 /* DACs */
7695 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7696 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7697 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7698 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007699 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007700 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7701 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7702 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007703 /* Surround mixer */
7704 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7705 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7706 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7707 /* LFE mixer */
7708 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7709 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7710 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7711 /* HP mixer */
7712 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7713 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7714 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7715 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007716 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7717 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007718 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7719 /* LFE Pin (0x0e) */
7720 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7721 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7722 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7723 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007724 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7725 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007726 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10307727 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007728 /* Front Mic pin: input vref at 80% */
7729 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7730 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7731 /* Line In pin */
7732 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7733 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7734
7735 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7736 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7737 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7738 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7739 { }
7740};
7741
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007742/* Macmini 3,1 */
7743static struct hda_verb alc885_macmini3_init_verbs[] = {
7744 /* DACs */
7745 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7746 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7747 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7748 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7749 /* Front mixer */
7750 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7751 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7753 /* Surround mixer */
7754 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7755 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7756 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7757 /* LFE mixer */
7758 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7759 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7760 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7761 /* HP mixer */
7762 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7763 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7764 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7765 /* Front Pin (0x0c) */
7766 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7767 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7768 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7769 /* LFE Pin (0x0e) */
7770 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7771 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7772 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7773 /* HP Pin (0x0f) */
7774 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7775 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7776 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
7777 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7778 /* Line In pin */
7779 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7780 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7781
7782 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7783 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7784 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7785 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7786 { }
7787};
7788
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007789
7790static struct hda_verb alc885_mba21_init_verbs[] = {
7791 /*Internal and HP Speaker Mixer*/
7792 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7793 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7794 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7795 /*Internal Speaker Pin (0x0c)*/
7796 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
7797 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7798 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7799 /* HP Pin: output 0 (0x0e) */
7800 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7801 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7802 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7803 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
7804 /* Line in (is hp when jack connected)*/
7805 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
7806 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7807
7808 { }
7809 };
7810
7811
Takashi Iwai87350ad2007-08-16 18:19:38 +02007812/* Macbook Pro rev3 */
7813static struct hda_verb alc885_mbp3_init_verbs[] = {
7814 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7815 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7816 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7817 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7818 /* Rear mixer */
7819 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7820 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7821 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007822 /* HP mixer */
7823 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7824 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7825 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007826 /* Front Pin: output 0 (0x0c) */
7827 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7828 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7829 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007830 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007831 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007832 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7833 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007834 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7835 /* Mic (rear) pin: input vref at 80% */
7836 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7837 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7838 /* Front Mic pin: input vref at 80% */
7839 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7840 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7841 /* Line In pin: use output 1 when in LineOut mode */
7842 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7843 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7844 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7845
7846 /* FIXME: use matrix-type input source selection */
7847 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7848 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7849 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7850 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7851 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7852 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7853 /* Input mixer2 */
7854 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7855 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7856 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7857 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7858 /* Input mixer3 */
7859 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7860 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7861 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7862 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7863 /* ADC1: mute amp left and right */
7864 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7865 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7866 /* ADC2: mute amp left and right */
7867 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7868 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7869 /* ADC3: mute amp left and right */
7870 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7871 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7872
7873 { }
7874};
7875
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007876/* iMac 9,1 */
7877static struct hda_verb alc885_imac91_init_verbs[] = {
7878 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
7879 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7880 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7881 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7882 /* Rear mixer */
7883 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7884 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7885 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7886 /* HP Pin: output 0 (0x0c) */
7887 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7888 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7889 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7890 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7891 /* Internal Speakers: output 0 (0x0d) */
7892 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7893 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7894 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7895 /* Mic (rear) pin: input vref at 80% */
7896 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7897 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7898 /* Front Mic pin: input vref at 80% */
7899 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7900 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7901 /* Line In pin: use output 1 when in LineOut mode */
7902 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7903 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7904 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7905
7906 /* FIXME: use matrix-type input source selection */
7907 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7908 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7909 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7910 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7911 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7912 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7913 /* Input mixer2 */
7914 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7915 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7916 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7917 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7918 /* Input mixer3 */
7919 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7920 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7921 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7922 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7923 /* ADC1: mute amp left and right */
7924 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7925 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7926 /* ADC2: mute amp left and right */
7927 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7928 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7929 /* ADC3: mute amp left and right */
7930 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7931 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7932
7933 { }
7934};
7935
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007936/* iMac 24 mixer. */
7937static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7938 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7939 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7940 { } /* end */
7941};
7942
7943/* iMac 24 init verbs. */
7944static struct hda_verb alc885_imac24_init_verbs[] = {
7945 /* Internal speakers: output 0 (0x0c) */
7946 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7947 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7948 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7949 /* Internal speakers: output 0 (0x0c) */
7950 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7951 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7952 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7953 /* Headphone: output 0 (0x0c) */
7954 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7955 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7956 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7957 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7958 /* Front Mic: input vref at 80% */
7959 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7960 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7961 { }
7962};
7963
7964/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007965static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007966{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007967 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007968
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007969 spec->autocfg.hp_pins[0] = 0x14;
7970 spec->autocfg.speaker_pins[0] = 0x18;
7971 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007972}
7973
Takashi Iwai9d54f082010-02-22 08:34:40 +01007974#define alc885_mb5_setup alc885_imac24_setup
7975#define alc885_macmini3_setup alc885_imac24_setup
7976
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007977/* Macbook Air 2,1 */
7978static void alc885_mba21_setup(struct hda_codec *codec)
7979{
7980 struct alc_spec *spec = codec->spec;
7981
7982 spec->autocfg.hp_pins[0] = 0x14;
7983 spec->autocfg.speaker_pins[0] = 0x18;
7984}
7985
7986
7987
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007988static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007989{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007990 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007991
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007992 spec->autocfg.hp_pins[0] = 0x15;
7993 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007994}
7995
Takashi Iwai9d54f082010-02-22 08:34:40 +01007996static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10307997{
Takashi Iwai9d54f082010-02-22 08:34:40 +01007998 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10307999
Takashi Iwai9d54f082010-02-22 08:34:40 +01008000 spec->autocfg.hp_pins[0] = 0x14;
8001 spec->autocfg.speaker_pins[0] = 0x15;
8002 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008003}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008004
Kailang Yang272a5272007-05-14 11:00:38 +02008005static struct hda_verb alc882_targa_verbs[] = {
8006 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8007 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8008
8009 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8010 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008011
Kailang Yang272a5272007-05-14 11:00:38 +02008012 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8013 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8014 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8015
8016 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008017 { } /* end */
8018};
8019
8020/* toggle speaker-output according to the hp-jack state */
8021static void alc882_targa_automute(struct hda_codec *codec)
8022{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008023 struct alc_spec *spec = codec->spec;
8024 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008025 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008026 spec->jack_present ? 1 : 3);
8027}
8028
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008029static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008030{
8031 struct alc_spec *spec = codec->spec;
8032
8033 spec->autocfg.hp_pins[0] = 0x14;
8034 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008035}
8036
8037static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8038{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008039 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008040 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008041}
8042
8043static struct hda_verb alc882_asus_a7j_verbs[] = {
8044 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8045 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8046
8047 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8048 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8049 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008050
Kailang Yang272a5272007-05-14 11:00:38 +02008051 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8052 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8053 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8054
8055 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8056 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8057 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8058 { } /* end */
8059};
8060
Takashi Iwai914759b2007-09-06 14:52:04 +02008061static struct hda_verb alc882_asus_a7m_verbs[] = {
8062 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8063 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8064
8065 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8066 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8067 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008068
Takashi Iwai914759b2007-09-06 14:52:04 +02008069 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8070 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8071 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8072
8073 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8074 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8075 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8076 { } /* end */
8077};
8078
Tobin Davis9102cd12006-12-15 10:02:12 +01008079static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8080{
8081 unsigned int gpiostate, gpiomask, gpiodir;
8082
8083 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8084 AC_VERB_GET_GPIO_DATA, 0);
8085
8086 if (!muted)
8087 gpiostate |= (1 << pin);
8088 else
8089 gpiostate &= ~(1 << pin);
8090
8091 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8092 AC_VERB_GET_GPIO_MASK, 0);
8093 gpiomask |= (1 << pin);
8094
8095 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8096 AC_VERB_GET_GPIO_DIRECTION, 0);
8097 gpiodir |= (1 << pin);
8098
8099
8100 snd_hda_codec_write(codec, codec->afg, 0,
8101 AC_VERB_SET_GPIO_MASK, gpiomask);
8102 snd_hda_codec_write(codec, codec->afg, 0,
8103 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8104
8105 msleep(1);
8106
8107 snd_hda_codec_write(codec, codec->afg, 0,
8108 AC_VERB_SET_GPIO_DATA, gpiostate);
8109}
8110
Takashi Iwai7debbe52007-08-16 15:01:03 +02008111/* set up GPIO at initialization */
8112static void alc885_macpro_init_hook(struct hda_codec *codec)
8113{
8114 alc882_gpio_mute(codec, 0, 0);
8115 alc882_gpio_mute(codec, 1, 0);
8116}
8117
8118/* set up GPIO and update auto-muting at initialization */
8119static void alc885_imac24_init_hook(struct hda_codec *codec)
8120{
8121 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008122 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008123}
8124
Kailang Yangdf694da2005-12-05 19:42:22 +01008125/*
8126 * generic initialization of ADC, input mixers and output mixers
8127 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008128static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008129 /*
8130 * Unmute ADC0-2 and set the default input to mic-in
8131 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008132 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8133 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8134 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8135 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8136
Kailang Yangdf694da2005-12-05 19:42:22 +01008137 /*
8138 * Set up output mixers (0x0c - 0x0f)
8139 */
8140 /* set vol=0 to output mixers */
8141 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8142 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8143 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8144 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8145 /* set up input amps for analog loopback */
8146 /* Amp Indices: DAC = 0, mixer = 1 */
8147 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8148 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8149 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8150 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8151 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8152 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8153 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8154 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8155 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8156 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8157
8158 /* FIXME: use matrix-type input source selection */
8159 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008160 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008161 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008162 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008163 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008164 { }
8165};
8166
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008167/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8168static struct hda_verb alc889A_mb31_ch2_init[] = {
8169 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8170 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8171 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8172 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8173 { } /* end */
8174};
8175
8176/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8177static struct hda_verb alc889A_mb31_ch4_init[] = {
8178 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8179 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8180 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8181 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8182 { } /* end */
8183};
8184
8185/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8186static struct hda_verb alc889A_mb31_ch5_init[] = {
8187 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8188 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8189 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8190 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8191 { } /* end */
8192};
8193
8194/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8195static struct hda_verb alc889A_mb31_ch6_init[] = {
8196 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8197 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8198 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8199 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8200 { } /* end */
8201};
8202
8203static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8204 { 2, alc889A_mb31_ch2_init },
8205 { 4, alc889A_mb31_ch4_init },
8206 { 5, alc889A_mb31_ch5_init },
8207 { 6, alc889A_mb31_ch6_init },
8208};
8209
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008210static struct hda_verb alc883_medion_eapd_verbs[] = {
8211 /* eanable EAPD on medion laptop */
8212 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8213 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8214 { }
8215};
8216
Takashi Iwai4953550a2009-06-30 15:28:30 +02008217#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008218
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008219static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8220 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8221 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8222 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8223 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8224 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8225 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8226 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8227 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8228 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8229 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8230 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8231 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8232 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008233 { } /* end */
8234};
8235
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008236static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008237 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8238 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8239 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8240 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8241 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8242 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8243 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8244 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8245 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8246 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008247 { } /* end */
8248};
8249
Jiang zhefb97dc62008-03-06 11:07:11 +01008250static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8251 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8252 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8253 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8254 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8255 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8256 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8257 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8258 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8259 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8260 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008261 { } /* end */
8262};
8263
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008264static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8265 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8266 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8267 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8268 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8269 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8270 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8271 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8272 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008273 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008274 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8275 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008276 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008277 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008278 { } /* end */
8279};
8280
8281static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8282 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8283 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8284 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8285 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8286 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8287 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8288 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8289 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8290 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8291 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8292 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8293 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8294 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8295 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008296 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008297 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8298 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008299 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008300 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008301 { } /* end */
8302};
8303
Jiang zhe17bba1b2008-06-04 12:11:07 +02008304static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8305 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8306 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8307 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8308 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8309 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8310 HDA_OUTPUT),
8311 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8312 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8313 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8314 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8315 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8316 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8317 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8318 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8319 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8320 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8321 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8322 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8323 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8324 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008325 { } /* end */
8326};
8327
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008328static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8329 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8330 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8331 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8332 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8333 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8334 HDA_OUTPUT),
8335 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8336 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8337 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8338 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8339 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8340 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8341 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8342 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8343 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8344 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8345 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8346 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8347 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8348 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8349 { } /* end */
8350};
8351
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008352static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008353 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008354 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008355 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008356 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008357 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8358 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008359 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8360 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008361 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8362 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8363 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8364 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8365 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008367 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008368 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8369 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008370 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008371 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008372 { } /* end */
8373};
8374
Sasha Alexandrc2592492009-06-16 14:52:54 -04008375static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008376 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008377 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008378 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008379 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008380 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8381 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8382 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8383 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8384 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8385 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8386 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8387 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8388 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8389 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8390 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008391 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008392 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008393 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008394};
Kailang Yangccc656c2006-10-17 12:32:26 +02008395
Sasha Alexandrc2592492009-06-16 14:52:54 -04008396static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008397 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008398 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008399 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008400 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008401 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8402 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8403 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008404 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008405 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008406 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8407 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8408 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008409 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008410};
Kailang Yangccc656c2006-10-17 12:32:26 +02008411
Takashi Iwaib99dba32009-09-17 18:23:00 +02008412static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8413 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8414 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8415 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8416 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8417 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8418 { } /* end */
8419};
8420
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008421static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8422 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8423 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008424 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8425 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008426 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8427 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8428 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8429 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008430 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008431};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008432
Kailang Yang272a5272007-05-14 11:00:38 +02008433static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8434 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8435 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8436 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8437 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8438 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8439 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8440 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8441 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8442 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008443 { } /* end */
8444};
8445
8446static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8447 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8448 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8449 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8450 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8451 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8452 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8453 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8454 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8455 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008456 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008457};
Kailang Yang272a5272007-05-14 11:00:38 +02008458
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02008459static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
8460 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8461 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8462 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8463 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
8464 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
8465 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
8466 { } /* end */
8467};
8468
8469static struct hda_verb alc883_medion_wim2160_verbs[] = {
8470 /* Unmute front mixer */
8471 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8472 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8473
8474 /* Set speaker pin to front mixer */
8475 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8476
8477 /* Init headphone pin */
8478 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8479 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8480 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8481 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8482
8483 { } /* end */
8484};
8485
8486/* toggle speaker-output according to the hp-jack state */
8487static void alc883_medion_wim2160_setup(struct hda_codec *codec)
8488{
8489 struct alc_spec *spec = codec->spec;
8490
8491 spec->autocfg.hp_pins[0] = 0x1a;
8492 spec->autocfg.speaker_pins[0] = 0x15;
8493}
8494
Tobin Davis2880a862007-08-07 11:50:26 +02008495static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008496 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8497 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008498 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008499 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8500 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008501 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8502 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8503 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008504 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008505};
Tobin Davis2880a862007-08-07 11:50:26 +02008506
Tony Vroond2fd4b02009-06-21 00:40:10 +01008507static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8508 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008509 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008510 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8511 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008512 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8513 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8514 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8515 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8516 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8517 { } /* end */
8518};
8519
Kailang Yange2757d52008-08-26 13:17:46 +02008520static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8521 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8522 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8523 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8524 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8525 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8526 0x0d, 1, 0x0, HDA_OUTPUT),
8527 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8528 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8529 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8530 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8531 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008532 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8533 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8534 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8535 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8536 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8537 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8538 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8539 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8540 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8541 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008542 { } /* end */
8543};
8544
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008545static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8546 /* Output mixers */
8547 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8548 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8549 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8550 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8551 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8552 HDA_OUTPUT),
8553 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8554 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8555 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8556 /* Output switches */
8557 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8558 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8559 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8560 /* Boost mixers */
8561 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8562 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8563 /* Input mixers */
8564 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8565 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8566 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8567 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8568 { } /* end */
8569};
8570
Guido Günther3e1647c2009-06-05 00:47:26 +02008571static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8572 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8573 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8574 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8575 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8576 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8577 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8578 { } /* end */
8579};
8580
Kailang Yange2757d52008-08-26 13:17:46 +02008581static struct hda_bind_ctls alc883_bind_cap_vol = {
8582 .ops = &snd_hda_bind_vol,
8583 .values = {
8584 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8585 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8586 0
8587 },
8588};
8589
8590static struct hda_bind_ctls alc883_bind_cap_switch = {
8591 .ops = &snd_hda_bind_sw,
8592 .values = {
8593 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8594 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8595 0
8596 },
8597};
8598
8599static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8600 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8601 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8602 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8603 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8604 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8605 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8606 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8607 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008608 { } /* end */
8609};
8610
8611static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008612 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8613 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8614 {
8615 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8616 /* .name = "Capture Source", */
8617 .name = "Input Source",
8618 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008619 .info = alc_mux_enum_info,
8620 .get = alc_mux_enum_get,
8621 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008622 },
8623 { } /* end */
8624};
8625
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008626static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8627 {
8628 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8629 .name = "Channel Mode",
8630 .info = alc_ch_mode_info,
8631 .get = alc_ch_mode_get,
8632 .put = alc_ch_mode_put,
8633 },
8634 { } /* end */
8635};
8636
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008637/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008638static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008639{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008640 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008641
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008642 spec->autocfg.hp_pins[0] = 0x15;
8643 spec->autocfg.speaker_pins[0] = 0x14;
8644 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008645}
8646
8647/* auto-toggle front mic */
8648/*
8649static void alc883_mitac_mic_automute(struct hda_codec *codec)
8650{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008651 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008652
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008653 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8654}
8655*/
8656
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008657static struct hda_verb alc883_mitac_verbs[] = {
8658 /* HP */
8659 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8660 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8661 /* Subwoofer */
8662 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8663 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8664
8665 /* enable unsolicited event */
8666 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8667 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8668
8669 { } /* end */
8670};
8671
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308672static struct hda_verb alc883_clevo_m540r_verbs[] = {
8673 /* HP */
8674 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8675 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8676 /* Int speaker */
8677 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8678
8679 /* enable unsolicited event */
8680 /*
8681 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8682 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8683 */
8684
8685 { } /* end */
8686};
8687
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008688static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008689 /* HP */
8690 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8691 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8692 /* Int speaker */
8693 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8694 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8695
8696 /* enable unsolicited event */
8697 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008698 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008699
8700 { } /* end */
8701};
8702
Jiang zhefb97dc62008-03-06 11:07:11 +01008703static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8704 /* HP */
8705 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8706 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8707 /* Subwoofer */
8708 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8709 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8710
8711 /* enable unsolicited event */
8712 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8713
8714 { } /* end */
8715};
8716
Sasha Alexandrc2592492009-06-16 14:52:54 -04008717static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008718 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8719 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8720
8721 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8722 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008723
David Heidelberger64a8be72009-06-08 16:15:18 +02008724/* Connect Line-Out side jack (SPDIF) to Side */
8725 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8726 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8727 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8728/* Connect Mic jack to CLFE */
8729 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8730 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8731 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8732/* Connect Line-in jack to Surround */
8733 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8734 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8735 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8736/* Connect HP out jack to Front */
8737 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8738 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8739 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008740
8741 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008742
8743 { } /* end */
8744};
8745
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008746static struct hda_verb alc883_lenovo_101e_verbs[] = {
8747 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8748 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8749 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8750 { } /* end */
8751};
8752
Kailang Yang272a5272007-05-14 11:00:38 +02008753static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8754 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8755 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8756 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8757 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8758 { } /* end */
8759};
8760
8761static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8762 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8763 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8764 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8765 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8766 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8767 { } /* end */
8768};
8769
Kailang Yang189609a2007-08-20 11:31:23 +02008770static struct hda_verb alc883_haier_w66_verbs[] = {
8771 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8772 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8773
8774 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8775
8776 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8777 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8778 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8779 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8780 { } /* end */
8781};
8782
Kailang Yange2757d52008-08-26 13:17:46 +02008783static struct hda_verb alc888_lenovo_sky_verbs[] = {
8784 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8785 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8786 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8787 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8788 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8789 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8790 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8791 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8792 { } /* end */
8793};
8794
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008795static struct hda_verb alc888_6st_dell_verbs[] = {
8796 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8797 { }
8798};
8799
Guido Günther3e1647c2009-06-05 00:47:26 +02008800static struct hda_verb alc883_vaiott_verbs[] = {
8801 /* HP */
8802 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8803 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8804
8805 /* enable unsolicited event */
8806 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8807
8808 { } /* end */
8809};
8810
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008811static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008812{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008813 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008814
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008815 spec->autocfg.hp_pins[0] = 0x1b;
8816 spec->autocfg.speaker_pins[0] = 0x14;
8817 spec->autocfg.speaker_pins[1] = 0x16;
8818 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008819}
8820
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008821static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008822 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008823 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8824 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008825 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008826 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008827};
8828
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008829/*
8830 * 2ch mode
8831 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008832static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008833 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8834 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8835 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8836 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008837 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008838};
8839
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008840/*
8841 * 4ch mode
8842 */
8843static struct hda_verb alc888_3st_hp_4ch_init[] = {
8844 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8845 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8846 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8847 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8848 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8849 { } /* end */
8850};
8851
8852/*
8853 * 6ch mode
8854 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008855static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008856 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8857 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008858 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008859 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8860 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008861 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8862 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008863};
8864
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008865static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008866 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008867 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008868 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008869};
8870
Kailang Yang272a5272007-05-14 11:00:38 +02008871/* toggle front-jack and RCA according to the hp-jack state */
8872static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8873{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008874 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008875
Takashi Iwai47fd8302007-08-10 17:11:07 +02008876 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8877 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8878 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8879 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008880}
8881
8882/* toggle RCA according to the front-jack state */
8883static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8884{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008885 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02008886
Takashi Iwai47fd8302007-08-10 17:11:07 +02008887 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8888 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008889}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008890
Kailang Yang272a5272007-05-14 11:00:38 +02008891static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8892 unsigned int res)
8893{
8894 if ((res >> 26) == ALC880_HP_EVENT)
8895 alc888_lenovo_ms7195_front_automute(codec);
8896 if ((res >> 26) == ALC880_FRONT_EVENT)
8897 alc888_lenovo_ms7195_rca_automute(codec);
8898}
8899
8900static struct hda_verb alc883_medion_md2_verbs[] = {
8901 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8902 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8903
8904 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8905
8906 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8907 { } /* end */
8908};
8909
8910/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008911static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008912{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008913 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008914
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008915 spec->autocfg.hp_pins[0] = 0x14;
8916 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008917}
8918
Kailang Yangccc656c2006-10-17 12:32:26 +02008919/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008920#define alc883_targa_init_hook alc882_targa_init_hook
8921#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008922
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008923static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8924{
8925 unsigned int present;
8926
Takashi Iwaid56757a2009-11-18 08:00:14 +01008927 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008928 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8929 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8930}
8931
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008932static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008933{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008934 struct alc_spec *spec = codec->spec;
8935
8936 spec->autocfg.hp_pins[0] = 0x15;
8937 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008938}
8939
8940static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8941{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008942 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008943 alc883_clevo_m720_mic_automute(codec);
8944}
8945
8946static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008947 unsigned int res)
8948{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008949 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008950 case ALC880_MIC_EVENT:
8951 alc883_clevo_m720_mic_automute(codec);
8952 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008953 default:
8954 alc_automute_amp_unsol_event(codec, res);
8955 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008956 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008957}
8958
Jiang zhefb97dc62008-03-06 11:07:11 +01008959/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008960static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008961{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008962 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008963
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008964 spec->autocfg.hp_pins[0] = 0x14;
8965 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008966}
8967
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008968static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008969{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008970 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008971
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008972 spec->autocfg.hp_pins[0] = 0x1b;
8973 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008974}
8975
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008976static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8977{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008978 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008979
Takashi Iwai47fd8302007-08-10 17:11:07 +02008980 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8981 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008982}
8983
8984static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8985{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008986 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008987
Takashi Iwai47fd8302007-08-10 17:11:07 +02008988 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8989 HDA_AMP_MUTE, bits);
8990 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8991 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008992}
8993
8994static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8995 unsigned int res)
8996{
8997 if ((res >> 26) == ALC880_HP_EVENT)
8998 alc883_lenovo_101e_all_automute(codec);
8999 if ((res >> 26) == ALC880_FRONT_EVENT)
9000 alc883_lenovo_101e_ispeaker_automute(codec);
9001}
9002
Takashi Iwai676a9b52007-08-16 15:23:35 +02009003/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009004static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009005{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009006 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009007
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009008 spec->autocfg.hp_pins[0] = 0x14;
9009 spec->autocfg.speaker_pins[0] = 0x15;
9010 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009011}
9012
Kailang Yangd1a991a2007-08-15 16:21:59 +02009013static struct hda_verb alc883_acer_eapd_verbs[] = {
9014 /* HP Pin: output 0 (0x0c) */
9015 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9016 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9017 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9018 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009019 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9020 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009021 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009022 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9023 /* eanable EAPD on medion laptop */
9024 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9025 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009026 /* enable unsolicited event */
9027 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009028 { }
9029};
9030
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009031static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
9032 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9033 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9034 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9035 { } /* end */
9036};
9037
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009038static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009039{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009040 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +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;
9046 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009047}
9048
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009049static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009050{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009051 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009052
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009053 spec->autocfg.hp_pins[0] = 0x1b;
9054 spec->autocfg.speaker_pins[0] = 0x14;
9055 spec->autocfg.speaker_pins[1] = 0x15;
9056 spec->autocfg.speaker_pins[2] = 0x16;
9057 spec->autocfg.speaker_pins[3] = 0x17;
9058 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009059}
9060
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009061static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009062{
9063 struct alc_spec *spec = codec->spec;
9064
9065 spec->autocfg.hp_pins[0] = 0x15;
9066 spec->autocfg.speaker_pins[0] = 0x14;
9067 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009068}
9069
Kailang Yange2757d52008-08-26 13:17:46 +02009070static struct hda_verb alc888_asus_m90v_verbs[] = {
9071 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9072 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9073 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9074 /* enable unsolicited event */
9075 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9076 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9077 { } /* end */
9078};
9079
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009080static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009081{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009082 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009083
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009084 spec->autocfg.hp_pins[0] = 0x1b;
9085 spec->autocfg.speaker_pins[0] = 0x14;
9086 spec->autocfg.speaker_pins[1] = 0x15;
9087 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009088 spec->ext_mic.pin = 0x18;
9089 spec->int_mic.pin = 0x19;
9090 spec->ext_mic.mux_idx = 0;
9091 spec->int_mic.mux_idx = 1;
9092 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009093}
9094
9095static struct hda_verb alc888_asus_eee1601_verbs[] = {
9096 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9097 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9099 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9100 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9101 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9102 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9103 /* enable unsolicited event */
9104 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9105 { } /* end */
9106};
9107
Kailang Yange2757d52008-08-26 13:17:46 +02009108static void alc883_eee1601_inithook(struct hda_codec *codec)
9109{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009110 struct alc_spec *spec = codec->spec;
9111
9112 spec->autocfg.hp_pins[0] = 0x14;
9113 spec->autocfg.speaker_pins[0] = 0x1b;
9114 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009115}
9116
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009117static struct hda_verb alc889A_mb31_verbs[] = {
9118 /* Init rear pin (used as headphone output) */
9119 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9120 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9121 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9122 /* Init line pin (used as output in 4ch and 6ch mode) */
9123 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9124 /* Init line 2 pin (used as headphone out by default) */
9125 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9126 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9127 { } /* end */
9128};
9129
9130/* Mute speakers according to the headphone jack state */
9131static void alc889A_mb31_automute(struct hda_codec *codec)
9132{
9133 unsigned int present;
9134
9135 /* Mute only in 2ch or 4ch mode */
9136 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9137 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009138 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009139 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9140 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9141 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9142 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9143 }
9144}
9145
9146static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9147{
9148 if ((res >> 26) == ALC880_HP_EVENT)
9149 alc889A_mb31_automute(codec);
9150}
9151
Takashi Iwai4953550a2009-06-30 15:28:30 +02009152
Takashi Iwaicb53c622007-08-10 17:21:45 +02009153#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009154#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009155#endif
9156
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009157/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009158#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9159#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9160#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9161#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9162
9163static hda_nid_t alc883_slave_dig_outs[] = {
9164 ALC1200_DIGOUT_NID, 0,
9165};
9166
9167static hda_nid_t alc1200_slave_dig_outs[] = {
9168 ALC883_DIGOUT_NID, 0,
9169};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009170
9171/*
9172 * configuration and preset
9173 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009174static const char *alc882_models[ALC882_MODEL_LAST] = {
9175 [ALC882_3ST_DIG] = "3stack-dig",
9176 [ALC882_6ST_DIG] = "6stack-dig",
9177 [ALC882_ARIMA] = "arima",
9178 [ALC882_W2JC] = "w2jc",
9179 [ALC882_TARGA] = "targa",
9180 [ALC882_ASUS_A7J] = "asus-a7j",
9181 [ALC882_ASUS_A7M] = "asus-a7m",
9182 [ALC885_MACPRO] = "macpro",
9183 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009184 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009185 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009186 [ALC885_MBP3] = "mbp3",
9187 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009188 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009189 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009190 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9191 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009192 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009193 [ALC883_TARGA_DIG] = "targa-dig",
9194 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009195 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009196 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009197 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009198 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009199 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009200 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009201 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009202 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009203 [ALC883_MEDION_MD2] = "medion-md2",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009204 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009205 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009206 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009207 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9208 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009209 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009210 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009211 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009212 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009213 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309214 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009215 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009216 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009217 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009218 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009219 [ALC889A_INTEL] = "intel-alc889a",
9220 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009221 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009222 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009223 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009224 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009225};
9226
Takashi Iwai4953550a2009-06-30 15:28:30 +02009227static struct snd_pci_quirk alc882_cfg_tbl[] = {
9228 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9229
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009230 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009231 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009232 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009233 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9234 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009235 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009236 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9237 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009238 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009239 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009240 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9241 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009242 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9243 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009244 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9245 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009246 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009247 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009248 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009249 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009250 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9251 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009252 /* default Acer -- disabled as it causes more problems.
9253 * model=auto should work fine now
9254 */
9255 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009256
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009257 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009258
Tobin Davisfebe3372007-06-12 11:27:46 +02009259 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009260 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9261 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009262 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009263 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009264 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009265
9266 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9267 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9268 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009269 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009270 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9271 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9272 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009273 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009274 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009275 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009276 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009277
9278 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009279 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009280 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009281 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009282 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9283 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009284 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009285 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009286 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9287
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009288 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9289 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9290 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009291 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009292 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009293 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009294 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009295 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009296 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9297 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9298 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9299 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9300 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9301 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009302 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009303 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9304 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9305 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009306 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009307 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009308 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9309 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009310 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009311 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009312 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009313 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009314 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009315 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009316 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009317 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009318 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009319
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009320 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009321 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9322 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309323 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009324 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009325 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009326 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009327 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009328 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009329 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009330 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009331 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009332 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009333 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009334 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9335 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009336 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009337 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009338 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009339 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009340 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009341
Jiang zhe17bba1b2008-06-04 12:11:07 +02009342 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9343 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009344 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009345 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9346 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9347 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009348 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009349
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009350 {}
9351};
9352
Takashi Iwai4953550a2009-06-30 15:28:30 +02009353/* codec SSID table for Intel Mac */
9354static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9355 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9356 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9357 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9358 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9359 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9360 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9361 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
9362 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9363 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9364 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009365 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009366 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009367 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9368 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009369 */
9370 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009371 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009372 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009373 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009374};
9375
Takashi Iwai4953550a2009-06-30 15:28:30 +02009376static struct alc_config_preset alc882_presets[] = {
9377 [ALC882_3ST_DIG] = {
9378 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009379 .init_verbs = { alc882_base_init_verbs,
9380 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009381 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9382 .dac_nids = alc882_dac_nids,
9383 .dig_out_nid = ALC882_DIGOUT_NID,
9384 .dig_in_nid = ALC882_DIGIN_NID,
9385 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9386 .channel_mode = alc882_ch_modes,
9387 .need_dac_fix = 1,
9388 .input_mux = &alc882_capture_source,
9389 },
9390 [ALC882_6ST_DIG] = {
9391 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009392 .init_verbs = { alc882_base_init_verbs,
9393 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009394 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9395 .dac_nids = alc882_dac_nids,
9396 .dig_out_nid = ALC882_DIGOUT_NID,
9397 .dig_in_nid = ALC882_DIGIN_NID,
9398 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9399 .channel_mode = alc882_sixstack_modes,
9400 .input_mux = &alc882_capture_source,
9401 },
9402 [ALC882_ARIMA] = {
9403 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009404 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9405 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009406 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9407 .dac_nids = alc882_dac_nids,
9408 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9409 .channel_mode = alc882_sixstack_modes,
9410 .input_mux = &alc882_capture_source,
9411 },
9412 [ALC882_W2JC] = {
9413 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009414 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9415 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009416 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9417 .dac_nids = alc882_dac_nids,
9418 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9419 .channel_mode = alc880_threestack_modes,
9420 .need_dac_fix = 1,
9421 .input_mux = &alc882_capture_source,
9422 .dig_out_nid = ALC882_DIGOUT_NID,
9423 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009424 [ALC885_MBA21] = {
9425 .mixers = { alc885_mba21_mixer },
9426 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9427 .num_dacs = 2,
9428 .dac_nids = alc882_dac_nids,
9429 .channel_mode = alc885_mba21_ch_modes,
9430 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9431 .input_mux = &alc882_capture_source,
9432 .unsol_event = alc_automute_amp_unsol_event,
9433 .setup = alc885_mba21_setup,
9434 .init_hook = alc_automute_amp,
9435 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009436 [ALC885_MBP3] = {
9437 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9438 .init_verbs = { alc885_mbp3_init_verbs,
9439 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009440 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009441 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009442 .hp_nid = 0x04,
9443 .channel_mode = alc885_mbp_4ch_modes,
9444 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009445 .input_mux = &alc882_capture_source,
9446 .dig_out_nid = ALC882_DIGOUT_NID,
9447 .dig_in_nid = ALC882_DIGIN_NID,
9448 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009449 .setup = alc885_mbp3_setup,
9450 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009451 },
9452 [ALC885_MB5] = {
9453 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9454 .init_verbs = { alc885_mb5_init_verbs,
9455 alc880_gpio1_init_verbs },
9456 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9457 .dac_nids = alc882_dac_nids,
9458 .channel_mode = alc885_mb5_6ch_modes,
9459 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9460 .input_mux = &mb5_capture_source,
9461 .dig_out_nid = ALC882_DIGOUT_NID,
9462 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009463 .unsol_event = alc_automute_amp_unsol_event,
9464 .setup = alc885_mb5_setup,
9465 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009466 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009467 [ALC885_MACMINI3] = {
9468 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9469 .init_verbs = { alc885_macmini3_init_verbs,
9470 alc880_gpio1_init_verbs },
9471 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9472 .dac_nids = alc882_dac_nids,
9473 .channel_mode = alc885_macmini3_6ch_modes,
9474 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9475 .input_mux = &macmini3_capture_source,
9476 .dig_out_nid = ALC882_DIGOUT_NID,
9477 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009478 .unsol_event = alc_automute_amp_unsol_event,
9479 .setup = alc885_macmini3_setup,
9480 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009481 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009482 [ALC885_MACPRO] = {
9483 .mixers = { alc882_macpro_mixer },
9484 .init_verbs = { alc882_macpro_init_verbs },
9485 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9486 .dac_nids = alc882_dac_nids,
9487 .dig_out_nid = ALC882_DIGOUT_NID,
9488 .dig_in_nid = ALC882_DIGIN_NID,
9489 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9490 .channel_mode = alc882_ch_modes,
9491 .input_mux = &alc882_capture_source,
9492 .init_hook = alc885_macpro_init_hook,
9493 },
9494 [ALC885_IMAC24] = {
9495 .mixers = { alc885_imac24_mixer },
9496 .init_verbs = { alc885_imac24_init_verbs },
9497 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9498 .dac_nids = alc882_dac_nids,
9499 .dig_out_nid = ALC882_DIGOUT_NID,
9500 .dig_in_nid = ALC882_DIGIN_NID,
9501 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9502 .channel_mode = alc882_ch_modes,
9503 .input_mux = &alc882_capture_source,
9504 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009505 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009506 .init_hook = alc885_imac24_init_hook,
9507 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009508 [ALC885_IMAC91] = {
9509 .mixers = { alc885_imac91_mixer, alc882_chmode_mixer },
9510 .init_verbs = { alc885_imac91_init_verbs,
9511 alc880_gpio1_init_verbs },
9512 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9513 .dac_nids = alc882_dac_nids,
9514 .channel_mode = alc885_mbp_4ch_modes,
9515 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
9516 .input_mux = &alc882_capture_source,
9517 .dig_out_nid = ALC882_DIGOUT_NID,
9518 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009519 .unsol_event = alc_automute_amp_unsol_event,
9520 .setup = alc885_imac91_setup,
9521 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009522 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009523 [ALC882_TARGA] = {
9524 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009525 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009526 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009527 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9528 .dac_nids = alc882_dac_nids,
9529 .dig_out_nid = ALC882_DIGOUT_NID,
9530 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9531 .adc_nids = alc882_adc_nids,
9532 .capsrc_nids = alc882_capsrc_nids,
9533 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9534 .channel_mode = alc882_3ST_6ch_modes,
9535 .need_dac_fix = 1,
9536 .input_mux = &alc882_capture_source,
9537 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009538 .setup = alc882_targa_setup,
9539 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009540 },
9541 [ALC882_ASUS_A7J] = {
9542 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009543 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9544 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009545 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9546 .dac_nids = alc882_dac_nids,
9547 .dig_out_nid = ALC882_DIGOUT_NID,
9548 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9549 .adc_nids = alc882_adc_nids,
9550 .capsrc_nids = alc882_capsrc_nids,
9551 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9552 .channel_mode = alc882_3ST_6ch_modes,
9553 .need_dac_fix = 1,
9554 .input_mux = &alc882_capture_source,
9555 },
9556 [ALC882_ASUS_A7M] = {
9557 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009558 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9559 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009560 alc882_asus_a7m_verbs },
9561 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9562 .dac_nids = alc882_dac_nids,
9563 .dig_out_nid = ALC882_DIGOUT_NID,
9564 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9565 .channel_mode = alc880_threestack_modes,
9566 .need_dac_fix = 1,
9567 .input_mux = &alc882_capture_source,
9568 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009569 [ALC883_3ST_2ch_DIG] = {
9570 .mixers = { alc883_3ST_2ch_mixer },
9571 .init_verbs = { alc883_init_verbs },
9572 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9573 .dac_nids = alc883_dac_nids,
9574 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009575 .dig_in_nid = ALC883_DIGIN_NID,
9576 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9577 .channel_mode = alc883_3ST_2ch_modes,
9578 .input_mux = &alc883_capture_source,
9579 },
9580 [ALC883_3ST_6ch_DIG] = {
9581 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9582 .init_verbs = { alc883_init_verbs },
9583 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9584 .dac_nids = alc883_dac_nids,
9585 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009586 .dig_in_nid = ALC883_DIGIN_NID,
9587 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9588 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009589 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009590 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009591 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009592 [ALC883_3ST_6ch] = {
9593 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9594 .init_verbs = { alc883_init_verbs },
9595 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9596 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009597 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9598 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009599 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009600 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009601 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009602 [ALC883_3ST_6ch_INTEL] = {
9603 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9604 .init_verbs = { alc883_init_verbs },
9605 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9606 .dac_nids = alc883_dac_nids,
9607 .dig_out_nid = ALC883_DIGOUT_NID,
9608 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009609 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009610 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9611 .channel_mode = alc883_3ST_6ch_intel_modes,
9612 .need_dac_fix = 1,
9613 .input_mux = &alc883_3stack_6ch_intel,
9614 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009615 [ALC889A_INTEL] = {
9616 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009617 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9618 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009619 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9620 .dac_nids = alc883_dac_nids,
9621 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9622 .adc_nids = alc889_adc_nids,
9623 .dig_out_nid = ALC883_DIGOUT_NID,
9624 .dig_in_nid = ALC883_DIGIN_NID,
9625 .slave_dig_outs = alc883_slave_dig_outs,
9626 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9627 .channel_mode = alc889_8ch_intel_modes,
9628 .capsrc_nids = alc889_capsrc_nids,
9629 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009630 .setup = alc889_automute_setup,
9631 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009632 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009633 .need_dac_fix = 1,
9634 },
9635 [ALC889_INTEL] = {
9636 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9637 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009638 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009639 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9640 .dac_nids = alc883_dac_nids,
9641 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9642 .adc_nids = alc889_adc_nids,
9643 .dig_out_nid = ALC883_DIGOUT_NID,
9644 .dig_in_nid = ALC883_DIGIN_NID,
9645 .slave_dig_outs = alc883_slave_dig_outs,
9646 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9647 .channel_mode = alc889_8ch_intel_modes,
9648 .capsrc_nids = alc889_capsrc_nids,
9649 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009650 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009651 .init_hook = alc889_intel_init_hook,
9652 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009653 .need_dac_fix = 1,
9654 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009655 [ALC883_6ST_DIG] = {
9656 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9657 .init_verbs = { alc883_init_verbs },
9658 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9659 .dac_nids = alc883_dac_nids,
9660 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009661 .dig_in_nid = ALC883_DIGIN_NID,
9662 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9663 .channel_mode = alc883_sixstack_modes,
9664 .input_mux = &alc883_capture_source,
9665 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009666 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009667 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009668 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9669 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009670 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9671 .dac_nids = alc883_dac_nids,
9672 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009673 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9674 .channel_mode = alc883_3ST_6ch_modes,
9675 .need_dac_fix = 1,
9676 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009677 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009678 .setup = alc882_targa_setup,
9679 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009680 },
9681 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009682 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009683 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9684 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009685 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9686 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009687 .adc_nids = alc883_adc_nids_alt,
9688 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009689 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009690 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009691 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9692 .channel_mode = alc883_3ST_2ch_modes,
9693 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009694 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009695 .setup = alc882_targa_setup,
9696 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009697 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009698 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009699 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9700 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009701 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009702 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009703 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9704 .dac_nids = alc883_dac_nids,
9705 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9706 .adc_nids = alc883_adc_nids_rev,
9707 .capsrc_nids = alc883_capsrc_nids_rev,
9708 .dig_out_nid = ALC883_DIGOUT_NID,
9709 .dig_in_nid = ALC883_DIGIN_NID,
9710 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9711 .channel_mode = alc883_4ST_8ch_modes,
9712 .need_dac_fix = 1,
9713 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009714 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009715 .setup = alc882_targa_setup,
9716 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009717 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009718 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009719 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009720 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9721 * and the headphone jack. Turn this on and rely on the
9722 * standard mute methods whenever the user wants to turn
9723 * these outputs off.
9724 */
9725 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9726 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9727 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009728 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9729 .channel_mode = alc883_3ST_2ch_modes,
9730 .input_mux = &alc883_capture_source,
9731 },
Tobin Davis2880a862007-08-07 11:50:26 +02009732 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009733 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009734 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009735 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9736 .dac_nids = alc883_dac_nids,
9737 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009738 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9739 .channel_mode = alc883_3ST_2ch_modes,
9740 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009741 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009742 .setup = alc883_acer_aspire_setup,
9743 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009744 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009745 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009746 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009747 alc883_chmode_mixer },
9748 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9749 alc888_acer_aspire_4930g_verbs },
9750 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9751 .dac_nids = alc883_dac_nids,
9752 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9753 .adc_nids = alc883_adc_nids_rev,
9754 .capsrc_nids = alc883_capsrc_nids_rev,
9755 .dig_out_nid = ALC883_DIGOUT_NID,
9756 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9757 .channel_mode = alc883_3ST_6ch_modes,
9758 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +01009759 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009760 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009761 ARRAY_SIZE(alc888_2_capture_sources),
9762 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009763 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009764 .setup = alc888_acer_aspire_4930g_setup,
9765 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009766 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009767 [ALC888_ACER_ASPIRE_6530G] = {
9768 .mixers = { alc888_acer_aspire_6530_mixer },
9769 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9770 alc888_acer_aspire_6530g_verbs },
9771 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9772 .dac_nids = alc883_dac_nids,
9773 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9774 .adc_nids = alc883_adc_nids_rev,
9775 .capsrc_nids = alc883_capsrc_nids_rev,
9776 .dig_out_nid = ALC883_DIGOUT_NID,
9777 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9778 .channel_mode = alc883_3ST_2ch_modes,
9779 .num_mux_defs =
9780 ARRAY_SIZE(alc888_2_capture_sources),
9781 .input_mux = alc888_acer_aspire_6530_sources,
9782 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009783 .setup = alc888_acer_aspire_6530g_setup,
9784 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009785 },
Hector Martin3b315d72009-06-02 10:54:19 +02009786 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +01009787 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +02009788 alc883_chmode_mixer },
9789 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +01009790 alc889_acer_aspire_8930g_verbs,
9791 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +02009792 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9793 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009794 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9795 .adc_nids = alc889_adc_nids,
9796 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009797 .dig_out_nid = ALC883_DIGOUT_NID,
9798 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9799 .channel_mode = alc883_3ST_6ch_modes,
9800 .need_dac_fix = 1,
9801 .const_channel_count = 6,
9802 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009803 ARRAY_SIZE(alc889_capture_sources),
9804 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009805 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009806 .setup = alc889_acer_aspire_8930g_setup,
9807 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +01009808#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05009809 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +01009810#endif
Hector Martin3b315d72009-06-02 10:54:19 +02009811 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009812 [ALC888_ACER_ASPIRE_7730G] = {
9813 .mixers = { alc883_3ST_6ch_mixer,
9814 alc883_chmode_mixer },
9815 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9816 alc888_acer_aspire_7730G_verbs },
9817 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9818 .dac_nids = alc883_dac_nids,
9819 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9820 .adc_nids = alc883_adc_nids_rev,
9821 .capsrc_nids = alc883_capsrc_nids_rev,
9822 .dig_out_nid = ALC883_DIGOUT_NID,
9823 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9824 .channel_mode = alc883_3ST_6ch_modes,
9825 .need_dac_fix = 1,
9826 .const_channel_count = 6,
9827 .input_mux = &alc883_capture_source,
9828 .unsol_event = alc_automute_amp_unsol_event,
9829 .setup = alc888_acer_aspire_6530g_setup,
9830 .init_hook = alc_automute_amp,
9831 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009832 [ALC883_MEDION] = {
9833 .mixers = { alc883_fivestack_mixer,
9834 alc883_chmode_mixer },
9835 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009836 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009837 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9838 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009839 .adc_nids = alc883_adc_nids_alt,
9840 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009841 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009842 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9843 .channel_mode = alc883_sixstack_modes,
9844 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009845 },
Kailang Yang272a5272007-05-14 11:00:38 +02009846 [ALC883_MEDION_MD2] = {
9847 .mixers = { alc883_medion_md2_mixer},
9848 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9849 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9850 .dac_nids = alc883_dac_nids,
9851 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009852 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9853 .channel_mode = alc883_3ST_2ch_modes,
9854 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009855 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009856 .setup = alc883_medion_md2_setup,
9857 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009858 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009859 [ALC883_MEDION_WIM2160] = {
9860 .mixers = { alc883_medion_wim2160_mixer },
9861 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
9862 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9863 .dac_nids = alc883_dac_nids,
9864 .dig_out_nid = ALC883_DIGOUT_NID,
9865 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9866 .adc_nids = alc883_adc_nids,
9867 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9868 .channel_mode = alc883_3ST_2ch_modes,
9869 .input_mux = &alc883_capture_source,
9870 .unsol_event = alc_automute_amp_unsol_event,
9871 .setup = alc883_medion_wim2160_setup,
9872 .init_hook = alc_automute_amp,
9873 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009874 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009875 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009876 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9877 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9878 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009879 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9880 .channel_mode = alc883_3ST_2ch_modes,
9881 .input_mux = &alc883_capture_source,
9882 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309883 [ALC883_CLEVO_M540R] = {
9884 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9885 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9886 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9887 .dac_nids = alc883_dac_nids,
9888 .dig_out_nid = ALC883_DIGOUT_NID,
9889 .dig_in_nid = ALC883_DIGIN_NID,
9890 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9891 .channel_mode = alc883_3ST_6ch_clevo_modes,
9892 .need_dac_fix = 1,
9893 .input_mux = &alc883_capture_source,
9894 /* This machine has the hardware HP auto-muting, thus
9895 * we need no software mute via unsol event
9896 */
9897 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009898 [ALC883_CLEVO_M720] = {
9899 .mixers = { alc883_clevo_m720_mixer },
9900 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009901 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9902 .dac_nids = alc883_dac_nids,
9903 .dig_out_nid = ALC883_DIGOUT_NID,
9904 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9905 .channel_mode = alc883_3ST_2ch_modes,
9906 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009907 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009908 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009909 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009910 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009911 [ALC883_LENOVO_101E_2ch] = {
9912 .mixers = { alc883_lenovo_101e_2ch_mixer},
9913 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9914 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9915 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009916 .adc_nids = alc883_adc_nids_alt,
9917 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009918 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009919 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9920 .channel_mode = alc883_3ST_2ch_modes,
9921 .input_mux = &alc883_lenovo_101e_capture_source,
9922 .unsol_event = alc883_lenovo_101e_unsol_event,
9923 .init_hook = alc883_lenovo_101e_all_automute,
9924 },
Kailang Yang272a5272007-05-14 11:00:38 +02009925 [ALC883_LENOVO_NB0763] = {
9926 .mixers = { alc883_lenovo_nb0763_mixer },
9927 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9928 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9929 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009930 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9931 .channel_mode = alc883_3ST_2ch_modes,
9932 .need_dac_fix = 1,
9933 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009934 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009935 .setup = alc883_medion_md2_setup,
9936 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009937 },
9938 [ALC888_LENOVO_MS7195_DIG] = {
9939 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9940 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9941 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9942 .dac_nids = alc883_dac_nids,
9943 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009944 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9945 .channel_mode = alc883_3ST_6ch_modes,
9946 .need_dac_fix = 1,
9947 .input_mux = &alc883_capture_source,
9948 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9949 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009950 },
9951 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009952 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009953 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9954 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9955 .dac_nids = alc883_dac_nids,
9956 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009957 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9958 .channel_mode = alc883_3ST_2ch_modes,
9959 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009960 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009961 .setup = alc883_haier_w66_setup,
9962 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009963 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009964 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009965 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009966 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009967 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9968 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009969 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9970 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009971 .need_dac_fix = 1,
9972 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009973 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009974 .setup = alc888_3st_hp_setup,
9975 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009976 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009977 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009978 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009979 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9980 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9981 .dac_nids = alc883_dac_nids,
9982 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009983 .dig_in_nid = ALC883_DIGIN_NID,
9984 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9985 .channel_mode = alc883_sixstack_modes,
9986 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009987 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009988 .setup = alc888_6st_dell_setup,
9989 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009990 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009991 [ALC883_MITAC] = {
9992 .mixers = { alc883_mitac_mixer },
9993 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9994 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9995 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009996 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9997 .channel_mode = alc883_3ST_2ch_modes,
9998 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009999 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010000 .setup = alc883_mitac_setup,
10001 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010002 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010003 [ALC883_FUJITSU_PI2515] = {
10004 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10005 .init_verbs = { alc883_init_verbs,
10006 alc883_2ch_fujitsu_pi2515_verbs},
10007 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10008 .dac_nids = alc883_dac_nids,
10009 .dig_out_nid = ALC883_DIGOUT_NID,
10010 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10011 .channel_mode = alc883_3ST_2ch_modes,
10012 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010013 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010014 .setup = alc883_2ch_fujitsu_pi2515_setup,
10015 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010016 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010017 [ALC888_FUJITSU_XA3530] = {
10018 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10019 .init_verbs = { alc883_init_verbs,
10020 alc888_fujitsu_xa3530_verbs },
10021 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10022 .dac_nids = alc883_dac_nids,
10023 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10024 .adc_nids = alc883_adc_nids_rev,
10025 .capsrc_nids = alc883_capsrc_nids_rev,
10026 .dig_out_nid = ALC883_DIGOUT_NID,
10027 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10028 .channel_mode = alc888_4ST_8ch_intel_modes,
10029 .num_mux_defs =
10030 ARRAY_SIZE(alc888_2_capture_sources),
10031 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010032 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010033 .setup = alc888_fujitsu_xa3530_setup,
10034 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010035 },
Kailang Yange2757d52008-08-26 13:17:46 +020010036 [ALC888_LENOVO_SKY] = {
10037 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10038 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10039 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10040 .dac_nids = alc883_dac_nids,
10041 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010042 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10043 .channel_mode = alc883_sixstack_modes,
10044 .need_dac_fix = 1,
10045 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010046 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010047 .setup = alc888_lenovo_sky_setup,
10048 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010049 },
10050 [ALC888_ASUS_M90V] = {
10051 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10052 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10053 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10054 .dac_nids = alc883_dac_nids,
10055 .dig_out_nid = ALC883_DIGOUT_NID,
10056 .dig_in_nid = ALC883_DIGIN_NID,
10057 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10058 .channel_mode = alc883_3ST_6ch_modes,
10059 .need_dac_fix = 1,
10060 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010061 .unsol_event = alc_sku_unsol_event,
10062 .setup = alc883_mode2_setup,
10063 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010064 },
10065 [ALC888_ASUS_EEE1601] = {
10066 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010067 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010068 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10069 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10070 .dac_nids = alc883_dac_nids,
10071 .dig_out_nid = ALC883_DIGOUT_NID,
10072 .dig_in_nid = ALC883_DIGIN_NID,
10073 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10074 .channel_mode = alc883_3ST_2ch_modes,
10075 .need_dac_fix = 1,
10076 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010077 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010078 .init_hook = alc883_eee1601_inithook,
10079 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010080 [ALC1200_ASUS_P5Q] = {
10081 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10082 .init_verbs = { alc883_init_verbs },
10083 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10084 .dac_nids = alc883_dac_nids,
10085 .dig_out_nid = ALC1200_DIGOUT_NID,
10086 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010087 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010088 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10089 .channel_mode = alc883_sixstack_modes,
10090 .input_mux = &alc883_capture_source,
10091 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010092 [ALC889A_MB31] = {
10093 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10094 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10095 alc880_gpio1_init_verbs },
10096 .adc_nids = alc883_adc_nids,
10097 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010098 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010099 .dac_nids = alc883_dac_nids,
10100 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10101 .channel_mode = alc889A_mb31_6ch_modes,
10102 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10103 .input_mux = &alc889A_mb31_capture_source,
10104 .dig_out_nid = ALC883_DIGOUT_NID,
10105 .unsol_event = alc889A_mb31_unsol_event,
10106 .init_hook = alc889A_mb31_automute,
10107 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010108 [ALC883_SONY_VAIO_TT] = {
10109 .mixers = { alc883_vaiott_mixer },
10110 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10111 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10112 .dac_nids = alc883_dac_nids,
10113 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10114 .channel_mode = alc883_3ST_2ch_modes,
10115 .input_mux = &alc883_capture_source,
10116 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010117 .setup = alc883_vaiott_setup,
10118 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010119 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010120};
10121
10122
10123/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010124 * Pin config fixes
10125 */
10126enum {
10127 PINFIX_ABIT_AW9D_MAX
10128};
10129
10130static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
10131 { 0x15, 0x01080104 }, /* side */
10132 { 0x16, 0x01011012 }, /* rear */
10133 { 0x17, 0x01016011 }, /* clfe */
10134 { }
10135};
10136
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010137static const struct alc_fixup alc882_fixups[] = {
10138 [PINFIX_ABIT_AW9D_MAX] = {
10139 .pins = alc882_abit_aw9d_pinfix
10140 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010141};
10142
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010143static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +020010144 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10145 {}
10146};
10147
10148/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010149 * BIOS auto configuration
10150 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010151static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10152 const struct auto_pin_cfg *cfg)
10153{
10154 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10155}
10156
Takashi Iwai4953550a2009-06-30 15:28:30 +020010157static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010158 hda_nid_t nid, int pin_type,
10159 int dac_idx)
10160{
10161 /* set as output */
10162 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010163 int idx;
10164
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010165 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaif9700d52010-04-05 23:25:13 +020010166 if (dac_idx >= spec->multiout.num_dacs)
10167 return;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010168 if (spec->multiout.dac_nids[dac_idx] == 0x25)
10169 idx = 4;
Takashi Iwaif9700d52010-04-05 23:25:13 +020010170 else
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010171 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010172 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
10173
10174}
10175
Takashi Iwai4953550a2009-06-30 15:28:30 +020010176static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010177{
10178 struct alc_spec *spec = codec->spec;
10179 int i;
10180
10181 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010182 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010183 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010184 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010185 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010186 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010187 }
10188}
10189
Takashi Iwai4953550a2009-06-30 15:28:30 +020010190static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010191{
10192 struct alc_spec *spec = codec->spec;
10193 hda_nid_t pin;
10194
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010195 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010196 if (pin) /* connect to front */
10197 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010198 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010199 pin = spec->autocfg.speaker_pins[0];
10200 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010201 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010202}
10203
Takashi Iwai4953550a2009-06-30 15:28:30 +020010204static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010205{
10206 struct alc_spec *spec = codec->spec;
10207 int i;
10208
10209 for (i = 0; i < AUTO_PIN_LAST; i++) {
10210 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010211 if (!nid)
10212 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +020010213 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010214 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10215 snd_hda_codec_write(codec, nid, 0,
10216 AC_VERB_SET_AMP_GAIN_MUTE,
10217 AMP_OUT_MUTE);
10218 }
10219}
10220
10221static void alc882_auto_init_input_src(struct hda_codec *codec)
10222{
10223 struct alc_spec *spec = codec->spec;
10224 int c;
10225
10226 for (c = 0; c < spec->num_adc_nids; c++) {
10227 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10228 hda_nid_t nid = spec->capsrc_nids[c];
10229 unsigned int mux_idx;
10230 const struct hda_input_mux *imux;
10231 int conns, mute, idx, item;
10232
10233 conns = snd_hda_get_connections(codec, nid, conn_list,
10234 ARRAY_SIZE(conn_list));
10235 if (conns < 0)
10236 continue;
10237 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10238 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010239 if (!imux->num_items && mux_idx > 0)
10240 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010241 for (idx = 0; idx < conns; idx++) {
10242 /* if the current connection is the selected one,
10243 * unmute it as default - otherwise mute it
10244 */
10245 mute = AMP_IN_MUTE(idx);
10246 for (item = 0; item < imux->num_items; item++) {
10247 if (imux->items[item].index == idx) {
10248 if (spec->cur_mux[c] == item)
10249 mute = AMP_IN_UNMUTE(idx);
10250 break;
10251 }
10252 }
10253 /* check if we have a selector or mixer
10254 * we could check for the widget type instead, but
10255 * just check for Amp-In presence (in case of mixer
10256 * without amp-in there is something wrong, this
10257 * function shouldn't be used or capsrc nid is wrong)
10258 */
10259 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010260 snd_hda_codec_write(codec, nid, 0,
10261 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010262 mute);
10263 else if (mute != AMP_IN_MUTE(idx))
10264 snd_hda_codec_write(codec, nid, 0,
10265 AC_VERB_SET_CONNECT_SEL,
10266 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010267 }
10268 }
10269}
10270
Takashi Iwai4953550a2009-06-30 15:28:30 +020010271/* add mic boosts if needed */
10272static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010273{
10274 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010275 int err;
10276 hda_nid_t nid;
10277
10278 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
10279 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10280 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10281 "Mic Boost",
10282 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10283 if (err < 0)
10284 return err;
10285 }
10286 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
10287 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10288 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10289 "Front Mic Boost",
10290 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10291 if (err < 0)
10292 return err;
10293 }
10294 return 0;
10295}
10296
10297/* almost identical with ALC880 parser... */
10298static int alc882_parse_auto_config(struct hda_codec *codec)
10299{
10300 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010301 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
10302 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010303
Takashi Iwai05f5f472009-08-25 13:10:18 +020010304 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10305 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010306 if (err < 0)
10307 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010308 if (!spec->autocfg.line_outs)
10309 return 0; /* can't find valid BIOS pin config */
10310
10311 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10312 if (err < 0)
10313 return err;
10314 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10315 if (err < 0)
10316 return err;
10317 err = alc880_auto_create_extra_out(spec,
10318 spec->autocfg.speaker_pins[0],
10319 "Speaker");
10320 if (err < 0)
10321 return err;
10322 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10323 "Headphone");
10324 if (err < 0)
10325 return err;
10326 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10327 if (err < 0)
10328 return err;
10329
10330 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10331
10332 /* check multiple SPDIF-out (for recent codecs) */
10333 for (i = 0; i < spec->autocfg.dig_outs; i++) {
10334 hda_nid_t dig_nid;
10335 err = snd_hda_get_connections(codec,
10336 spec->autocfg.dig_out_pins[i],
10337 &dig_nid, 1);
10338 if (err < 0)
10339 continue;
10340 if (!i)
10341 spec->multiout.dig_out_nid = dig_nid;
10342 else {
10343 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010344 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +020010345 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010346 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010347 }
10348 }
10349 if (spec->autocfg.dig_in_pin)
10350 spec->dig_in_nid = ALC880_DIGIN_NID;
10351
10352 if (spec->kctls.list)
10353 add_mixer(spec, spec->kctls.list);
10354
10355 add_verb(spec, alc883_auto_init_verbs);
10356 /* if ADC 0x07 is available, initialize it, too */
10357 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10358 add_verb(spec, alc882_adc1_init_verbs);
10359
10360 spec->num_mux_defs = 1;
10361 spec->input_mux = &spec->private_imux[0];
10362
Kailang Yang6227cdc2010-02-25 08:36:52 +010010363 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010364
10365 err = alc_auto_add_mic_boost(codec);
10366 if (err < 0)
10367 return err;
10368
Takashi Iwai776e1842007-08-29 15:07:11 +020010369 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010370}
10371
10372/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010373static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010374{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010375 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010376 alc882_auto_init_multi_out(codec);
10377 alc882_auto_init_hp_out(codec);
10378 alc882_auto_init_analog_input(codec);
10379 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010380 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010381 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010382}
10383
Takashi Iwai4953550a2009-06-30 15:28:30 +020010384static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010385{
10386 struct alc_spec *spec;
10387 int err, board_config;
10388
10389 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10390 if (spec == NULL)
10391 return -ENOMEM;
10392
10393 codec->spec = spec;
10394
Takashi Iwai4953550a2009-06-30 15:28:30 +020010395 switch (codec->vendor_id) {
10396 case 0x10ec0882:
10397 case 0x10ec0885:
10398 break;
10399 default:
10400 /* ALC883 and variants */
10401 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10402 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010403 }
10404
Takashi Iwai4953550a2009-06-30 15:28:30 +020010405 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10406 alc882_models,
10407 alc882_cfg_tbl);
10408
10409 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10410 board_config = snd_hda_check_board_codec_sid_config(codec,
10411 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10412
10413 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010414 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010415 codec->chip_name);
10416 board_config = ALC882_AUTO;
10417 }
10418
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010419 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010420
10421 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010422 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010423 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010424 if (err < 0) {
10425 alc_free(codec);
10426 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010427 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010428 printk(KERN_INFO
10429 "hda_codec: Cannot set up configuration "
10430 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010431 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010432 }
10433 }
10434
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010435 err = snd_hda_attach_beep_device(codec, 0x1);
10436 if (err < 0) {
10437 alc_free(codec);
10438 return err;
10439 }
10440
Takashi Iwai4953550a2009-06-30 15:28:30 +020010441 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010442 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010443
Takashi Iwai4953550a2009-06-30 15:28:30 +020010444 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10445 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10446 /* FIXME: setup DAC5 */
10447 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10448 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10449
10450 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10451 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10452
10453 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010454 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010455
10456 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010457 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010458 spec->num_adc_nids = 0;
10459 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010460 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010461 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010462 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010463 hda_nid_t nid = alc882_adc_nids[i];
10464 unsigned int wcap = get_wcaps(codec, nid);
10465 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010466 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010467 if (wcap != AC_WID_AUD_IN)
10468 continue;
10469 spec->private_adc_nids[spec->num_adc_nids] = nid;
10470 err = snd_hda_get_connections(codec, nid, &cap, 1);
10471 if (err < 0)
10472 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010473 err = snd_hda_get_connections(codec, cap, items,
10474 ARRAY_SIZE(items));
10475 if (err < 0)
10476 continue;
10477 for (j = 0; j < imux->num_items; j++)
10478 if (imux->items[j].index >= err)
10479 break;
10480 if (j < imux->num_items)
10481 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010482 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10483 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010484 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010485 spec->adc_nids = spec->private_adc_nids;
10486 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010487 }
10488
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010489 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010010490 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010491
Takashi Iwai2134ea42008-01-10 16:53:55 +010010492 spec->vmaster_nid = 0x0c;
10493
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010494 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010495 if (board_config == ALC882_AUTO)
10496 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010497#ifdef CONFIG_SND_HDA_POWER_SAVE
10498 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010499 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010500#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010501
10502 return 0;
10503}
10504
Takashi Iwai4953550a2009-06-30 15:28:30 +020010505
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010506/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010507 * ALC262 support
10508 */
10509
10510#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10511#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10512
10513#define alc262_dac_nids alc260_dac_nids
10514#define alc262_adc_nids alc882_adc_nids
10515#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010516#define alc262_capsrc_nids alc882_capsrc_nids
10517#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010518
10519#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010520#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010521
Kailang Yang4e555fe2008-08-26 13:05:55 +020010522static hda_nid_t alc262_dmic_adc_nids[1] = {
10523 /* ADC0 */
10524 0x09
10525};
10526
10527static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10528
Kailang Yangdf694da2005-12-05 19:42:22 +010010529static struct snd_kcontrol_new alc262_base_mixer[] = {
10530 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10531 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10532 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10533 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10534 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10535 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10536 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10537 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010538 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010539 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10540 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010541 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010542 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10543 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10544 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10545 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010546 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010547};
10548
Takashi Iwaice875f02008-01-28 18:17:43 +010010549/* update HP, line and mono-out pins according to the master switch */
10550static void alc262_hp_master_update(struct hda_codec *codec)
10551{
10552 struct alc_spec *spec = codec->spec;
10553 int val = spec->master_sw;
10554
10555 /* HP & line-out */
10556 snd_hda_codec_write_cache(codec, 0x1b, 0,
10557 AC_VERB_SET_PIN_WIDGET_CONTROL,
10558 val ? PIN_HP : 0);
10559 snd_hda_codec_write_cache(codec, 0x15, 0,
10560 AC_VERB_SET_PIN_WIDGET_CONTROL,
10561 val ? PIN_HP : 0);
10562 /* mono (speaker) depending on the HP jack sense */
10563 val = val && !spec->jack_present;
10564 snd_hda_codec_write_cache(codec, 0x16, 0,
10565 AC_VERB_SET_PIN_WIDGET_CONTROL,
10566 val ? PIN_OUT : 0);
10567}
10568
10569static void alc262_hp_bpc_automute(struct hda_codec *codec)
10570{
10571 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010572
10573 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010574 alc262_hp_master_update(codec);
10575}
10576
10577static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10578{
10579 if ((res >> 26) != ALC880_HP_EVENT)
10580 return;
10581 alc262_hp_bpc_automute(codec);
10582}
10583
10584static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10585{
10586 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010587
10588 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010589 alc262_hp_master_update(codec);
10590}
10591
10592static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10593 unsigned int res)
10594{
10595 if ((res >> 26) != ALC880_HP_EVENT)
10596 return;
10597 alc262_hp_wildwest_automute(codec);
10598}
10599
Takashi Iwaib72519b2009-05-08 14:31:55 +020010600#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010601
10602static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10603 struct snd_ctl_elem_value *ucontrol)
10604{
10605 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10606 struct alc_spec *spec = codec->spec;
10607 int val = !!*ucontrol->value.integer.value;
10608
10609 if (val == spec->master_sw)
10610 return 0;
10611 spec->master_sw = val;
10612 alc262_hp_master_update(codec);
10613 return 1;
10614}
10615
Takashi Iwaib72519b2009-05-08 14:31:55 +020010616#define ALC262_HP_MASTER_SWITCH \
10617 { \
10618 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10619 .name = "Master Playback Switch", \
10620 .info = snd_ctl_boolean_mono_info, \
10621 .get = alc262_hp_master_sw_get, \
10622 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010623 }, \
10624 { \
10625 .iface = NID_MAPPING, \
10626 .name = "Master Playback Switch", \
10627 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020010628 }
10629
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010630
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010631static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010632 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010633 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10634 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10635 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010636 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10637 HDA_OUTPUT),
10638 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10639 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010640 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10641 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010642 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010643 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10644 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010645 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010646 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10647 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10648 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10649 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010650 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10651 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10652 { } /* end */
10653};
10654
Kailang Yangcd7509a2007-01-26 18:33:17 +010010655static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010656 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010657 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10658 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10659 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10660 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010661 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10662 HDA_OUTPUT),
10663 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10664 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010665 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10666 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010667 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010668 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10669 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10670 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10671 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010672 { } /* end */
10673};
10674
10675static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10676 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10677 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010678 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010679 { } /* end */
10680};
10681
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010682/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010683static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010684{
10685 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010686
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010687 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010010688 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010689}
10690
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010691static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010692 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10693 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010694 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10695 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10696 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10697 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10698 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10699 { } /* end */
10700};
10701
10702static struct hda_verb alc262_hp_t5735_verbs[] = {
10703 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10704 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10705
10706 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10707 { }
10708};
10709
Kailang Yang8c427222008-01-10 13:03:59 +010010710static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010711 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10712 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010713 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10714 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010715 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10716 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10717 { } /* end */
10718};
10719
10720static struct hda_verb alc262_hp_rp5700_verbs[] = {
10721 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10722 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10723 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10724 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10725 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10726 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10727 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10728 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10729 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10730 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10731 {}
10732};
10733
10734static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10735 .num_items = 1,
10736 .items = {
10737 { "Line", 0x1 },
10738 },
10739};
10740
Takashi Iwai42171c12009-05-08 14:11:43 +020010741/* bind hp and internal speaker mute (with plug check) as master switch */
10742static void alc262_hippo_master_update(struct hda_codec *codec)
10743{
10744 struct alc_spec *spec = codec->spec;
10745 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10746 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10747 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10748 unsigned int mute;
10749
10750 /* HP */
10751 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10752 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10753 HDA_AMP_MUTE, mute);
10754 /* mute internal speaker per jack sense */
10755 if (spec->jack_present)
10756 mute = HDA_AMP_MUTE;
10757 if (line_nid)
10758 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10759 HDA_AMP_MUTE, mute);
10760 if (speaker_nid && speaker_nid != line_nid)
10761 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10762 HDA_AMP_MUTE, mute);
10763}
10764
10765#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10766
10767static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10768 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010769{
10770 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010771 struct alc_spec *spec = codec->spec;
10772 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010773
Takashi Iwai42171c12009-05-08 14:11:43 +020010774 if (val == spec->master_sw)
10775 return 0;
10776 spec->master_sw = val;
10777 alc262_hippo_master_update(codec);
10778 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010779}
Takashi Iwai5b319542007-07-26 11:49:22 +020010780
Takashi Iwai42171c12009-05-08 14:11:43 +020010781#define ALC262_HIPPO_MASTER_SWITCH \
10782 { \
10783 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10784 .name = "Master Playback Switch", \
10785 .info = snd_ctl_boolean_mono_info, \
10786 .get = alc262_hippo_master_sw_get, \
10787 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010788 }, \
10789 { \
10790 .iface = NID_MAPPING, \
10791 .name = "Master Playback Switch", \
10792 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
10793 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020010794 }
10795
10796static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10797 ALC262_HIPPO_MASTER_SWITCH,
10798 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10799 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10800 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10801 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10802 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10803 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10805 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10806 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10807 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10808 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10809 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10810 { } /* end */
10811};
10812
10813static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10814 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10815 ALC262_HIPPO_MASTER_SWITCH,
10816 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10817 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10818 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10819 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
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("Mic Boost", 0x18, 0, HDA_INPUT),
10823 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10824 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10825 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10826 { } /* end */
10827};
10828
10829/* mute/unmute internal speaker according to the hp jack and mute state */
10830static void alc262_hippo_automute(struct hda_codec *codec)
10831{
10832 struct alc_spec *spec = codec->spec;
10833 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010834
Wu Fengguang864f92b2009-11-18 12:38:02 +080010835 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010836 alc262_hippo_master_update(codec);
10837}
10838
10839static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10840{
10841 if ((res >> 26) != ALC880_HP_EVENT)
10842 return;
10843 alc262_hippo_automute(codec);
10844}
10845
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010846static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010847{
10848 struct alc_spec *spec = codec->spec;
10849
10850 spec->autocfg.hp_pins[0] = 0x15;
10851 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010852}
10853
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010854static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010855{
10856 struct alc_spec *spec = codec->spec;
10857
10858 spec->autocfg.hp_pins[0] = 0x1b;
10859 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010860}
10861
10862
Kailang Yang272a5272007-05-14 11:00:38 +020010863static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010864 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010865 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010866 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10867 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10868 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10869 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10870 { } /* end */
10871};
10872
Kailang Yang83c34212007-07-05 11:43:05 +020010873static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010874 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10875 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010876 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10877 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10878 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10879 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10880 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10881 { } /* end */
10882};
Kailang Yang272a5272007-05-14 11:00:38 +020010883
Tony Vroonba340e82009-02-02 19:01:30 +000010884static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10885 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10886 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10887 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10888 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10889 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10890 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10893 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10894 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10895 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10896 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10897 { } /* end */
10898};
10899
10900static struct hda_verb alc262_tyan_verbs[] = {
10901 /* Headphone automute */
10902 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10903 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10904 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10905
10906 /* P11 AUX_IN, white 4-pin connector */
10907 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10908 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10909 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10910 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10911
10912 {}
10913};
10914
10915/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010916static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010917{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010918 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010919
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010920 spec->autocfg.hp_pins[0] = 0x1b;
10921 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010922}
10923
Tony Vroonba340e82009-02-02 19:01:30 +000010924
Kailang Yangdf694da2005-12-05 19:42:22 +010010925#define alc262_capture_mixer alc882_capture_mixer
10926#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10927
10928/*
10929 * generic initialization of ADC, input mixers and output mixers
10930 */
10931static struct hda_verb alc262_init_verbs[] = {
10932 /*
10933 * Unmute ADC0-2 and set the default input to mic-in
10934 */
10935 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10937 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10938 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10939 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10940 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10941
Takashi Iwaicb53c622007-08-10 17:21:45 +020010942 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010943 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010944 * Note: PASD motherboards uses the Line In 2 as the input for
10945 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010946 */
10947 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010948 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10949 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10950 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10951 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10952 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010953
10954 /*
10955 * Set up output mixers (0x0c - 0x0e)
10956 */
10957 /* set vol=0 to output mixers */
10958 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10959 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10960 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10961 /* set up input amps for analog loopback */
10962 /* Amp Indices: DAC = 0, mixer = 1 */
10963 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10964 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10965 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10966 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10967 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10968 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10969
10970 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10971 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10972 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10973 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10974 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10975 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10976
10977 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10978 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10979 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10980 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10981 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010982
Kailang Yangdf694da2005-12-05 19:42:22 +010010983 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10984 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010985
Kailang Yangdf694da2005-12-05 19:42:22 +010010986 /* FIXME: use matrix-type input source selection */
10987 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10988 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10989 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10990 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10991 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10992 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10993 /* Input mixer2 */
10994 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10995 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10996 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10997 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10998 /* Input mixer3 */
10999 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11000 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11001 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011002 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011003
11004 { }
11005};
11006
Kailang Yang4e555fe2008-08-26 13:05:55 +020011007static struct hda_verb alc262_eapd_verbs[] = {
11008 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11009 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11010 { }
11011};
11012
Kailang Yangccc656c2006-10-17 12:32:26 +020011013static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11014 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11015 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11016 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11017
11018 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11019 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11020 {}
11021};
11022
Kailang Yang272a5272007-05-14 11:00:38 +020011023static struct hda_verb alc262_sony_unsol_verbs[] = {
11024 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11025 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11026 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11027
11028 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11029 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011030 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011031};
11032
Kailang Yang4e555fe2008-08-26 13:05:55 +020011033static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11034 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11035 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11036 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11037 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11038 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011039 { } /* end */
11040};
11041
11042static struct hda_verb alc262_toshiba_s06_verbs[] = {
11043 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11044 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11045 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11046 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11047 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11048 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11049 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11050 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11051 {}
11052};
11053
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011054static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011055{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011056 struct alc_spec *spec = codec->spec;
11057
11058 spec->autocfg.hp_pins[0] = 0x15;
11059 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011060 spec->ext_mic.pin = 0x18;
11061 spec->ext_mic.mux_idx = 0;
11062 spec->int_mic.pin = 0x12;
11063 spec->int_mic.mux_idx = 9;
11064 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011065}
11066
Takashi Iwai834be882006-03-01 14:16:17 +010011067/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011068 * nec model
11069 * 0x15 = headphone
11070 * 0x16 = internal speaker
11071 * 0x18 = external mic
11072 */
11073
11074static struct snd_kcontrol_new alc262_nec_mixer[] = {
11075 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11076 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11077
11078 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11079 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11080 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11081
11082 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11083 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11084 { } /* end */
11085};
11086
11087static struct hda_verb alc262_nec_verbs[] = {
11088 /* Unmute Speaker */
11089 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11090
11091 /* Headphone */
11092 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11093 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11094
11095 /* External mic to headphone */
11096 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11097 /* External mic to speaker */
11098 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11099 {}
11100};
11101
11102/*
Takashi Iwai834be882006-03-01 14:16:17 +010011103 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011104 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11105 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011106 */
11107
11108#define ALC_HP_EVENT 0x37
11109
11110static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11111 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11112 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011113 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11114 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011115 {}
11116};
11117
Jiang zhe0e31daf2008-03-20 12:12:39 +010011118static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11119 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11120 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11121 {}
11122};
11123
Daniel T Chene2595322009-12-19 18:19:02 -050011124static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11125 /* Front Mic pin: input vref at 50% */
11126 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11127 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11128 {}
11129};
11130
Takashi Iwai834be882006-03-01 14:16:17 +010011131static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011132 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011133 .items = {
11134 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011135 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011136 { "CD", 0x4 },
11137 },
11138};
11139
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011140static struct hda_input_mux alc262_HP_capture_source = {
11141 .num_items = 5,
11142 .items = {
11143 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011144 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011145 { "Line", 0x2 },
11146 { "CD", 0x4 },
11147 { "AUX IN", 0x6 },
11148 },
11149};
11150
zhejiangaccbe492007-08-31 12:36:05 +020011151static struct hda_input_mux alc262_HP_D7000_capture_source = {
11152 .num_items = 4,
11153 .items = {
11154 { "Mic", 0x0 },
11155 { "Front Mic", 0x2 },
11156 { "Line", 0x1 },
11157 { "CD", 0x4 },
11158 },
11159};
11160
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011161/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011162static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11163{
11164 struct alc_spec *spec = codec->spec;
11165 unsigned int mute;
11166
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011167 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011168 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11169 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011170 spec->sense_updated = 1;
11171 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011172 /* unmute internal speaker only if both HPs are unplugged and
11173 * master switch is on
11174 */
11175 if (spec->jack_present)
11176 mute = HDA_AMP_MUTE;
11177 else
Takashi Iwai834be882006-03-01 14:16:17 +010011178 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011179 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11180 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011181}
11182
11183/* unsolicited event for HP jack sensing */
11184static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11185 unsigned int res)
11186{
11187 if ((res >> 26) != ALC_HP_EVENT)
11188 return;
11189 alc262_fujitsu_automute(codec, 1);
11190}
11191
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011192static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11193{
11194 alc262_fujitsu_automute(codec, 1);
11195}
11196
Takashi Iwai834be882006-03-01 14:16:17 +010011197/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011198static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11199 .ops = &snd_hda_bind_vol,
11200 .values = {
11201 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11202 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11203 0
11204 },
11205};
Takashi Iwai834be882006-03-01 14:16:17 +010011206
Jiang zhe0e31daf2008-03-20 12:12:39 +010011207/* mute/unmute internal speaker according to the hp jack and mute state */
11208static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11209{
11210 struct alc_spec *spec = codec->spec;
11211 unsigned int mute;
11212
11213 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011214 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011215 spec->sense_updated = 1;
11216 }
11217 if (spec->jack_present) {
11218 /* mute internal speaker */
11219 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11220 HDA_AMP_MUTE, HDA_AMP_MUTE);
11221 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11222 HDA_AMP_MUTE, HDA_AMP_MUTE);
11223 } else {
11224 /* unmute internal speaker if necessary */
11225 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11226 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11227 HDA_AMP_MUTE, mute);
11228 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11229 HDA_AMP_MUTE, mute);
11230 }
11231}
11232
11233/* unsolicited event for HP jack sensing */
11234static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11235 unsigned int res)
11236{
11237 if ((res >> 26) != ALC_HP_EVENT)
11238 return;
11239 alc262_lenovo_3000_automute(codec, 1);
11240}
11241
Takashi Iwai8de56b72009-07-24 16:51:47 +020011242static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11243 int dir, int idx, long *valp)
11244{
11245 int i, change = 0;
11246
11247 for (i = 0; i < 2; i++, valp++)
11248 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11249 HDA_AMP_MUTE,
11250 *valp ? 0 : HDA_AMP_MUTE);
11251 return change;
11252}
11253
Takashi Iwai834be882006-03-01 14:16:17 +010011254/* bind hp and internal speaker mute (with plug check) */
11255static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11256 struct snd_ctl_elem_value *ucontrol)
11257{
11258 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11259 long *valp = ucontrol->value.integer.value;
11260 int change;
11261
Takashi Iwai8de56b72009-07-24 16:51:47 +020011262 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11263 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011264 if (change)
11265 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011266 return change;
11267}
11268
11269static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011270 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011271 {
11272 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11273 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011274 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011275 .info = snd_hda_mixer_amp_switch_info,
11276 .get = snd_hda_mixer_amp_switch_get,
11277 .put = alc262_fujitsu_master_sw_put,
11278 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11279 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011280 {
11281 .iface = NID_MAPPING,
11282 .name = "Master Playback Switch",
11283 .private_value = 0x1b,
11284 },
Takashi Iwai834be882006-03-01 14:16:17 +010011285 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11286 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11287 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11288 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11289 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011290 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11291 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11292 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011293 { } /* end */
11294};
11295
Jiang zhe0e31daf2008-03-20 12:12:39 +010011296/* bind hp and internal speaker mute (with plug check) */
11297static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11298 struct snd_ctl_elem_value *ucontrol)
11299{
11300 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11301 long *valp = ucontrol->value.integer.value;
11302 int change;
11303
Takashi Iwai8de56b72009-07-24 16:51:47 +020011304 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011305 if (change)
11306 alc262_lenovo_3000_automute(codec, 0);
11307 return change;
11308}
11309
11310static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11311 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11312 {
11313 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11314 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011315 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011316 .info = snd_hda_mixer_amp_switch_info,
11317 .get = snd_hda_mixer_amp_switch_get,
11318 .put = alc262_lenovo_3000_master_sw_put,
11319 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11320 },
11321 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11322 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11323 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11324 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11325 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11326 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11327 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11328 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11329 { } /* end */
11330};
11331
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011332static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11333 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011334 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11336 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11337 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11338 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11339 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11340 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11341 { } /* end */
11342};
11343
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011344/* additional init verbs for Benq laptops */
11345static struct hda_verb alc262_EAPD_verbs[] = {
11346 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11347 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11348 {}
11349};
11350
Kailang Yang83c34212007-07-05 11:43:05 +020011351static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11352 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11353 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11354
11355 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11356 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11357 {}
11358};
11359
Tobin Davisf651b502007-10-26 12:40:47 +020011360/* Samsung Q1 Ultra Vista model setup */
11361static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011362 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11363 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011364 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11365 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11366 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011367 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011368 { } /* end */
11369};
11370
11371static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011372 /* output mixer */
11373 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11374 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11375 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11376 /* speaker */
11377 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11378 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11379 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11380 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11381 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011382 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011383 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11384 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11385 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11386 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11387 /* internal mic */
11388 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11389 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11390 /* ADC, choose mic */
11391 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11392 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11393 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11394 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11395 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11396 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11397 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11398 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11399 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11400 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011401 {}
11402};
11403
Tobin Davisf651b502007-10-26 12:40:47 +020011404/* mute/unmute internal speaker according to the hp jack and mute state */
11405static void alc262_ultra_automute(struct hda_codec *codec)
11406{
11407 struct alc_spec *spec = codec->spec;
11408 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011409
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011410 mute = 0;
11411 /* auto-mute only when HP is used as HP */
11412 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011413 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011414 if (spec->jack_present)
11415 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011416 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011417 /* mute/unmute internal speaker */
11418 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11419 HDA_AMP_MUTE, mute);
11420 /* mute/unmute HP */
11421 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11422 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011423}
11424
11425/* unsolicited event for HP jack sensing */
11426static void alc262_ultra_unsol_event(struct hda_codec *codec,
11427 unsigned int res)
11428{
11429 if ((res >> 26) != ALC880_HP_EVENT)
11430 return;
11431 alc262_ultra_automute(codec);
11432}
11433
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011434static struct hda_input_mux alc262_ultra_capture_source = {
11435 .num_items = 2,
11436 .items = {
11437 { "Mic", 0x1 },
11438 { "Headphone", 0x7 },
11439 },
11440};
11441
11442static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11443 struct snd_ctl_elem_value *ucontrol)
11444{
11445 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11446 struct alc_spec *spec = codec->spec;
11447 int ret;
11448
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011449 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011450 if (!ret)
11451 return 0;
11452 /* reprogram the HP pin as mic or HP according to the input source */
11453 snd_hda_codec_write_cache(codec, 0x15, 0,
11454 AC_VERB_SET_PIN_WIDGET_CONTROL,
11455 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11456 alc262_ultra_automute(codec); /* mute/unmute HP */
11457 return ret;
11458}
11459
11460static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11461 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11462 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11463 {
11464 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11465 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011466 .info = alc_mux_enum_info,
11467 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011468 .put = alc262_ultra_mux_enum_put,
11469 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011470 {
11471 .iface = NID_MAPPING,
11472 .name = "Capture Source",
11473 .private_value = 0x15,
11474 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011475 { } /* end */
11476};
11477
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011478/* We use two mixers depending on the output pin; 0x16 is a mono output
11479 * and thus it's bound with a different mixer.
11480 * This function returns which mixer amp should be used.
11481 */
11482static int alc262_check_volbit(hda_nid_t nid)
11483{
11484 if (!nid)
11485 return 0;
11486 else if (nid == 0x16)
11487 return 2;
11488 else
11489 return 1;
11490}
11491
11492static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11493 const char *pfx, int *vbits)
11494{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011495 unsigned long val;
11496 int vbit;
11497
11498 vbit = alc262_check_volbit(nid);
11499 if (!vbit)
11500 return 0;
11501 if (*vbits & vbit) /* a volume control for this mixer already there */
11502 return 0;
11503 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011504 if (vbit == 2)
11505 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11506 else
11507 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011508 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011509}
11510
11511static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11512 const char *pfx)
11513{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011514 unsigned long val;
11515
11516 if (!nid)
11517 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011518 if (nid == 0x16)
11519 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11520 else
11521 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011522 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011523}
11524
Kailang Yangdf694da2005-12-05 19:42:22 +010011525/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011526static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11527 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011528{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011529 const char *pfx;
11530 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011531 int err;
11532
11533 spec->multiout.num_dacs = 1; /* only use one dac */
11534 spec->multiout.dac_nids = spec->private_dac_nids;
11535 spec->multiout.dac_nids[0] = 2;
11536
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011537 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11538 pfx = "Master";
11539 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11540 pfx = "Speaker";
11541 else
11542 pfx = "Front";
11543 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11544 if (err < 0)
11545 return err;
11546 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11547 if (err < 0)
11548 return err;
11549 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11550 if (err < 0)
11551 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011552
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011553 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11554 alc262_check_volbit(cfg->speaker_pins[0]) |
11555 alc262_check_volbit(cfg->hp_pins[0]);
11556 if (vbits == 1 || vbits == 2)
11557 pfx = "Master"; /* only one mixer is used */
11558 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11559 pfx = "Speaker";
11560 else
11561 pfx = "Front";
11562 vbits = 0;
11563 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11564 if (err < 0)
11565 return err;
11566 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11567 &vbits);
11568 if (err < 0)
11569 return err;
11570 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11571 &vbits);
11572 if (err < 0)
11573 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011574 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011575}
11576
Takashi Iwai05f5f472009-08-25 13:10:18 +020011577#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011578 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011579
11580/*
11581 * generic initialization of ADC, input mixers and output mixers
11582 */
11583static struct hda_verb alc262_volume_init_verbs[] = {
11584 /*
11585 * Unmute ADC0-2 and set the default input to mic-in
11586 */
11587 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11588 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11589 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11590 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11591 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11592 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11593
Takashi Iwaicb53c622007-08-10 17:21:45 +020011594 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011595 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011596 * Note: PASD motherboards uses the Line In 2 as the input for
11597 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011598 */
11599 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011600 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11601 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11602 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11603 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11604 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011605
11606 /*
11607 * Set up output mixers (0x0c - 0x0f)
11608 */
11609 /* set vol=0 to output mixers */
11610 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11611 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11612 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011613
Kailang Yangdf694da2005-12-05 19:42:22 +010011614 /* set up input amps for analog loopback */
11615 /* Amp Indices: DAC = 0, mixer = 1 */
11616 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11617 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11618 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11619 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11620 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11621 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11622
11623 /* FIXME: use matrix-type input source selection */
11624 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11625 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11626 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11627 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11628 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11629 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11630 /* Input mixer2 */
11631 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11632 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11633 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11634 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11635 /* Input mixer3 */
11636 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11637 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11638 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11639 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11640
11641 { }
11642};
11643
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011644static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11645 /*
11646 * Unmute ADC0-2 and set the default input to mic-in
11647 */
11648 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11649 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11650 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11651 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11652 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11653 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11654
Takashi Iwaicb53c622007-08-10 17:21:45 +020011655 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011656 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011657 * Note: PASD motherboards uses the Line In 2 as the input for
11658 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011659 */
11660 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011661 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11662 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11663 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11664 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11665 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11666 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11667 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011668
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011669 /*
11670 * Set up output mixers (0x0c - 0x0e)
11671 */
11672 /* set vol=0 to output mixers */
11673 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11674 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11675 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11676
11677 /* set up input amps for analog loopback */
11678 /* Amp Indices: DAC = 0, mixer = 1 */
11679 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11680 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11681 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11682 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11683 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11684 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11685
Takashi Iwaice875f02008-01-28 18:17:43 +010011686 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011687 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11688 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11689
11690 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11691 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11692
11693 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11694 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11695
11696 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11697 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11698 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11699 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11700 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11701
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011702 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011703 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11704 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011705 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011706 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11707 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11708
11709
11710 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011711 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11712 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011713 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011714 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11715 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11716 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11717 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11718 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11719 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11720 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11721 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011722 /* Input mixer2 */
11723 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011724 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11725 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11726 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11727 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11728 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11729 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11730 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11731 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011732 /* Input mixer3 */
11733 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011734 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11735 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11736 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11737 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11738 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11739 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11740 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11741 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011742
Takashi Iwaice875f02008-01-28 18:17:43 +010011743 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11744
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011745 { }
11746};
11747
Kailang Yangcd7509a2007-01-26 18:33:17 +010011748static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11749 /*
11750 * Unmute ADC0-2 and set the default input to mic-in
11751 */
11752 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11753 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11754 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11755 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11756 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11757 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11758
Takashi Iwaicb53c622007-08-10 17:21:45 +020011759 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011760 * mixer widget
11761 * Note: PASD motherboards uses the Line In 2 as the input for front
11762 * panel mic (mic 2)
11763 */
11764 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011765 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11766 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11767 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11768 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11769 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11770 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11771 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11772 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011773 /*
11774 * Set up output mixers (0x0c - 0x0e)
11775 */
11776 /* set vol=0 to output mixers */
11777 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11778 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11779 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11780
11781 /* set up input amps for analog loopback */
11782 /* Amp Indices: DAC = 0, mixer = 1 */
11783 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11784 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11785 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11786 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11787 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11788 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11789
11790
11791 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11792 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11793 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11794 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11795 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11796 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11797 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11798
11799 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11801
11802 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11803 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11804
11805 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11806 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11807 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11808 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11809 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11810 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11811
11812 /* FIXME: use matrix-type input source selection */
11813 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11814 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11815 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11816 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11817 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11818 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11819 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11820 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11821 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11822 /* Input mixer2 */
11823 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11824 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11825 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11826 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11827 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11828 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11829 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11830 /* Input mixer3 */
11831 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11832 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11833 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11834 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11835 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11836 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11837 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11838
Takashi Iwaice875f02008-01-28 18:17:43 +010011839 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11840
Kailang Yangcd7509a2007-01-26 18:33:17 +010011841 { }
11842};
11843
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011844static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11845
11846 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11847 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11848 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11849
11850 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11851 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11852 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11853 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11854
11855 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11856 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11857 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11858 {}
11859};
11860
11861
Takashi Iwaicb53c622007-08-10 17:21:45 +020011862#ifdef CONFIG_SND_HDA_POWER_SAVE
11863#define alc262_loopbacks alc880_loopbacks
11864#endif
11865
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011866/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011867#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11868#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11869#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11870#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11871
11872/*
11873 * BIOS auto configuration
11874 */
11875static int alc262_parse_auto_config(struct hda_codec *codec)
11876{
11877 struct alc_spec *spec = codec->spec;
11878 int err;
11879 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11880
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011881 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11882 alc262_ignore);
11883 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011884 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011885 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011886 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011887 spec->multiout.max_channels = 2;
11888 spec->no_analog = 1;
11889 goto dig_only;
11890 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011891 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011892 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011893 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11894 if (err < 0)
11895 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011896 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011897 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011898 return err;
11899
11900 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11901
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011902 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011903 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011904 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011905 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011906 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011907 if (spec->autocfg.dig_in_pin)
11908 spec->dig_in_nid = ALC262_DIGIN_NID;
11909
Takashi Iwai603c4012008-07-30 15:01:44 +020011910 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011911 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011912
Takashi Iwaid88897e2008-10-31 15:01:37 +010011913 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011914 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011915 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011916
Takashi Iwai776e1842007-08-29 15:07:11 +020011917 err = alc_auto_add_mic_boost(codec);
11918 if (err < 0)
11919 return err;
11920
Kailang Yang6227cdc2010-02-25 08:36:52 +010011921 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011922
Kailang Yangdf694da2005-12-05 19:42:22 +010011923 return 1;
11924}
11925
11926#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11927#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11928#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011929#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011930
11931
11932/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011933static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011934{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011935 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011936 alc262_auto_init_multi_out(codec);
11937 alc262_auto_init_hp_out(codec);
11938 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011939 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011940 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011941 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011942}
11943
11944/*
11945 * configuration and preset
11946 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011947static const char *alc262_models[ALC262_MODEL_LAST] = {
11948 [ALC262_BASIC] = "basic",
11949 [ALC262_HIPPO] = "hippo",
11950 [ALC262_HIPPO_1] = "hippo_1",
11951 [ALC262_FUJITSU] = "fujitsu",
11952 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011953 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011954 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011955 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011956 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011957 [ALC262_BENQ_T31] = "benq-t31",
11958 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011959 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011960 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011961 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011962 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011963 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011964 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011965 [ALC262_AUTO] = "auto",
11966};
11967
11968static struct snd_pci_quirk alc262_cfg_tbl[] = {
11969 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011970 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011971 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11972 ALC262_HP_BPC),
11973 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11974 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011975 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11976 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011977 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011978 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011979 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011980 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011981 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011982 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011983 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011984 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011985 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11986 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11987 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011988 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11989 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011990 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011991 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011992 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011993 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011994 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011995 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050011996 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010011997 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011998#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010011999 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12000 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012001#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012002 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012003 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012004 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012005 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012006 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012007 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012008 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12009 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012010 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012011 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012012 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012013 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012014 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012015 {}
12016};
12017
12018static struct alc_config_preset alc262_presets[] = {
12019 [ALC262_BASIC] = {
12020 .mixers = { alc262_base_mixer },
12021 .init_verbs = { alc262_init_verbs },
12022 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12023 .dac_nids = alc262_dac_nids,
12024 .hp_nid = 0x03,
12025 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12026 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012027 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012028 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012029 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012030 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012031 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012032 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12033 .dac_nids = alc262_dac_nids,
12034 .hp_nid = 0x03,
12035 .dig_out_nid = ALC262_DIGOUT_NID,
12036 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12037 .channel_mode = alc262_modes,
12038 .input_mux = &alc262_capture_source,
12039 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012040 .setup = alc262_hippo_setup,
12041 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012042 },
12043 [ALC262_HIPPO_1] = {
12044 .mixers = { alc262_hippo1_mixer },
12045 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12046 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12047 .dac_nids = alc262_dac_nids,
12048 .hp_nid = 0x02,
12049 .dig_out_nid = ALC262_DIGOUT_NID,
12050 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12051 .channel_mode = alc262_modes,
12052 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012053 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012054 .setup = alc262_hippo1_setup,
12055 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012056 },
Takashi Iwai834be882006-03-01 14:16:17 +010012057 [ALC262_FUJITSU] = {
12058 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012059 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12060 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012061 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12062 .dac_nids = alc262_dac_nids,
12063 .hp_nid = 0x03,
12064 .dig_out_nid = ALC262_DIGOUT_NID,
12065 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12066 .channel_mode = alc262_modes,
12067 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012068 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012069 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012070 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012071 [ALC262_HP_BPC] = {
12072 .mixers = { alc262_HP_BPC_mixer },
12073 .init_verbs = { alc262_HP_BPC_init_verbs },
12074 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12075 .dac_nids = alc262_dac_nids,
12076 .hp_nid = 0x03,
12077 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12078 .channel_mode = alc262_modes,
12079 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012080 .unsol_event = alc262_hp_bpc_unsol_event,
12081 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012082 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012083 [ALC262_HP_BPC_D7000_WF] = {
12084 .mixers = { alc262_HP_BPC_WildWest_mixer },
12085 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12086 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12087 .dac_nids = alc262_dac_nids,
12088 .hp_nid = 0x03,
12089 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12090 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012091 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012092 .unsol_event = alc262_hp_wildwest_unsol_event,
12093 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012094 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012095 [ALC262_HP_BPC_D7000_WL] = {
12096 .mixers = { alc262_HP_BPC_WildWest_mixer,
12097 alc262_HP_BPC_WildWest_option_mixer },
12098 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12099 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12100 .dac_nids = alc262_dac_nids,
12101 .hp_nid = 0x03,
12102 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12103 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012104 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012105 .unsol_event = alc262_hp_wildwest_unsol_event,
12106 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012107 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012108 [ALC262_HP_TC_T5735] = {
12109 .mixers = { alc262_hp_t5735_mixer },
12110 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12111 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12112 .dac_nids = alc262_dac_nids,
12113 .hp_nid = 0x03,
12114 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12115 .channel_mode = alc262_modes,
12116 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012117 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012118 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012119 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012120 },
12121 [ALC262_HP_RP5700] = {
12122 .mixers = { alc262_hp_rp5700_mixer },
12123 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12124 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12125 .dac_nids = alc262_dac_nids,
12126 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12127 .channel_mode = alc262_modes,
12128 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012129 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012130 [ALC262_BENQ_ED8] = {
12131 .mixers = { alc262_base_mixer },
12132 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12133 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12134 .dac_nids = alc262_dac_nids,
12135 .hp_nid = 0x03,
12136 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12137 .channel_mode = alc262_modes,
12138 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012139 },
Kailang Yang272a5272007-05-14 11:00:38 +020012140 [ALC262_SONY_ASSAMD] = {
12141 .mixers = { alc262_sony_mixer },
12142 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12143 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12144 .dac_nids = alc262_dac_nids,
12145 .hp_nid = 0x02,
12146 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12147 .channel_mode = alc262_modes,
12148 .input_mux = &alc262_capture_source,
12149 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012150 .setup = alc262_hippo_setup,
12151 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012152 },
12153 [ALC262_BENQ_T31] = {
12154 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012155 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12156 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012157 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12158 .dac_nids = alc262_dac_nids,
12159 .hp_nid = 0x03,
12160 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12161 .channel_mode = alc262_modes,
12162 .input_mux = &alc262_capture_source,
12163 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012164 .setup = alc262_hippo_setup,
12165 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012166 },
Tobin Davisf651b502007-10-26 12:40:47 +020012167 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012168 .mixers = { alc262_ultra_mixer },
12169 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012170 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012171 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12172 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012173 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12174 .channel_mode = alc262_modes,
12175 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012176 .adc_nids = alc262_adc_nids, /* ADC0 */
12177 .capsrc_nids = alc262_capsrc_nids,
12178 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012179 .unsol_event = alc262_ultra_unsol_event,
12180 .init_hook = alc262_ultra_automute,
12181 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012182 [ALC262_LENOVO_3000] = {
12183 .mixers = { alc262_lenovo_3000_mixer },
12184 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012185 alc262_lenovo_3000_unsol_verbs,
12186 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012187 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12188 .dac_nids = alc262_dac_nids,
12189 .hp_nid = 0x03,
12190 .dig_out_nid = ALC262_DIGOUT_NID,
12191 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12192 .channel_mode = alc262_modes,
12193 .input_mux = &alc262_fujitsu_capture_source,
12194 .unsol_event = alc262_lenovo_3000_unsol_event,
12195 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012196 [ALC262_NEC] = {
12197 .mixers = { alc262_nec_mixer },
12198 .init_verbs = { alc262_nec_verbs },
12199 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12200 .dac_nids = alc262_dac_nids,
12201 .hp_nid = 0x03,
12202 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12203 .channel_mode = alc262_modes,
12204 .input_mux = &alc262_capture_source,
12205 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012206 [ALC262_TOSHIBA_S06] = {
12207 .mixers = { alc262_toshiba_s06_mixer },
12208 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12209 alc262_eapd_verbs },
12210 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12211 .capsrc_nids = alc262_dmic_capsrc_nids,
12212 .dac_nids = alc262_dac_nids,
12213 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012214 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012215 .dig_out_nid = ALC262_DIGOUT_NID,
12216 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12217 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012218 .unsol_event = alc_sku_unsol_event,
12219 .setup = alc262_toshiba_s06_setup,
12220 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012221 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012222 [ALC262_TOSHIBA_RX1] = {
12223 .mixers = { alc262_toshiba_rx1_mixer },
12224 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12225 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12226 .dac_nids = alc262_dac_nids,
12227 .hp_nid = 0x03,
12228 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12229 .channel_mode = alc262_modes,
12230 .input_mux = &alc262_capture_source,
12231 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012232 .setup = alc262_hippo_setup,
12233 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012234 },
Tony Vroonba340e82009-02-02 19:01:30 +000012235 [ALC262_TYAN] = {
12236 .mixers = { alc262_tyan_mixer },
12237 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12238 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12239 .dac_nids = alc262_dac_nids,
12240 .hp_nid = 0x02,
12241 .dig_out_nid = ALC262_DIGOUT_NID,
12242 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12243 .channel_mode = alc262_modes,
12244 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012245 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012246 .setup = alc262_tyan_setup,
12247 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012248 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012249};
12250
12251static int patch_alc262(struct hda_codec *codec)
12252{
12253 struct alc_spec *spec;
12254 int board_config;
12255 int err;
12256
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012257 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012258 if (spec == NULL)
12259 return -ENOMEM;
12260
12261 codec->spec = spec;
12262#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012263 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12264 * under-run
12265 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012266 {
12267 int tmp;
12268 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12269 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12270 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12271 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12272 }
12273#endif
12274
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012275 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12276
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012277 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12278 alc262_models,
12279 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012280
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012281 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012282 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12283 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012284 board_config = ALC262_AUTO;
12285 }
12286
12287 if (board_config == ALC262_AUTO) {
12288 /* automatic parse from the BIOS config */
12289 err = alc262_parse_auto_config(codec);
12290 if (err < 0) {
12291 alc_free(codec);
12292 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012293 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012294 printk(KERN_INFO
12295 "hda_codec: Cannot set up configuration "
12296 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012297 board_config = ALC262_BASIC;
12298 }
12299 }
12300
Takashi Iwai07eba612009-02-19 08:06:35 +010012301 if (!spec->no_analog) {
12302 err = snd_hda_attach_beep_device(codec, 0x1);
12303 if (err < 0) {
12304 alc_free(codec);
12305 return err;
12306 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012307 }
12308
Kailang Yangdf694da2005-12-05 19:42:22 +010012309 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012310 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012311
Kailang Yangdf694da2005-12-05 19:42:22 +010012312 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12313 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012314
Kailang Yangdf694da2005-12-05 19:42:22 +010012315 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12316 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12317
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012318 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012319 int i;
12320 /* check whether the digital-mic has to be supported */
12321 for (i = 0; i < spec->input_mux->num_items; i++) {
12322 if (spec->input_mux->items[i].index >= 9)
12323 break;
12324 }
12325 if (i < spec->input_mux->num_items) {
12326 /* use only ADC0 */
12327 spec->adc_nids = alc262_dmic_adc_nids;
12328 spec->num_adc_nids = 1;
12329 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012330 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012331 /* all analog inputs */
12332 /* check whether NID 0x07 is valid */
12333 unsigned int wcap = get_wcaps(codec, 0x07);
12334
12335 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012336 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012337 if (wcap != AC_WID_AUD_IN) {
12338 spec->adc_nids = alc262_adc_nids_alt;
12339 spec->num_adc_nids =
12340 ARRAY_SIZE(alc262_adc_nids_alt);
12341 spec->capsrc_nids = alc262_capsrc_nids_alt;
12342 } else {
12343 spec->adc_nids = alc262_adc_nids;
12344 spec->num_adc_nids =
12345 ARRAY_SIZE(alc262_adc_nids);
12346 spec->capsrc_nids = alc262_capsrc_nids;
12347 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012348 }
12349 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012350 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012351 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010012352 if (!spec->no_analog)
12353 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012354
Takashi Iwai2134ea42008-01-10 16:53:55 +010012355 spec->vmaster_nid = 0x0c;
12356
Kailang Yangdf694da2005-12-05 19:42:22 +010012357 codec->patch_ops = alc_patch_ops;
12358 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012359 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012360#ifdef CONFIG_SND_HDA_POWER_SAVE
12361 if (!spec->loopback.amplist)
12362 spec->loopback.amplist = alc262_loopbacks;
12363#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012364
Kailang Yangdf694da2005-12-05 19:42:22 +010012365 return 0;
12366}
12367
Kailang Yangdf694da2005-12-05 19:42:22 +010012368/*
Kailang Yanga361d842007-06-05 12:30:55 +020012369 * ALC268 channel source setting (2 channel)
12370 */
12371#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12372#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012373
Kailang Yanga361d842007-06-05 12:30:55 +020012374static hda_nid_t alc268_dac_nids[2] = {
12375 /* front, hp */
12376 0x02, 0x03
12377};
12378
12379static hda_nid_t alc268_adc_nids[2] = {
12380 /* ADC0-1 */
12381 0x08, 0x07
12382};
12383
12384static hda_nid_t alc268_adc_nids_alt[1] = {
12385 /* ADC0 */
12386 0x08
12387};
12388
Takashi Iwaie1406342008-02-11 18:32:32 +010012389static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12390
Kailang Yanga361d842007-06-05 12:30:55 +020012391static struct snd_kcontrol_new alc268_base_mixer[] = {
12392 /* output mixer control */
12393 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12394 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12395 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12396 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012397 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12398 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12399 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012400 { }
12401};
12402
Takashi Iwai42171c12009-05-08 14:11:43 +020012403static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12404 /* output mixer control */
12405 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12406 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12407 ALC262_HIPPO_MASTER_SWITCH,
12408 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12409 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12410 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12411 { }
12412};
12413
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012414/* bind Beep switches of both NID 0x0f and 0x10 */
12415static struct hda_bind_ctls alc268_bind_beep_sw = {
12416 .ops = &snd_hda_bind_sw,
12417 .values = {
12418 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12419 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12420 0
12421 },
12422};
12423
12424static struct snd_kcontrol_new alc268_beep_mixer[] = {
12425 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12426 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12427 { }
12428};
12429
Kailang Yangd1a991a2007-08-15 16:21:59 +020012430static struct hda_verb alc268_eapd_verbs[] = {
12431 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12432 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12433 { }
12434};
12435
Takashi Iwaid2738092007-08-16 14:59:45 +020012436/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012437static struct hda_verb alc268_toshiba_verbs[] = {
12438 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12439 { } /* end */
12440};
12441
12442/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012443/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012444static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12445 .ops = &snd_hda_bind_vol,
12446 .values = {
12447 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12448 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12449 0
12450 },
12451};
12452
Takashi Iwai889c4392007-08-23 18:56:52 +020012453/* mute/unmute internal speaker according to the hp jack and mute state */
12454static void alc268_acer_automute(struct hda_codec *codec, int force)
12455{
12456 struct alc_spec *spec = codec->spec;
12457 unsigned int mute;
12458
12459 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012460 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012461 spec->sense_updated = 1;
12462 }
12463 if (spec->jack_present)
12464 mute = HDA_AMP_MUTE; /* mute internal speaker */
12465 else /* unmute internal speaker if necessary */
12466 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12467 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12468 HDA_AMP_MUTE, mute);
12469}
12470
12471
12472/* bind hp and internal speaker mute (with plug check) */
12473static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12474 struct snd_ctl_elem_value *ucontrol)
12475{
12476 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12477 long *valp = ucontrol->value.integer.value;
12478 int change;
12479
Takashi Iwai8de56b72009-07-24 16:51:47 +020012480 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012481 if (change)
12482 alc268_acer_automute(codec, 0);
12483 return change;
12484}
Takashi Iwaid2738092007-08-16 14:59:45 +020012485
Kailang Yang8ef355d2008-08-26 13:10:22 +020012486static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12487 /* output mixer control */
12488 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12489 {
12490 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12491 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012492 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012493 .info = snd_hda_mixer_amp_switch_info,
12494 .get = snd_hda_mixer_amp_switch_get,
12495 .put = alc268_acer_master_sw_put,
12496 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12497 },
12498 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12499 { }
12500};
12501
Takashi Iwaid2738092007-08-16 14:59:45 +020012502static struct snd_kcontrol_new alc268_acer_mixer[] = {
12503 /* output mixer control */
12504 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12505 {
12506 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12507 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012508 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012509 .info = snd_hda_mixer_amp_switch_info,
12510 .get = snd_hda_mixer_amp_switch_get,
12511 .put = alc268_acer_master_sw_put,
12512 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12513 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012514 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12515 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12516 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012517 { }
12518};
12519
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012520static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12521 /* output mixer control */
12522 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12523 {
12524 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12525 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012526 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012527 .info = snd_hda_mixer_amp_switch_info,
12528 .get = snd_hda_mixer_amp_switch_get,
12529 .put = alc268_acer_master_sw_put,
12530 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12531 },
12532 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12533 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12534 { }
12535};
12536
Kailang Yang8ef355d2008-08-26 13:10:22 +020012537static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12538 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12539 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12540 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12541 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12542 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12543 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12544 { }
12545};
12546
Takashi Iwaid2738092007-08-16 14:59:45 +020012547static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012548 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12549 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012550 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12551 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012552 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12553 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012554 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12555 { }
12556};
12557
12558/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012559#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012560#define alc268_toshiba_setup alc262_hippo_setup
12561#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012562
12563static void alc268_acer_unsol_event(struct hda_codec *codec,
12564 unsigned int res)
12565{
Takashi Iwai889c4392007-08-23 18:56:52 +020012566 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012567 return;
12568 alc268_acer_automute(codec, 1);
12569}
12570
Takashi Iwai889c4392007-08-23 18:56:52 +020012571static void alc268_acer_init_hook(struct hda_codec *codec)
12572{
12573 alc268_acer_automute(codec, 1);
12574}
12575
Kailang Yang8ef355d2008-08-26 13:10:22 +020012576/* toggle speaker-output according to the hp-jack state */
12577static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12578{
12579 unsigned int present;
12580 unsigned char bits;
12581
Wu Fengguang864f92b2009-11-18 12:38:02 +080012582 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012583 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012584 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012585 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012586 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012587 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012588}
12589
Kailang Yang8ef355d2008-08-26 13:10:22 +020012590static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12591 unsigned int res)
12592{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012593 switch (res >> 26) {
12594 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012595 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012596 break;
12597 case ALC880_MIC_EVENT:
12598 alc_mic_automute(codec);
12599 break;
12600 }
12601}
12602
12603static void alc268_acer_lc_setup(struct hda_codec *codec)
12604{
12605 struct alc_spec *spec = codec->spec;
12606 spec->ext_mic.pin = 0x18;
12607 spec->ext_mic.mux_idx = 0;
12608 spec->int_mic.pin = 0x12;
12609 spec->int_mic.mux_idx = 6;
12610 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012611}
12612
12613static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12614{
12615 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012616 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012617}
12618
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012619static struct snd_kcontrol_new alc268_dell_mixer[] = {
12620 /* output mixer control */
12621 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12622 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12623 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12624 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12625 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12626 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12627 { }
12628};
12629
12630static struct hda_verb alc268_dell_verbs[] = {
12631 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12632 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12633 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012634 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012635 { }
12636};
12637
12638/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012639static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012640{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012641 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012642
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012643 spec->autocfg.hp_pins[0] = 0x15;
12644 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012645 spec->ext_mic.pin = 0x18;
12646 spec->ext_mic.mux_idx = 0;
12647 spec->int_mic.pin = 0x19;
12648 spec->int_mic.mux_idx = 1;
12649 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012650}
12651
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012652static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12653 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12654 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12655 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12656 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12657 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12658 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12659 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12660 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12661 { }
12662};
12663
12664static struct hda_verb alc267_quanta_il1_verbs[] = {
12665 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12666 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12667 { }
12668};
12669
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012670static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012671{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012672 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012673 spec->autocfg.hp_pins[0] = 0x15;
12674 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012675 spec->ext_mic.pin = 0x18;
12676 spec->ext_mic.mux_idx = 0;
12677 spec->int_mic.pin = 0x19;
12678 spec->int_mic.mux_idx = 1;
12679 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012680}
12681
Kailang Yanga361d842007-06-05 12:30:55 +020012682/*
12683 * generic initialization of ADC, input mixers and output mixers
12684 */
12685static struct hda_verb alc268_base_init_verbs[] = {
12686 /* Unmute DAC0-1 and set vol = 0 */
12687 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012688 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012689
12690 /*
12691 * Set up output mixers (0x0c - 0x0e)
12692 */
12693 /* set vol=0 to output mixers */
12694 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012695 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12696
12697 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12698 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12699
12700 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12701 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12702 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12703 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12704 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12705 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12706 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12707 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12708
12709 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12710 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12711 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12712 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012713 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012714
12715 /* set PCBEEP vol = 0, mute connections */
12716 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12717 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12718 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012719
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012720 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012721
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012722 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12723 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12724 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12725 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012726
Kailang Yanga361d842007-06-05 12:30:55 +020012727 { }
12728};
12729
12730/*
12731 * generic initialization of ADC, input mixers and output mixers
12732 */
12733static struct hda_verb alc268_volume_init_verbs[] = {
12734 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012735 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12736 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012737
12738 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12739 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12740 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12741 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12742 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12743
Kailang Yanga361d842007-06-05 12:30:55 +020012744 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012745 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12746 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12747
12748 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012749 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012750
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012751 /* set PCBEEP vol = 0, mute connections */
12752 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12753 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12754 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012755
12756 { }
12757};
12758
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012759static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12760 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12761 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12762 { } /* end */
12763};
12764
Kailang Yanga361d842007-06-05 12:30:55 +020012765static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12766 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12767 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012768 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012769 { } /* end */
12770};
12771
12772static struct snd_kcontrol_new alc268_capture_mixer[] = {
12773 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12774 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12775 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12776 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012777 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012778 { } /* end */
12779};
12780
12781static struct hda_input_mux alc268_capture_source = {
12782 .num_items = 4,
12783 .items = {
12784 { "Mic", 0x0 },
12785 { "Front Mic", 0x1 },
12786 { "Line", 0x2 },
12787 { "CD", 0x3 },
12788 },
12789};
12790
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012791static struct hda_input_mux alc268_acer_capture_source = {
12792 .num_items = 3,
12793 .items = {
12794 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012795 { "Internal Mic", 0x1 },
12796 { "Line", 0x2 },
12797 },
12798};
12799
12800static struct hda_input_mux alc268_acer_dmic_capture_source = {
12801 .num_items = 3,
12802 .items = {
12803 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012804 { "Internal Mic", 0x6 },
12805 { "Line", 0x2 },
12806 },
12807};
12808
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012809#ifdef CONFIG_SND_DEBUG
12810static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012811 /* Volume widgets */
12812 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12813 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12814 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12815 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12816 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12817 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12818 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12819 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12820 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12821 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12822 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12823 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12824 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012825 /* The below appears problematic on some hardwares */
12826 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012827 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12828 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12829 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12830 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12831
12832 /* Modes for retasking pin widgets */
12833 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12834 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12835 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12836 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12837
12838 /* Controls for GPIO pins, assuming they are configured as outputs */
12839 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12840 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12841 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12842 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12843
12844 /* Switches to allow the digital SPDIF output pin to be enabled.
12845 * The ALC268 does not have an SPDIF input.
12846 */
12847 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12848
12849 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12850 * this output to turn on an external amplifier.
12851 */
12852 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12853 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12854
12855 { } /* end */
12856};
12857#endif
12858
Kailang Yanga361d842007-06-05 12:30:55 +020012859/* create input playback/capture controls for the given pin */
12860static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12861 const char *ctlname, int idx)
12862{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012863 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012864 int err;
12865
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012866 switch (nid) {
12867 case 0x14:
12868 case 0x16:
12869 dac = 0x02;
12870 break;
12871 case 0x15:
Kailang Yang531d8792010-04-09 10:57:33 +020012872 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012873 dac = 0x03;
12874 break;
12875 default:
12876 return 0;
12877 }
12878 if (spec->multiout.dac_nids[0] != dac &&
12879 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012880 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012881 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012882 HDA_OUTPUT));
12883 if (err < 0)
12884 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012885 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12886 }
12887
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012888 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012889 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020012890 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012891 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012892 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012893 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012894 if (err < 0)
12895 return err;
12896 return 0;
12897}
12898
12899/* add playback controls from the parsed DAC table */
12900static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12901 const struct auto_pin_cfg *cfg)
12902{
12903 hda_nid_t nid;
12904 int err;
12905
Kailang Yanga361d842007-06-05 12:30:55 +020012906 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012907
12908 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012909 if (nid) {
12910 const char *name;
12911 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12912 name = "Speaker";
12913 else
12914 name = "Front";
12915 err = alc268_new_analog_output(spec, nid, name, 0);
12916 if (err < 0)
12917 return err;
12918 }
Kailang Yanga361d842007-06-05 12:30:55 +020012919
12920 nid = cfg->speaker_pins[0];
12921 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012922 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020012923 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12924 if (err < 0)
12925 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012926 } else {
12927 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12928 if (err < 0)
12929 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012930 }
12931 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012932 if (nid) {
12933 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12934 if (err < 0)
12935 return err;
12936 }
Kailang Yanga361d842007-06-05 12:30:55 +020012937
12938 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12939 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012940 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012941 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012942 if (err < 0)
12943 return err;
12944 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012945 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012946}
12947
12948/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012949static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012950 const struct auto_pin_cfg *cfg)
12951{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012952 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012953}
12954
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012955static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12956 hda_nid_t nid, int pin_type)
12957{
12958 int idx;
12959
12960 alc_set_pin_output(codec, nid, pin_type);
12961 if (nid == 0x14 || nid == 0x16)
12962 idx = 0;
12963 else
12964 idx = 1;
12965 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12966}
12967
12968static void alc268_auto_init_multi_out(struct hda_codec *codec)
12969{
12970 struct alc_spec *spec = codec->spec;
12971 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12972 if (nid) {
12973 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12974 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12975 }
12976}
12977
12978static void alc268_auto_init_hp_out(struct hda_codec *codec)
12979{
12980 struct alc_spec *spec = codec->spec;
12981 hda_nid_t pin;
12982
12983 pin = spec->autocfg.hp_pins[0];
12984 if (pin)
12985 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12986 pin = spec->autocfg.speaker_pins[0];
12987 if (pin)
12988 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12989}
12990
Kailang Yanga361d842007-06-05 12:30:55 +020012991static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12992{
12993 struct alc_spec *spec = codec->spec;
12994 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12995 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12996 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12997 unsigned int dac_vol1, dac_vol2;
12998
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012999 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013000 snd_hda_codec_write(codec, speaker_nid, 0,
13001 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013002 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013003 snd_hda_codec_write(codec, 0x0f, 0,
13004 AC_VERB_SET_AMP_GAIN_MUTE,
13005 AMP_IN_UNMUTE(1));
13006 snd_hda_codec_write(codec, 0x10, 0,
13007 AC_VERB_SET_AMP_GAIN_MUTE,
13008 AMP_IN_UNMUTE(1));
13009 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013010 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013011 snd_hda_codec_write(codec, 0x0f, 0,
13012 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13013 snd_hda_codec_write(codec, 0x10, 0,
13014 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13015 }
13016
13017 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013018 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013019 dac_vol2 = AMP_OUT_ZERO;
13020 else if (line_nid == 0x15)
13021 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013022 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013023 dac_vol2 = AMP_OUT_ZERO;
13024 else if (hp_nid == 0x15)
13025 dac_vol1 = AMP_OUT_ZERO;
13026 if (line_nid != 0x16 || hp_nid != 0x16 ||
13027 spec->autocfg.line_out_pins[1] != 0x16 ||
13028 spec->autocfg.line_out_pins[2] != 0x16)
13029 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13030
13031 snd_hda_codec_write(codec, 0x02, 0,
13032 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13033 snd_hda_codec_write(codec, 0x03, 0,
13034 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13035}
13036
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013037/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013038#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13039#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013040#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013041#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13042
13043/*
13044 * BIOS auto configuration
13045 */
13046static int alc268_parse_auto_config(struct hda_codec *codec)
13047{
13048 struct alc_spec *spec = codec->spec;
13049 int err;
13050 static hda_nid_t alc268_ignore[] = { 0 };
13051
13052 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13053 alc268_ignore);
13054 if (err < 0)
13055 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013056 if (!spec->autocfg.line_outs) {
13057 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13058 spec->multiout.max_channels = 2;
13059 spec->no_analog = 1;
13060 goto dig_only;
13061 }
Kailang Yanga361d842007-06-05 12:30:55 +020013062 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013063 }
Kailang Yanga361d842007-06-05 12:30:55 +020013064 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13065 if (err < 0)
13066 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013067 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013068 if (err < 0)
13069 return err;
13070
13071 spec->multiout.max_channels = 2;
13072
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013073 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013074 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013075 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020013076 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013077 spec->dig_out_type = spec->autocfg.dig_out_type[0];
13078 }
Takashi Iwai603c4012008-07-30 15:01:44 +020013079 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013080 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013081
Takashi Iwai892981f2009-03-02 08:04:35 +010013082 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013083 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013084
Takashi Iwaid88897e2008-10-31 15:01:37 +010013085 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013086 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013087 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013088
Takashi Iwai776e1842007-08-29 15:07:11 +020013089 err = alc_auto_add_mic_boost(codec);
13090 if (err < 0)
13091 return err;
13092
Kailang Yang6227cdc2010-02-25 08:36:52 +010013093 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013094
Kailang Yanga361d842007-06-05 12:30:55 +020013095 return 1;
13096}
13097
Kailang Yanga361d842007-06-05 12:30:55 +020013098#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13099
13100/* init callback for auto-configuration model -- overriding the default init */
13101static void alc268_auto_init(struct hda_codec *codec)
13102{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013103 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013104 alc268_auto_init_multi_out(codec);
13105 alc268_auto_init_hp_out(codec);
13106 alc268_auto_init_mono_speaker_out(codec);
13107 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013108 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013109 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013110}
13111
13112/*
13113 * configuration and preset
13114 */
13115static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013116 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013117 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013118 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013119 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013120 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013121 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013122 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013123 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013124#ifdef CONFIG_SND_DEBUG
13125 [ALC268_TEST] = "test",
13126#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013127 [ALC268_AUTO] = "auto",
13128};
13129
13130static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013131 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013132 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013133 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013134 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013135 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013136 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13137 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013138 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013139 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13140 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013141 /* almost compatible with toshiba but with optional digital outs;
13142 * auto-probing seems working fine
13143 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013144 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013145 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013146 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013147 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013148 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013149 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013150 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013151 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020013152 {}
13153};
13154
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013155/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13156static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13157 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13158 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13159 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13160 ALC268_TOSHIBA),
13161 {}
13162};
13163
Kailang Yanga361d842007-06-05 12:30:55 +020013164static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013165 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013166 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13167 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013168 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13169 alc267_quanta_il1_verbs },
13170 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13171 .dac_nids = alc268_dac_nids,
13172 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13173 .adc_nids = alc268_adc_nids_alt,
13174 .hp_nid = 0x03,
13175 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13176 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013177 .unsol_event = alc_sku_unsol_event,
13178 .setup = alc267_quanta_il1_setup,
13179 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013180 },
Kailang Yanga361d842007-06-05 12:30:55 +020013181 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013182 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13183 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013184 .init_verbs = { alc268_base_init_verbs },
13185 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13186 .dac_nids = alc268_dac_nids,
13187 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13188 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013189 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013190 .hp_nid = 0x03,
13191 .dig_out_nid = ALC268_DIGOUT_NID,
13192 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13193 .channel_mode = alc268_modes,
13194 .input_mux = &alc268_capture_source,
13195 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013196 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013197 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013198 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013199 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13200 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013201 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13202 .dac_nids = alc268_dac_nids,
13203 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13204 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013205 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013206 .hp_nid = 0x03,
13207 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13208 .channel_mode = alc268_modes,
13209 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013210 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013211 .setup = alc268_toshiba_setup,
13212 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013213 },
13214 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013215 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013216 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013217 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13218 alc268_acer_verbs },
13219 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13220 .dac_nids = alc268_dac_nids,
13221 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13222 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013223 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013224 .hp_nid = 0x02,
13225 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13226 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013227 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013228 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013229 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013230 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013231 [ALC268_ACER_DMIC] = {
13232 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13233 alc268_beep_mixer },
13234 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13235 alc268_acer_verbs },
13236 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13237 .dac_nids = alc268_dac_nids,
13238 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13239 .adc_nids = alc268_adc_nids_alt,
13240 .capsrc_nids = alc268_capsrc_nids,
13241 .hp_nid = 0x02,
13242 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13243 .channel_mode = alc268_modes,
13244 .input_mux = &alc268_acer_dmic_capture_source,
13245 .unsol_event = alc268_acer_unsol_event,
13246 .init_hook = alc268_acer_init_hook,
13247 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013248 [ALC268_ACER_ASPIRE_ONE] = {
13249 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013250 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013251 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013252 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13253 alc268_acer_aspire_one_verbs },
13254 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13255 .dac_nids = alc268_dac_nids,
13256 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13257 .adc_nids = alc268_adc_nids_alt,
13258 .capsrc_nids = alc268_capsrc_nids,
13259 .hp_nid = 0x03,
13260 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13261 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013262 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013263 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013264 .init_hook = alc268_acer_lc_init_hook,
13265 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013266 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013267 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13268 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013269 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13270 alc268_dell_verbs },
13271 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13272 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013273 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13274 .adc_nids = alc268_adc_nids_alt,
13275 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013276 .hp_nid = 0x02,
13277 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13278 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013279 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013280 .setup = alc268_dell_setup,
13281 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013282 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013283 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013284 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13285 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013286 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13287 alc268_toshiba_verbs },
13288 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13289 .dac_nids = alc268_dac_nids,
13290 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13291 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013292 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013293 .hp_nid = 0x03,
13294 .dig_out_nid = ALC268_DIGOUT_NID,
13295 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13296 .channel_mode = alc268_modes,
13297 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013298 .setup = alc268_toshiba_setup,
13299 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013300 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013301#ifdef CONFIG_SND_DEBUG
13302 [ALC268_TEST] = {
13303 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13304 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13305 alc268_volume_init_verbs },
13306 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13307 .dac_nids = alc268_dac_nids,
13308 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13309 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013310 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013311 .hp_nid = 0x03,
13312 .dig_out_nid = ALC268_DIGOUT_NID,
13313 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13314 .channel_mode = alc268_modes,
13315 .input_mux = &alc268_capture_source,
13316 },
13317#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013318};
13319
13320static int patch_alc268(struct hda_codec *codec)
13321{
13322 struct alc_spec *spec;
13323 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013324 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013325
Julia Lawallef86f582009-12-19 08:18:03 +010013326 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013327 if (spec == NULL)
13328 return -ENOMEM;
13329
13330 codec->spec = spec;
13331
13332 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13333 alc268_models,
13334 alc268_cfg_tbl);
13335
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013336 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13337 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013338 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013339
Kailang Yanga361d842007-06-05 12:30:55 +020013340 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013341 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13342 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013343 board_config = ALC268_AUTO;
13344 }
13345
13346 if (board_config == ALC268_AUTO) {
13347 /* automatic parse from the BIOS config */
13348 err = alc268_parse_auto_config(codec);
13349 if (err < 0) {
13350 alc_free(codec);
13351 return err;
13352 } else if (!err) {
13353 printk(KERN_INFO
13354 "hda_codec: Cannot set up configuration "
13355 "from BIOS. Using base mode...\n");
13356 board_config = ALC268_3ST;
13357 }
13358 }
13359
13360 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013361 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013362
Kailang Yanga361d842007-06-05 12:30:55 +020013363 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13364 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013365 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013366
Kailang Yanga361d842007-06-05 12:30:55 +020013367 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13368
Takashi Iwai22971e32009-02-10 11:56:44 +010013369 has_beep = 0;
13370 for (i = 0; i < spec->num_mixers; i++) {
13371 if (spec->mixers[i] == alc268_beep_mixer) {
13372 has_beep = 1;
13373 break;
13374 }
13375 }
13376
13377 if (has_beep) {
13378 err = snd_hda_attach_beep_device(codec, 0x1);
13379 if (err < 0) {
13380 alc_free(codec);
13381 return err;
13382 }
13383 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13384 /* override the amp caps for beep generator */
13385 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013386 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13387 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13388 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13389 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013390 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013391
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013392 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013393 /* check whether NID 0x07 is valid */
13394 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013395 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013396
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013397 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013398 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013399 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013400 if (spec->auto_mic ||
13401 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013402 spec->adc_nids = alc268_adc_nids_alt;
13403 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013404 if (spec->auto_mic)
13405 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013406 if (spec->auto_mic || spec->input_mux->num_items == 1)
13407 add_mixer(spec, alc268_capture_nosrc_mixer);
13408 else
13409 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013410 } else {
13411 spec->adc_nids = alc268_adc_nids;
13412 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013413 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013414 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013415 /* set default input source */
13416 for (i = 0; i < spec->num_adc_nids; i++)
13417 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13418 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013419 i < spec->num_mux_defs ?
13420 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013421 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013422 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013423
13424 spec->vmaster_nid = 0x02;
13425
Kailang Yanga361d842007-06-05 12:30:55 +020013426 codec->patch_ops = alc_patch_ops;
13427 if (board_config == ALC268_AUTO)
13428 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013429
Kailang Yanga361d842007-06-05 12:30:55 +020013430 return 0;
13431}
13432
13433/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013434 * ALC269 channel source setting (2 channel)
13435 */
13436#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13437
13438#define alc269_dac_nids alc260_dac_nids
13439
13440static hda_nid_t alc269_adc_nids[1] = {
13441 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013442 0x08,
13443};
13444
Takashi Iwaie01bf502008-08-21 16:25:07 +020013445static hda_nid_t alc269_capsrc_nids[1] = {
13446 0x23,
13447};
13448
Kailang Yang84898e82010-02-04 14:16:14 +010013449static hda_nid_t alc269vb_adc_nids[1] = {
13450 /* ADC1 */
13451 0x09,
13452};
13453
13454static hda_nid_t alc269vb_capsrc_nids[1] = {
13455 0x22,
13456};
13457
Takashi Iwai66946352010-03-29 17:21:45 +020013458static hda_nid_t alc269_adc_candidates[] = {
13459 0x08, 0x09, 0x07,
13460};
Takashi Iwaie01bf502008-08-21 16:25:07 +020013461
Kailang Yangf6a92242007-12-13 16:52:54 +010013462#define alc269_modes alc260_modes
13463#define alc269_capture_source alc880_lg_lw_capture_source
13464
13465static struct snd_kcontrol_new alc269_base_mixer[] = {
13466 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13467 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13468 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13469 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13470 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13471 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13472 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13473 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13474 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13475 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13476 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13477 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13478 { } /* end */
13479};
13480
Kailang Yang60db6b52008-08-26 13:13:00 +020013481static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13482 /* output mixer control */
13483 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13484 {
13485 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13486 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013487 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013488 .info = snd_hda_mixer_amp_switch_info,
13489 .get = snd_hda_mixer_amp_switch_get,
13490 .put = alc268_acer_master_sw_put,
13491 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13492 },
13493 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13494 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13495 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13496 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13497 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13498 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013499 { }
13500};
13501
Tony Vroon64154832008-11-06 15:08:49 +000013502static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13503 /* output mixer control */
13504 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13505 {
13506 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13507 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013508 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013509 .info = snd_hda_mixer_amp_switch_info,
13510 .get = snd_hda_mixer_amp_switch_get,
13511 .put = alc268_acer_master_sw_put,
13512 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13513 },
13514 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13515 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13516 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13517 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13518 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13519 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13520 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13521 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13522 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013523 { }
13524};
13525
Kailang Yang84898e82010-02-04 14:16:14 +010013526static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013527 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013528 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013529 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013530 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013531 { } /* end */
13532};
13533
Kailang Yang84898e82010-02-04 14:16:14 +010013534static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
13535 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13536 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13537 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13538 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13539 { } /* end */
13540};
13541
Kailang Yangf6a92242007-12-13 16:52:54 +010013542/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010013543static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
13544 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13545 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13546 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13547 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13548 { } /* end */
13549};
13550
13551static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020013552 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13553 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013554 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13555 { } /* end */
13556};
13557
Kailang Yang84898e82010-02-04 14:16:14 +010013558static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
13559 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13560 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13561 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13562 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13563 { } /* end */
13564};
13565
13566static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
13567 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13568 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13569 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13570 { } /* end */
13571};
13572
Takashi Iwai26f5df22008-11-03 17:39:46 +010013573/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010013574#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013575
Kailang Yang60db6b52008-08-26 13:13:00 +020013576static struct hda_verb alc269_quanta_fl1_verbs[] = {
13577 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13578 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13579 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13580 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13581 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13582 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13583 { }
13584};
13585
Tony Vroon64154832008-11-06 15:08:49 +000013586static struct hda_verb alc269_lifebook_verbs[] = {
13587 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13588 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13589 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13590 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13591 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13592 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13593 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13594 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13595 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13596 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13597 { }
13598};
13599
Kailang Yang60db6b52008-08-26 13:13:00 +020013600/* toggle speaker-output according to the hp-jack state */
13601static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13602{
13603 unsigned int present;
13604 unsigned char bits;
13605
Wu Fengguang864f92b2009-11-18 12:38:02 +080013606 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013607 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013608 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013609 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013610 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013611 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013612
13613 snd_hda_codec_write(codec, 0x20, 0,
13614 AC_VERB_SET_COEF_INDEX, 0x0c);
13615 snd_hda_codec_write(codec, 0x20, 0,
13616 AC_VERB_SET_PROC_COEF, 0x680);
13617
13618 snd_hda_codec_write(codec, 0x20, 0,
13619 AC_VERB_SET_COEF_INDEX, 0x0c);
13620 snd_hda_codec_write(codec, 0x20, 0,
13621 AC_VERB_SET_PROC_COEF, 0x480);
13622}
13623
Tony Vroon64154832008-11-06 15:08:49 +000013624/* toggle speaker-output according to the hp-jacks state */
13625static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13626{
13627 unsigned int present;
13628 unsigned char bits;
13629
13630 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013631 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013632
13633 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013634 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013635
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013636 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000013637 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013638 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013639 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013640 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013641
13642 snd_hda_codec_write(codec, 0x20, 0,
13643 AC_VERB_SET_COEF_INDEX, 0x0c);
13644 snd_hda_codec_write(codec, 0x20, 0,
13645 AC_VERB_SET_PROC_COEF, 0x680);
13646
13647 snd_hda_codec_write(codec, 0x20, 0,
13648 AC_VERB_SET_COEF_INDEX, 0x0c);
13649 snd_hda_codec_write(codec, 0x20, 0,
13650 AC_VERB_SET_PROC_COEF, 0x480);
13651}
13652
Tony Vroon64154832008-11-06 15:08:49 +000013653static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13654{
13655 unsigned int present_laptop;
13656 unsigned int present_dock;
13657
Wu Fengguang864f92b2009-11-18 12:38:02 +080013658 present_laptop = snd_hda_jack_detect(codec, 0x18);
13659 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013660
13661 /* Laptop mic port overrides dock mic port, design decision */
13662 if (present_dock)
13663 snd_hda_codec_write(codec, 0x23, 0,
13664 AC_VERB_SET_CONNECT_SEL, 0x3);
13665 if (present_laptop)
13666 snd_hda_codec_write(codec, 0x23, 0,
13667 AC_VERB_SET_CONNECT_SEL, 0x0);
13668 if (!present_dock && !present_laptop)
13669 snd_hda_codec_write(codec, 0x23, 0,
13670 AC_VERB_SET_CONNECT_SEL, 0x1);
13671}
13672
Kailang Yang60db6b52008-08-26 13:13:00 +020013673static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13674 unsigned int res)
13675{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013676 switch (res >> 26) {
13677 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013678 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013679 break;
13680 case ALC880_MIC_EVENT:
13681 alc_mic_automute(codec);
13682 break;
13683 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013684}
13685
Tony Vroon64154832008-11-06 15:08:49 +000013686static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13687 unsigned int res)
13688{
13689 if ((res >> 26) == ALC880_HP_EVENT)
13690 alc269_lifebook_speaker_automute(codec);
13691 if ((res >> 26) == ALC880_MIC_EVENT)
13692 alc269_lifebook_mic_autoswitch(codec);
13693}
13694
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013695static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13696{
13697 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013698 spec->autocfg.hp_pins[0] = 0x15;
13699 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013700 spec->ext_mic.pin = 0x18;
13701 spec->ext_mic.mux_idx = 0;
13702 spec->int_mic.pin = 0x19;
13703 spec->int_mic.mux_idx = 1;
13704 spec->auto_mic = 1;
13705}
13706
Kailang Yang60db6b52008-08-26 13:13:00 +020013707static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13708{
13709 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013710 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013711}
13712
Tony Vroon64154832008-11-06 15:08:49 +000013713static void alc269_lifebook_init_hook(struct hda_codec *codec)
13714{
13715 alc269_lifebook_speaker_automute(codec);
13716 alc269_lifebook_mic_autoswitch(codec);
13717}
13718
Kailang Yang84898e82010-02-04 14:16:14 +010013719static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013720 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13721 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13722 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13723 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13724 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13725 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13726 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13727 {}
13728};
13729
Kailang Yang84898e82010-02-04 14:16:14 +010013730static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013731 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13732 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13733 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13734 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13735 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13736 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13737 {}
13738};
13739
Kailang Yang84898e82010-02-04 14:16:14 +010013740static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
13741 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13742 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
13743 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13744 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13745 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13746 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13747 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13748 {}
13749};
13750
13751static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
13752 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13753 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
13754 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13755 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13756 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13757 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13758 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13759 {}
13760};
13761
Kailang Yang60db6b52008-08-26 13:13:00 +020013762/* toggle speaker-output according to the hp-jack state */
13763static void alc269_speaker_automute(struct hda_codec *codec)
13764{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013765 struct alc_spec *spec = codec->spec;
13766 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013767 unsigned int present;
13768 unsigned char bits;
13769
Kailang Yangebb83ee2009-12-17 12:23:00 +010013770 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013771 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013772 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013773 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013774 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013775 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013776}
13777
Kailang Yang60db6b52008-08-26 13:13:00 +020013778/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010013779static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013780 unsigned int res)
13781{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013782 switch (res >> 26) {
13783 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013784 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013785 break;
13786 case ALC880_MIC_EVENT:
13787 alc_mic_automute(codec);
13788 break;
13789 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013790}
13791
Kailang Yang84898e82010-02-04 14:16:14 +010013792static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013793{
13794 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013795 spec->autocfg.hp_pins[0] = 0x15;
13796 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013797 spec->ext_mic.pin = 0x18;
13798 spec->ext_mic.mux_idx = 0;
13799 spec->int_mic.pin = 0x12;
13800 spec->int_mic.mux_idx = 5;
13801 spec->auto_mic = 1;
13802}
13803
Kailang Yang84898e82010-02-04 14:16:14 +010013804static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
13805{
13806 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013807 spec->autocfg.hp_pins[0] = 0x15;
13808 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang84898e82010-02-04 14:16:14 +010013809 spec->ext_mic.pin = 0x18;
13810 spec->ext_mic.mux_idx = 0;
13811 spec->int_mic.pin = 0x12;
13812 spec->int_mic.mux_idx = 6;
13813 spec->auto_mic = 1;
13814}
13815
13816static void alc269_laptop_amic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013817{
13818 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013819 spec->autocfg.hp_pins[0] = 0x15;
13820 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013821 spec->ext_mic.pin = 0x18;
13822 spec->ext_mic.mux_idx = 0;
13823 spec->int_mic.pin = 0x19;
13824 spec->int_mic.mux_idx = 1;
13825 spec->auto_mic = 1;
13826}
13827
Kailang Yang84898e82010-02-04 14:16:14 +010013828static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013829{
13830 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013831 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013832}
13833
Kailang Yangf6a92242007-12-13 16:52:54 +010013834/*
13835 * generic initialization of ADC, input mixers and output mixers
13836 */
13837static struct hda_verb alc269_init_verbs[] = {
13838 /*
13839 * Unmute ADC0 and set the default input to mic-in
13840 */
Kailang Yang84898e82010-02-04 14:16:14 +010013841 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013842
13843 /*
Kailang Yang84898e82010-02-04 14:16:14 +010013844 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010013845 */
13846 /* set vol=0 to output mixers */
13847 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13848 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13849
13850 /* set up input amps for analog loopback */
13851 /* Amp Indices: DAC = 0, mixer = 1 */
13852 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13853 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13854 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13855 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13856 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13857 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13858
13859 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13860 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13861 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13862 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13863 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13864 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13865 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13866
13867 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13868 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010013869
Kailang Yang84898e82010-02-04 14:16:14 +010013870 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010013871 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13872 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010013873 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010013874
13875 /* set EAPD */
13876 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010013877 { }
13878};
13879
13880static struct hda_verb alc269vb_init_verbs[] = {
13881 /*
13882 * Unmute ADC0 and set the default input to mic-in
13883 */
13884 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13885
13886 /*
13887 * Set up output mixers (0x02 - 0x03)
13888 */
13889 /* set vol=0 to output mixers */
13890 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13891 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13892
13893 /* set up input amps for analog loopback */
13894 /* Amp Indices: DAC = 0, mixer = 1 */
13895 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13896 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13897 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13898 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13899 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13900 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13901
13902 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13903 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13904 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13905 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13906 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13907 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13908 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13909
13910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13911 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13912
13913 /* FIXME: use Mux-type input source selection */
13914 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13915 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
13916 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
13917
13918 /* set EAPD */
13919 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010013920 { }
13921};
13922
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013923#define alc269_auto_create_multi_out_ctls \
13924 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013925#define alc269_auto_create_input_ctls \
13926 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013927
13928#ifdef CONFIG_SND_HDA_POWER_SAVE
13929#define alc269_loopbacks alc880_loopbacks
13930#endif
13931
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013932/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013933#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13934#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13935#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13936#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13937
Takashi Iwaif03d3112009-03-05 14:18:16 +010013938static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13939 .substreams = 1,
13940 .channels_min = 2,
13941 .channels_max = 8,
13942 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13943 /* NID is set in alc_build_pcms */
13944 .ops = {
13945 .open = alc880_playback_pcm_open,
13946 .prepare = alc880_playback_pcm_prepare,
13947 .cleanup = alc880_playback_pcm_cleanup
13948 },
13949};
13950
13951static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13952 .substreams = 1,
13953 .channels_min = 2,
13954 .channels_max = 2,
13955 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13956 /* NID is set in alc_build_pcms */
13957};
13958
Kailang Yangf6a92242007-12-13 16:52:54 +010013959/*
13960 * BIOS auto configuration
13961 */
13962static int alc269_parse_auto_config(struct hda_codec *codec)
13963{
13964 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013965 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013966 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13967
13968 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13969 alc269_ignore);
13970 if (err < 0)
13971 return err;
13972
13973 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13974 if (err < 0)
13975 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013976 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013977 if (err < 0)
13978 return err;
13979
13980 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13981
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013982 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013983 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13984
Takashi Iwai603c4012008-07-30 15:01:44 +020013985 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013986 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013987
Kailang Yang84898e82010-02-04 14:16:14 +010013988 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
13989 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010013990 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010013991 } else {
13992 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010013993 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010013994 }
13995
Kailang Yangf6a92242007-12-13 16:52:54 +010013996 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013997 spec->input_mux = &spec->private_imux[0];
Takashi Iwai66946352010-03-29 17:21:45 +020013998 fillup_priv_adc_nids(codec, alc269_adc_candidates,
13999 sizeof(alc269_adc_candidates));
14000
Takashi Iwaie01bf502008-08-21 16:25:07 +020014001 /* set default input source */
Takashi Iwai66946352010-03-29 17:21:45 +020014002 snd_hda_codec_write_cache(codec, spec->capsrc_nids[0],
Takashi Iwaie01bf502008-08-21 16:25:07 +020014003 0, AC_VERB_SET_CONNECT_SEL,
14004 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014005
14006 err = alc_auto_add_mic_boost(codec);
14007 if (err < 0)
14008 return err;
14009
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014010 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014011 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014012
Kailang Yangf6a92242007-12-13 16:52:54 +010014013 return 1;
14014}
14015
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014016#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14017#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014018#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14019
14020
14021/* init callback for auto-configuration model -- overriding the default init */
14022static void alc269_auto_init(struct hda_codec *codec)
14023{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014024 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014025 alc269_auto_init_multi_out(codec);
14026 alc269_auto_init_hp_out(codec);
14027 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014028 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014029 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014030}
14031
14032/*
14033 * configuration and preset
14034 */
14035static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014036 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014037 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014038 [ALC269_AMIC] = "laptop-amic",
14039 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014040 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014041 [ALC269_LIFEBOOK] = "lifebook",
14042 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014043};
14044
14045static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014046 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020014047 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014048 ALC269_AMIC),
14049 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14050 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14051 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14052 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14053 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14054 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14055 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14056 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14057 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14058 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14059 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14060 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14061 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14062 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14063 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14064 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14065 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14066 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14067 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14068 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14069 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14070 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14071 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14072 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14073 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14074 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14075 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14076 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14077 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14078 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14079 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14080 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14081 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14082 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14083 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14084 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014085 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014086 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014087 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014088 ALC269_DMIC),
14089 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14090 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014091 SND_PCI_QUIRK(0x104d, 0x9071, "SONY XTB", ALC269_DMIC),
Tony Vroon64154832008-11-06 15:08:49 +000014092 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014093 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14094 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14095 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14096 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14097 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14098 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014099 {}
14100};
14101
14102static struct alc_config_preset alc269_presets[] = {
14103 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014104 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014105 .init_verbs = { alc269_init_verbs },
14106 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14107 .dac_nids = alc269_dac_nids,
14108 .hp_nid = 0x03,
14109 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14110 .channel_mode = alc269_modes,
14111 .input_mux = &alc269_capture_source,
14112 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014113 [ALC269_QUANTA_FL1] = {
14114 .mixers = { alc269_quanta_fl1_mixer },
14115 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14116 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14117 .dac_nids = alc269_dac_nids,
14118 .hp_nid = 0x03,
14119 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14120 .channel_mode = alc269_modes,
14121 .input_mux = &alc269_capture_source,
14122 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014123 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014124 .init_hook = alc269_quanta_fl1_init_hook,
14125 },
Kailang Yang84898e82010-02-04 14:16:14 +010014126 [ALC269_AMIC] = {
14127 .mixers = { alc269_laptop_mixer },
14128 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014129 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014130 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014131 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14132 .dac_nids = alc269_dac_nids,
14133 .hp_nid = 0x03,
14134 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14135 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014136 .unsol_event = alc269_laptop_unsol_event,
14137 .setup = alc269_laptop_amic_setup,
14138 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014139 },
Kailang Yang84898e82010-02-04 14:16:14 +010014140 [ALC269_DMIC] = {
14141 .mixers = { alc269_laptop_mixer },
14142 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014143 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014144 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014145 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14146 .dac_nids = alc269_dac_nids,
14147 .hp_nid = 0x03,
14148 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14149 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014150 .unsol_event = alc269_laptop_unsol_event,
14151 .setup = alc269_laptop_dmic_setup,
14152 .init_hook = alc269_laptop_inithook,
14153 },
14154 [ALC269VB_AMIC] = {
14155 .mixers = { alc269vb_laptop_mixer },
14156 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14157 .init_verbs = { alc269vb_init_verbs,
14158 alc269vb_laptop_amic_init_verbs },
14159 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14160 .dac_nids = alc269_dac_nids,
14161 .hp_nid = 0x03,
14162 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14163 .channel_mode = alc269_modes,
14164 .unsol_event = alc269_laptop_unsol_event,
14165 .setup = alc269_laptop_amic_setup,
14166 .init_hook = alc269_laptop_inithook,
14167 },
14168 [ALC269VB_DMIC] = {
14169 .mixers = { alc269vb_laptop_mixer },
14170 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14171 .init_verbs = { alc269vb_init_verbs,
14172 alc269vb_laptop_dmic_init_verbs },
14173 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14174 .dac_nids = alc269_dac_nids,
14175 .hp_nid = 0x03,
14176 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14177 .channel_mode = alc269_modes,
14178 .unsol_event = alc269_laptop_unsol_event,
14179 .setup = alc269vb_laptop_dmic_setup,
14180 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014181 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014182 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014183 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014184 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014185 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014186 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014187 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14188 .dac_nids = alc269_dac_nids,
14189 .hp_nid = 0x03,
14190 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14191 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014192 .unsol_event = alc269_laptop_unsol_event,
14193 .setup = alc269_laptop_dmic_setup,
14194 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014195 },
Tony Vroon64154832008-11-06 15:08:49 +000014196 [ALC269_LIFEBOOK] = {
14197 .mixers = { alc269_lifebook_mixer },
14198 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14199 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14200 .dac_nids = alc269_dac_nids,
14201 .hp_nid = 0x03,
14202 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14203 .channel_mode = alc269_modes,
14204 .input_mux = &alc269_capture_source,
14205 .unsol_event = alc269_lifebook_unsol_event,
14206 .init_hook = alc269_lifebook_init_hook,
14207 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014208};
14209
14210static int patch_alc269(struct hda_codec *codec)
14211{
14212 struct alc_spec *spec;
14213 int board_config;
14214 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014215 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014216
14217 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14218 if (spec == NULL)
14219 return -ENOMEM;
14220
14221 codec->spec = spec;
14222
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020014223 alc_fix_pll_init(codec, 0x20, 0x04, 15);
14224
Kailang Yang274693f2009-12-03 10:07:50 +010014225 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
14226 kfree(codec->chip_name);
14227 codec->chip_name = kstrdup("ALC259", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010014228 if (!codec->chip_name) {
14229 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010014230 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010014231 }
Kailang Yang84898e82010-02-04 14:16:14 +010014232 is_alc269vb = 1;
Kailang Yang274693f2009-12-03 10:07:50 +010014233 }
14234
Kailang Yangf6a92242007-12-13 16:52:54 +010014235 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14236 alc269_models,
14237 alc269_cfg_tbl);
14238
14239 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014240 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14241 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014242 board_config = ALC269_AUTO;
14243 }
14244
14245 if (board_config == ALC269_AUTO) {
14246 /* automatic parse from the BIOS config */
14247 err = alc269_parse_auto_config(codec);
14248 if (err < 0) {
14249 alc_free(codec);
14250 return err;
14251 } else if (!err) {
14252 printk(KERN_INFO
14253 "hda_codec: Cannot set up configuration "
14254 "from BIOS. Using base mode...\n");
14255 board_config = ALC269_BASIC;
14256 }
14257 }
14258
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014259 err = snd_hda_attach_beep_device(codec, 0x1);
14260 if (err < 0) {
14261 alc_free(codec);
14262 return err;
14263 }
14264
Kailang Yangf6a92242007-12-13 16:52:54 +010014265 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014266 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014267
Kailang Yang84898e82010-02-04 14:16:14 +010014268 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014269 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14270 * fix the sample rate of analog I/O to 44.1kHz
14271 */
14272 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14273 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
14274 } else {
14275 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14276 spec->stream_analog_capture = &alc269_pcm_analog_capture;
14277 }
Kailang Yangf6a92242007-12-13 16:52:54 +010014278 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14279 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14280
Takashi Iwai66946352010-03-29 17:21:45 +020014281 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
14282 if (!is_alc269vb) {
14283 spec->adc_nids = alc269_adc_nids;
14284 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14285 spec->capsrc_nids = alc269_capsrc_nids;
14286 } else {
14287 spec->adc_nids = alc269vb_adc_nids;
14288 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14289 spec->capsrc_nids = alc269vb_capsrc_nids;
14290 }
Kailang Yang84898e82010-02-04 14:16:14 +010014291 }
14292
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014293 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014294 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014295 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010014296
Takashi Iwai100d5eb2009-08-10 11:55:51 +020014297 spec->vmaster_nid = 0x02;
14298
Kailang Yangf6a92242007-12-13 16:52:54 +010014299 codec->patch_ops = alc_patch_ops;
14300 if (board_config == ALC269_AUTO)
14301 spec->init_hook = alc269_auto_init;
14302#ifdef CONFIG_SND_HDA_POWER_SAVE
14303 if (!spec->loopback.amplist)
14304 spec->loopback.amplist = alc269_loopbacks;
14305#endif
14306
14307 return 0;
14308}
14309
14310/*
Kailang Yangdf694da2005-12-05 19:42:22 +010014311 * ALC861 channel source setting (2/6 channel selection for 3-stack)
14312 */
14313
14314/*
14315 * set the path ways for 2 channel output
14316 * need to set the codec line out and mic 1 pin widgets to inputs
14317 */
14318static struct hda_verb alc861_threestack_ch2_init[] = {
14319 /* set pin widget 1Ah (line in) for input */
14320 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014321 /* set pin widget 18h (mic1/2) for input, for mic also enable
14322 * the vref
14323 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014324 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14325
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014326 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14327#if 0
14328 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14329 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14330#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014331 { } /* end */
14332};
14333/*
14334 * 6ch mode
14335 * need to set the codec line out and mic 1 pin widgets to outputs
14336 */
14337static struct hda_verb alc861_threestack_ch6_init[] = {
14338 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14339 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14340 /* set pin widget 18h (mic1) for output (CLFE)*/
14341 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14342
14343 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014344 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014345
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014346 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14347#if 0
14348 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14349 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14350#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014351 { } /* end */
14352};
14353
14354static struct hda_channel_mode alc861_threestack_modes[2] = {
14355 { 2, alc861_threestack_ch2_init },
14356 { 6, alc861_threestack_ch6_init },
14357};
Takashi Iwai22309c32006-08-09 16:57:28 +020014358/* Set mic1 as input and unmute the mixer */
14359static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
14360 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14361 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14362 { } /* end */
14363};
14364/* Set mic1 as output and mute mixer */
14365static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
14366 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14367 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14368 { } /* end */
14369};
14370
14371static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
14372 { 2, alc861_uniwill_m31_ch2_init },
14373 { 4, alc861_uniwill_m31_ch4_init },
14374};
Kailang Yangdf694da2005-12-05 19:42:22 +010014375
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014376/* Set mic1 and line-in as input and unmute the mixer */
14377static struct hda_verb alc861_asus_ch2_init[] = {
14378 /* set pin widget 1Ah (line in) for input */
14379 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014380 /* set pin widget 18h (mic1/2) for input, for mic also enable
14381 * the vref
14382 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014383 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14384
14385 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14386#if 0
14387 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14388 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14389#endif
14390 { } /* end */
14391};
14392/* Set mic1 nad line-in as output and mute mixer */
14393static struct hda_verb alc861_asus_ch6_init[] = {
14394 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14395 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14396 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14397 /* set pin widget 18h (mic1) for output (CLFE)*/
14398 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14399 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14400 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
14401 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
14402
14403 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14404#if 0
14405 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14406 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14407#endif
14408 { } /* end */
14409};
14410
14411static struct hda_channel_mode alc861_asus_modes[2] = {
14412 { 2, alc861_asus_ch2_init },
14413 { 6, alc861_asus_ch6_init },
14414};
14415
Kailang Yangdf694da2005-12-05 19:42:22 +010014416/* patch-ALC861 */
14417
14418static struct snd_kcontrol_new alc861_base_mixer[] = {
14419 /* output mixer control */
14420 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14421 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14422 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14423 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14424 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14425
14426 /*Input mixer control */
14427 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14428 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14429 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14430 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14431 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14432 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14433 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14434 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14435 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14436 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014437
Kailang Yangdf694da2005-12-05 19:42:22 +010014438 { } /* end */
14439};
14440
14441static struct snd_kcontrol_new alc861_3ST_mixer[] = {
14442 /* output mixer control */
14443 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14444 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14445 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14446 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14447 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14448
14449 /* Input mixer control */
14450 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14451 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14452 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14453 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14454 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14455 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14456 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14457 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14458 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14459 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014460
Kailang Yangdf694da2005-12-05 19:42:22 +010014461 {
14462 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14463 .name = "Channel Mode",
14464 .info = alc_ch_mode_info,
14465 .get = alc_ch_mode_get,
14466 .put = alc_ch_mode_put,
14467 .private_value = ARRAY_SIZE(alc861_threestack_modes),
14468 },
14469 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014470};
14471
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014472static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014473 /* output mixer control */
14474 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14475 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14476 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014477
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014478 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014479};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014480
Takashi Iwai22309c32006-08-09 16:57:28 +020014481static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
14482 /* output mixer control */
14483 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14484 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14485 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14486 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14487 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14488
14489 /* Input mixer control */
14490 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14491 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14492 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14493 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14494 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14495 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14496 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14497 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14498 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14499 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014500
Takashi Iwai22309c32006-08-09 16:57:28 +020014501 {
14502 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14503 .name = "Channel Mode",
14504 .info = alc_ch_mode_info,
14505 .get = alc_ch_mode_get,
14506 .put = alc_ch_mode_put,
14507 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
14508 },
14509 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014510};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014511
14512static struct snd_kcontrol_new alc861_asus_mixer[] = {
14513 /* output mixer control */
14514 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14515 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14516 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14517 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14518 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14519
14520 /* Input mixer control */
14521 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14522 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14523 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14524 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14525 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14526 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14527 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14528 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14529 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014530 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
14531
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014532 {
14533 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14534 .name = "Channel Mode",
14535 .info = alc_ch_mode_info,
14536 .get = alc_ch_mode_get,
14537 .put = alc_ch_mode_put,
14538 .private_value = ARRAY_SIZE(alc861_asus_modes),
14539 },
14540 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014541};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014542
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014543/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014544static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014545 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14546 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014547 { }
14548};
14549
Kailang Yangdf694da2005-12-05 19:42:22 +010014550/*
14551 * generic initialization of ADC, input mixers and output mixers
14552 */
14553static struct hda_verb alc861_base_init_verbs[] = {
14554 /*
14555 * Unmute ADC0 and set the default input to mic-in
14556 */
14557 /* port-A for surround (rear panel) */
14558 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14559 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
14560 /* port-B for mic-in (rear panel) with vref */
14561 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14562 /* port-C for line-in (rear panel) */
14563 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14564 /* port-D for Front */
14565 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14566 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14567 /* port-E for HP out (front panel) */
14568 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14569 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014570 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014571 /* port-F for mic-in (front panel) with vref */
14572 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14573 /* port-G for CLFE (rear panel) */
14574 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14575 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14576 /* port-H for side (rear panel) */
14577 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14578 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
14579 /* CD-in */
14580 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14581 /* route front mic to ADC1*/
14582 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14583 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014584
Kailang Yangdf694da2005-12-05 19:42:22 +010014585 /* Unmute DAC0~3 & spdif out*/
14586 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14587 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14588 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14589 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14590 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014591
Kailang Yangdf694da2005-12-05 19:42:22 +010014592 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14593 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14594 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14595 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14596 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014597
Kailang Yangdf694da2005-12-05 19:42:22 +010014598 /* Unmute Stereo Mixer 15 */
14599 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14600 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14601 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014602 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014603
14604 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14605 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14606 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14607 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14608 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14609 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14610 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14611 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014612 /* hp used DAC 3 (Front) */
14613 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014614 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14615
14616 { }
14617};
14618
14619static struct hda_verb alc861_threestack_init_verbs[] = {
14620 /*
14621 * Unmute ADC0 and set the default input to mic-in
14622 */
14623 /* port-A for surround (rear panel) */
14624 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14625 /* port-B for mic-in (rear panel) with vref */
14626 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14627 /* port-C for line-in (rear panel) */
14628 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14629 /* port-D for Front */
14630 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14631 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14632 /* port-E for HP out (front panel) */
14633 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14634 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014635 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014636 /* port-F for mic-in (front panel) with vref */
14637 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14638 /* port-G for CLFE (rear panel) */
14639 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14640 /* port-H for side (rear panel) */
14641 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14642 /* CD-in */
14643 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14644 /* route front mic to ADC1*/
14645 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14646 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14647 /* Unmute DAC0~3 & spdif out*/
14648 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14649 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14650 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14651 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14652 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014653
Kailang Yangdf694da2005-12-05 19:42:22 +010014654 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14655 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14656 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14657 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14658 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014659
Kailang Yangdf694da2005-12-05 19:42:22 +010014660 /* Unmute Stereo Mixer 15 */
14661 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14662 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14663 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014664 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014665
14666 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14667 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14668 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14669 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14670 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14671 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14672 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14673 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014674 /* hp used DAC 3 (Front) */
14675 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014676 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14677 { }
14678};
Takashi Iwai22309c32006-08-09 16:57:28 +020014679
14680static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14681 /*
14682 * Unmute ADC0 and set the default input to mic-in
14683 */
14684 /* port-A for surround (rear panel) */
14685 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14686 /* port-B for mic-in (rear panel) with vref */
14687 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14688 /* port-C for line-in (rear panel) */
14689 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14690 /* port-D for Front */
14691 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14692 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14693 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014694 /* this has to be set to VREF80 */
14695 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014696 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014697 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014698 /* port-F for mic-in (front panel) with vref */
14699 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14700 /* port-G for CLFE (rear panel) */
14701 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14702 /* port-H for side (rear panel) */
14703 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14704 /* CD-in */
14705 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14706 /* route front mic to ADC1*/
14707 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14708 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14709 /* Unmute DAC0~3 & spdif out*/
14710 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14711 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14712 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14713 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14714 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014715
Takashi Iwai22309c32006-08-09 16:57:28 +020014716 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14717 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14718 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14719 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14720 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014721
Takashi Iwai22309c32006-08-09 16:57:28 +020014722 /* Unmute Stereo Mixer 15 */
14723 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14724 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14725 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014726 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014727
14728 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14729 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14730 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14731 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14732 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14733 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14734 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14735 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014736 /* hp used DAC 3 (Front) */
14737 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014738 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14739 { }
14740};
14741
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014742static struct hda_verb alc861_asus_init_verbs[] = {
14743 /*
14744 * Unmute ADC0 and set the default input to mic-in
14745 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014746 /* port-A for surround (rear panel)
14747 * according to codec#0 this is the HP jack
14748 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014749 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14750 /* route front PCM to HP */
14751 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14752 /* port-B for mic-in (rear panel) with vref */
14753 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14754 /* port-C for line-in (rear panel) */
14755 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14756 /* port-D for Front */
14757 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14758 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14759 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014760 /* this has to be set to VREF80 */
14761 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014762 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014763 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014764 /* port-F for mic-in (front panel) with vref */
14765 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14766 /* port-G for CLFE (rear panel) */
14767 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14768 /* port-H for side (rear panel) */
14769 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14770 /* CD-in */
14771 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14772 /* route front mic to ADC1*/
14773 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14774 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14775 /* Unmute DAC0~3 & spdif out*/
14776 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14777 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14778 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14779 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14780 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14781 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14782 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14783 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14784 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14785 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014786
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014787 /* Unmute Stereo Mixer 15 */
14788 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14789 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14790 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014791 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014792
14793 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14794 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14795 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14796 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14797 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14798 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14799 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14800 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014801 /* hp used DAC 3 (Front) */
14802 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014803 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14804 { }
14805};
14806
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014807/* additional init verbs for ASUS laptops */
14808static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14809 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14810 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14811 { }
14812};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014813
Kailang Yangdf694da2005-12-05 19:42:22 +010014814/*
14815 * generic initialization of ADC, input mixers and output mixers
14816 */
14817static struct hda_verb alc861_auto_init_verbs[] = {
14818 /*
14819 * Unmute ADC0 and set the default input to mic-in
14820 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014821 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014822 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014823
Kailang Yangdf694da2005-12-05 19:42:22 +010014824 /* Unmute DAC0~3 & spdif out*/
14825 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14826 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14827 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14828 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14829 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014830
Kailang Yangdf694da2005-12-05 19:42:22 +010014831 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14832 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14833 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14834 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14835 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014836
Kailang Yangdf694da2005-12-05 19:42:22 +010014837 /* Unmute Stereo Mixer 15 */
14838 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14839 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14840 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14841 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14842
Takashi Iwai1c209302009-07-22 15:17:45 +020014843 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14844 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14845 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14846 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14847 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14848 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14849 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14850 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014851
14852 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14853 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014854 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14855 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014856 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14857 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014858 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14859 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014860
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014861 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014862
14863 { }
14864};
14865
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014866static struct hda_verb alc861_toshiba_init_verbs[] = {
14867 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014868
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014869 { }
14870};
14871
14872/* toggle speaker-output according to the hp-jack state */
14873static void alc861_toshiba_automute(struct hda_codec *codec)
14874{
Wu Fengguang864f92b2009-11-18 12:38:02 +080014875 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014876
Takashi Iwai47fd8302007-08-10 17:11:07 +020014877 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14878 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14879 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14880 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014881}
14882
14883static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14884 unsigned int res)
14885{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014886 if ((res >> 26) == ALC880_HP_EVENT)
14887 alc861_toshiba_automute(codec);
14888}
14889
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014890/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014891#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14892#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14893#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14894#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14895
14896
14897#define ALC861_DIGOUT_NID 0x07
14898
14899static struct hda_channel_mode alc861_8ch_modes[1] = {
14900 { 8, NULL }
14901};
14902
14903static hda_nid_t alc861_dac_nids[4] = {
14904 /* front, surround, clfe, side */
14905 0x03, 0x06, 0x05, 0x04
14906};
14907
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014908static hda_nid_t alc660_dac_nids[3] = {
14909 /* front, clfe, surround */
14910 0x03, 0x05, 0x06
14911};
14912
Kailang Yangdf694da2005-12-05 19:42:22 +010014913static hda_nid_t alc861_adc_nids[1] = {
14914 /* ADC0-2 */
14915 0x08,
14916};
14917
14918static struct hda_input_mux alc861_capture_source = {
14919 .num_items = 5,
14920 .items = {
14921 { "Mic", 0x0 },
14922 { "Front Mic", 0x3 },
14923 { "Line", 0x1 },
14924 { "CD", 0x4 },
14925 { "Mixer", 0x5 },
14926 },
14927};
14928
Takashi Iwai1c209302009-07-22 15:17:45 +020014929static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14930{
14931 struct alc_spec *spec = codec->spec;
14932 hda_nid_t mix, srcs[5];
14933 int i, j, num;
14934
14935 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14936 return 0;
14937 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14938 if (num < 0)
14939 return 0;
14940 for (i = 0; i < num; i++) {
14941 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014942 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014943 if (type != AC_WID_AUD_OUT)
14944 continue;
14945 for (j = 0; j < spec->multiout.num_dacs; j++)
14946 if (spec->multiout.dac_nids[j] == srcs[i])
14947 break;
14948 if (j >= spec->multiout.num_dacs)
14949 return srcs[i];
14950 }
14951 return 0;
14952}
14953
Kailang Yangdf694da2005-12-05 19:42:22 +010014954/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014955static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014956 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014957{
Takashi Iwai1c209302009-07-22 15:17:45 +020014958 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014959 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014960 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014961
14962 spec->multiout.dac_nids = spec->private_dac_nids;
14963 for (i = 0; i < cfg->line_outs; i++) {
14964 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014965 dac = alc861_look_for_dac(codec, nid);
14966 if (!dac)
14967 continue;
14968 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014969 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014970 return 0;
14971}
14972
Takashi Iwai1c209302009-07-22 15:17:45 +020014973static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14974 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014975{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020014976 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020014977 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14978}
14979
14980/* add playback controls from the parsed DAC table */
14981static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14982 const struct auto_pin_cfg *cfg)
14983{
14984 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014985 static const char *chname[4] = {
14986 "Front", "Surround", NULL /*CLFE*/, "Side"
14987 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014988 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014989 int i, err;
14990
14991 if (cfg->line_outs == 1) {
14992 const char *pfx = NULL;
14993 if (!cfg->hp_outs)
14994 pfx = "Master";
14995 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14996 pfx = "Speaker";
14997 if (pfx) {
14998 nid = spec->multiout.dac_nids[0];
14999 return alc861_create_out_sw(codec, pfx, nid, 3);
15000 }
15001 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015002
15003 for (i = 0; i < cfg->line_outs; i++) {
15004 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015005 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015006 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015007 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015008 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015009 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015010 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015011 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015012 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015013 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015014 return err;
15015 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015016 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015017 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015018 return err;
15019 }
15020 }
15021 return 0;
15022}
15023
Takashi Iwai1c209302009-07-22 15:17:45 +020015024static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015025{
Takashi Iwai1c209302009-07-22 15:17:45 +020015026 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015027 int err;
15028 hda_nid_t nid;
15029
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015030 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015031 return 0;
15032
15033 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015034 nid = alc861_look_for_dac(codec, pin);
15035 if (nid) {
15036 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15037 if (err < 0)
15038 return err;
15039 spec->multiout.hp_nid = nid;
15040 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015041 }
15042 return 0;
15043}
15044
15045/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015046static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015047 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015048{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015049 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015050}
15051
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015052static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15053 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015054 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015055{
Takashi Iwai1c209302009-07-22 15:17:45 +020015056 hda_nid_t mix, srcs[5];
15057 int i, num;
15058
Jacek Luczak564c5be2008-05-03 18:41:23 +020015059 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15060 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015061 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015062 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015063 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15064 return;
15065 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15066 if (num < 0)
15067 return;
15068 for (i = 0; i < num; i++) {
15069 unsigned int mute;
15070 if (srcs[i] == dac || srcs[i] == 0x15)
15071 mute = AMP_IN_UNMUTE(i);
15072 else
15073 mute = AMP_IN_MUTE(i);
15074 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15075 mute);
15076 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015077}
15078
15079static void alc861_auto_init_multi_out(struct hda_codec *codec)
15080{
15081 struct alc_spec *spec = codec->spec;
15082 int i;
15083
15084 for (i = 0; i < spec->autocfg.line_outs; i++) {
15085 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015086 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015087 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015088 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015089 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015090 }
15091}
15092
15093static void alc861_auto_init_hp_out(struct hda_codec *codec)
15094{
15095 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015096
Takashi Iwai15870f02009-10-05 08:25:13 +020015097 if (spec->autocfg.hp_outs)
15098 alc861_auto_set_output_and_unmute(codec,
15099 spec->autocfg.hp_pins[0],
15100 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015101 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015102 if (spec->autocfg.speaker_outs)
15103 alc861_auto_set_output_and_unmute(codec,
15104 spec->autocfg.speaker_pins[0],
15105 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015106 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015107}
15108
15109static void alc861_auto_init_analog_input(struct hda_codec *codec)
15110{
15111 struct alc_spec *spec = codec->spec;
15112 int i;
15113
15114 for (i = 0; i < AUTO_PIN_LAST; i++) {
15115 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010015116 if (nid >= 0x0c && nid <= 0x11)
15117 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010015118 }
15119}
15120
15121/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015122/* return 1 if successful, 0 if the proper config is not found,
15123 * or a negative error code
15124 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015125static int alc861_parse_auto_config(struct hda_codec *codec)
15126{
15127 struct alc_spec *spec = codec->spec;
15128 int err;
15129 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15130
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015131 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15132 alc861_ignore);
15133 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015134 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015135 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015136 return 0; /* can't find valid BIOS pin config */
15137
Takashi Iwai1c209302009-07-22 15:17:45 +020015138 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015139 if (err < 0)
15140 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015141 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015142 if (err < 0)
15143 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015144 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015145 if (err < 0)
15146 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015147 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015148 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015149 return err;
15150
15151 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15152
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015153 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015154 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
15155
Takashi Iwai603c4012008-07-30 15:01:44 +020015156 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015157 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015158
Takashi Iwaid88897e2008-10-31 15:01:37 +010015159 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015160
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015161 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015162 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015163
15164 spec->adc_nids = alc861_adc_nids;
15165 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015166 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015167
Kailang Yang6227cdc2010-02-25 08:36:52 +010015168 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015169
Kailang Yangdf694da2005-12-05 19:42:22 +010015170 return 1;
15171}
15172
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015173/* additional initialization for auto-configuration model */
15174static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015175{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015176 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015177 alc861_auto_init_multi_out(codec);
15178 alc861_auto_init_hp_out(codec);
15179 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015180 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015181 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015182}
15183
Takashi Iwaicb53c622007-08-10 17:21:45 +020015184#ifdef CONFIG_SND_HDA_POWER_SAVE
15185static struct hda_amp_list alc861_loopbacks[] = {
15186 { 0x15, HDA_INPUT, 0 },
15187 { 0x15, HDA_INPUT, 1 },
15188 { 0x15, HDA_INPUT, 2 },
15189 { 0x15, HDA_INPUT, 3 },
15190 { } /* end */
15191};
15192#endif
15193
Kailang Yangdf694da2005-12-05 19:42:22 +010015194
15195/*
15196 * configuration and preset
15197 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015198static const char *alc861_models[ALC861_MODEL_LAST] = {
15199 [ALC861_3ST] = "3stack",
15200 [ALC660_3ST] = "3stack-660",
15201 [ALC861_3ST_DIG] = "3stack-dig",
15202 [ALC861_6ST_DIG] = "6stack-dig",
15203 [ALC861_UNIWILL_M31] = "uniwill-m31",
15204 [ALC861_TOSHIBA] = "toshiba",
15205 [ALC861_ASUS] = "asus",
15206 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15207 [ALC861_AUTO] = "auto",
15208};
15209
15210static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015211 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015212 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15213 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15214 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015215 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015216 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015217 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015218 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15219 * Any other models that need this preset?
15220 */
15221 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015222 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15223 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015224 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15225 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15226 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15227 /* FIXME: the below seems conflict */
15228 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15229 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15230 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015231 {}
15232};
15233
15234static struct alc_config_preset alc861_presets[] = {
15235 [ALC861_3ST] = {
15236 .mixers = { alc861_3ST_mixer },
15237 .init_verbs = { alc861_threestack_init_verbs },
15238 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15239 .dac_nids = alc861_dac_nids,
15240 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15241 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015242 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015243 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15244 .adc_nids = alc861_adc_nids,
15245 .input_mux = &alc861_capture_source,
15246 },
15247 [ALC861_3ST_DIG] = {
15248 .mixers = { alc861_base_mixer },
15249 .init_verbs = { alc861_threestack_init_verbs },
15250 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15251 .dac_nids = alc861_dac_nids,
15252 .dig_out_nid = ALC861_DIGOUT_NID,
15253 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15254 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015255 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015256 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15257 .adc_nids = alc861_adc_nids,
15258 .input_mux = &alc861_capture_source,
15259 },
15260 [ALC861_6ST_DIG] = {
15261 .mixers = { alc861_base_mixer },
15262 .init_verbs = { alc861_base_init_verbs },
15263 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15264 .dac_nids = alc861_dac_nids,
15265 .dig_out_nid = ALC861_DIGOUT_NID,
15266 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
15267 .channel_mode = alc861_8ch_modes,
15268 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15269 .adc_nids = alc861_adc_nids,
15270 .input_mux = &alc861_capture_source,
15271 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015272 [ALC660_3ST] = {
15273 .mixers = { alc861_3ST_mixer },
15274 .init_verbs = { alc861_threestack_init_verbs },
15275 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
15276 .dac_nids = alc660_dac_nids,
15277 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15278 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015279 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015280 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15281 .adc_nids = alc861_adc_nids,
15282 .input_mux = &alc861_capture_source,
15283 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015284 [ALC861_UNIWILL_M31] = {
15285 .mixers = { alc861_uniwill_m31_mixer },
15286 .init_verbs = { alc861_uniwill_m31_init_verbs },
15287 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15288 .dac_nids = alc861_dac_nids,
15289 .dig_out_nid = ALC861_DIGOUT_NID,
15290 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
15291 .channel_mode = alc861_uniwill_m31_modes,
15292 .need_dac_fix = 1,
15293 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15294 .adc_nids = alc861_adc_nids,
15295 .input_mux = &alc861_capture_source,
15296 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015297 [ALC861_TOSHIBA] = {
15298 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015299 .init_verbs = { alc861_base_init_verbs,
15300 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015301 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15302 .dac_nids = alc861_dac_nids,
15303 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15304 .channel_mode = alc883_3ST_2ch_modes,
15305 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15306 .adc_nids = alc861_adc_nids,
15307 .input_mux = &alc861_capture_source,
15308 .unsol_event = alc861_toshiba_unsol_event,
15309 .init_hook = alc861_toshiba_automute,
15310 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015311 [ALC861_ASUS] = {
15312 .mixers = { alc861_asus_mixer },
15313 .init_verbs = { alc861_asus_init_verbs },
15314 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15315 .dac_nids = alc861_dac_nids,
15316 .dig_out_nid = ALC861_DIGOUT_NID,
15317 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
15318 .channel_mode = alc861_asus_modes,
15319 .need_dac_fix = 1,
15320 .hp_nid = 0x06,
15321 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15322 .adc_nids = alc861_adc_nids,
15323 .input_mux = &alc861_capture_source,
15324 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015325 [ALC861_ASUS_LAPTOP] = {
15326 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
15327 .init_verbs = { alc861_asus_init_verbs,
15328 alc861_asus_laptop_init_verbs },
15329 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15330 .dac_nids = alc861_dac_nids,
15331 .dig_out_nid = ALC861_DIGOUT_NID,
15332 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15333 .channel_mode = alc883_3ST_2ch_modes,
15334 .need_dac_fix = 1,
15335 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15336 .adc_nids = alc861_adc_nids,
15337 .input_mux = &alc861_capture_source,
15338 },
15339};
Kailang Yangdf694da2005-12-05 19:42:22 +010015340
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015341/* Pin config fixes */
15342enum {
15343 PINFIX_FSC_AMILO_PI1505,
15344};
15345
15346static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
15347 { 0x0b, 0x0221101f }, /* HP */
15348 { 0x0f, 0x90170310 }, /* speaker */
15349 { }
15350};
15351
15352static const struct alc_fixup alc861_fixups[] = {
15353 [PINFIX_FSC_AMILO_PI1505] = {
15354 .pins = alc861_fsc_amilo_pi1505_pinfix
15355 },
15356};
15357
15358static struct snd_pci_quirk alc861_fixup_tbl[] = {
15359 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
15360 {}
15361};
Kailang Yangdf694da2005-12-05 19:42:22 +010015362
15363static int patch_alc861(struct hda_codec *codec)
15364{
15365 struct alc_spec *spec;
15366 int board_config;
15367 int err;
15368
Robert P. J. Daydc041e02006-12-19 14:44:15 +010015369 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010015370 if (spec == NULL)
15371 return -ENOMEM;
15372
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015373 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015374
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015375 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
15376 alc861_models,
15377 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015378
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015379 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015380 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15381 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010015382 board_config = ALC861_AUTO;
15383 }
15384
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015385 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups);
15386
Kailang Yangdf694da2005-12-05 19:42:22 +010015387 if (board_config == ALC861_AUTO) {
15388 /* automatic parse from the BIOS config */
15389 err = alc861_parse_auto_config(codec);
15390 if (err < 0) {
15391 alc_free(codec);
15392 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015393 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015394 printk(KERN_INFO
15395 "hda_codec: Cannot set up configuration "
15396 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010015397 board_config = ALC861_3ST_DIG;
15398 }
15399 }
15400
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015401 err = snd_hda_attach_beep_device(codec, 0x23);
15402 if (err < 0) {
15403 alc_free(codec);
15404 return err;
15405 }
15406
Kailang Yangdf694da2005-12-05 19:42:22 +010015407 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015408 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015409
Kailang Yangdf694da2005-12-05 19:42:22 +010015410 spec->stream_analog_playback = &alc861_pcm_analog_playback;
15411 spec->stream_analog_capture = &alc861_pcm_analog_capture;
15412
Kailang Yangdf694da2005-12-05 19:42:22 +010015413 spec->stream_digital_playback = &alc861_pcm_digital_playback;
15414 spec->stream_digital_capture = &alc861_pcm_digital_capture;
15415
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010015416 if (!spec->cap_mixer)
15417 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015418 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
15419
Takashi Iwai2134ea42008-01-10 16:53:55 +010015420 spec->vmaster_nid = 0x03;
15421
Kailang Yangdf694da2005-12-05 19:42:22 +010015422 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050015423 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015424 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015425#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015426 spec->power_hook = alc_power_eapd;
15427#endif
15428 }
15429#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015430 if (!spec->loopback.amplist)
15431 spec->loopback.amplist = alc861_loopbacks;
15432#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015433
Kailang Yangdf694da2005-12-05 19:42:22 +010015434 return 0;
15435}
15436
15437/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015438 * ALC861-VD support
15439 *
15440 * Based on ALC882
15441 *
15442 * In addition, an independent DAC
15443 */
15444#define ALC861VD_DIGOUT_NID 0x06
15445
15446static hda_nid_t alc861vd_dac_nids[4] = {
15447 /* front, surr, clfe, side surr */
15448 0x02, 0x03, 0x04, 0x05
15449};
15450
15451/* dac_nids for ALC660vd are in a different order - according to
15452 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015453 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015454 * of ALC660vd codecs, but for now there is only 3stack mixer
15455 * - and it is the same as in 861vd.
15456 * adc_nids in ALC660vd are (is) the same as in 861vd
15457 */
15458static hda_nid_t alc660vd_dac_nids[3] = {
15459 /* front, rear, clfe, rear_surr */
15460 0x02, 0x04, 0x03
15461};
15462
15463static hda_nid_t alc861vd_adc_nids[1] = {
15464 /* ADC0 */
15465 0x09,
15466};
15467
Takashi Iwaie1406342008-02-11 18:32:32 +010015468static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
15469
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015470/* input MUX */
15471/* FIXME: should be a matrix-type input source selection */
15472static struct hda_input_mux alc861vd_capture_source = {
15473 .num_items = 4,
15474 .items = {
15475 { "Mic", 0x0 },
15476 { "Front Mic", 0x1 },
15477 { "Line", 0x2 },
15478 { "CD", 0x4 },
15479 },
15480};
15481
Kailang Yang272a5272007-05-14 11:00:38 +020015482static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010015483 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020015484 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010015485 { "Ext Mic", 0x0 },
15486 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020015487 },
15488};
15489
Kailang Yangd1a991a2007-08-15 16:21:59 +020015490static struct hda_input_mux alc861vd_hp_capture_source = {
15491 .num_items = 2,
15492 .items = {
15493 { "Front Mic", 0x0 },
15494 { "ATAPI Mic", 0x1 },
15495 },
15496};
15497
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015498/*
15499 * 2ch mode
15500 */
15501static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
15502 { 2, NULL }
15503};
15504
15505/*
15506 * 6ch mode
15507 */
15508static struct hda_verb alc861vd_6stack_ch6_init[] = {
15509 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15510 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15511 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15512 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15513 { } /* end */
15514};
15515
15516/*
15517 * 8ch mode
15518 */
15519static struct hda_verb alc861vd_6stack_ch8_init[] = {
15520 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15521 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15522 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15523 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15524 { } /* end */
15525};
15526
15527static struct hda_channel_mode alc861vd_6stack_modes[2] = {
15528 { 6, alc861vd_6stack_ch6_init },
15529 { 8, alc861vd_6stack_ch8_init },
15530};
15531
15532static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
15533 {
15534 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15535 .name = "Channel Mode",
15536 .info = alc_ch_mode_info,
15537 .get = alc_ch_mode_get,
15538 .put = alc_ch_mode_put,
15539 },
15540 { } /* end */
15541};
15542
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015543/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15544 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15545 */
15546static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
15547 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15548 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15549
15550 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15551 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
15552
15553 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
15554 HDA_OUTPUT),
15555 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
15556 HDA_OUTPUT),
15557 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
15558 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
15559
15560 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
15561 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
15562
15563 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15564
15565 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15566 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15567 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15568
15569 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15570 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15571 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15572
15573 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15574 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15575
15576 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15577 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15578
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015579 { } /* end */
15580};
15581
15582static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
15583 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15584 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15585
15586 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15587
15588 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15589 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15590 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15591
15592 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15593 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15594 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15595
15596 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15597 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15598
15599 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15600 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15601
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015602 { } /* end */
15603};
15604
Kailang Yangbdd148a2007-05-08 15:19:08 +020015605static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
15606 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15607 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
15608 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15609
15610 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15611
15612 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15613 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15614 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15615
15616 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15617 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15618 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15619
15620 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15621 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15622
15623 { } /* end */
15624};
15625
Tobin Davisb419f342008-03-07 11:57:51 +010015626/* Pin assignment: Speaker=0x14, HP = 0x15,
15627 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015628 */
15629static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015630 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15631 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015632 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15633 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015634 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15635 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15636 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15637 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15638 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15639 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015640 { } /* end */
15641};
15642
Kailang Yangd1a991a2007-08-15 16:21:59 +020015643/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15644 * Front Mic=0x18, ATAPI Mic = 0x19,
15645 */
15646static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15647 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15648 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15649 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15650 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15651 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15652 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15653 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15654 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015655
Kailang Yangd1a991a2007-08-15 16:21:59 +020015656 { } /* end */
15657};
15658
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015659/*
15660 * generic initialization of ADC, input mixers and output mixers
15661 */
15662static struct hda_verb alc861vd_volume_init_verbs[] = {
15663 /*
15664 * Unmute ADC0 and set the default input to mic-in
15665 */
15666 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15667 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15668
15669 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15670 * the analog-loopback mixer widget
15671 */
15672 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015673 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15674 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15675 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15676 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15677 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015678
15679 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015680 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15681 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15682 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015683 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015684
15685 /*
15686 * Set up output mixers (0x02 - 0x05)
15687 */
15688 /* set vol=0 to output mixers */
15689 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15690 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15691 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15692 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15693
15694 /* set up input amps for analog loopback */
15695 /* Amp Indices: DAC = 0, mixer = 1 */
15696 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15697 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15698 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15699 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15700 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15701 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15702 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15703 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15704
15705 { }
15706};
15707
15708/*
15709 * 3-stack pin configuration:
15710 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15711 */
15712static struct hda_verb alc861vd_3stack_init_verbs[] = {
15713 /*
15714 * Set pin mode and muting
15715 */
15716 /* set front pin widgets 0x14 for output */
15717 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15718 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15719 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15720
15721 /* Mic (rear) pin: input vref at 80% */
15722 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15723 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15724 /* Front Mic pin: input vref at 80% */
15725 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15726 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15727 /* Line In pin: input */
15728 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15729 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15730 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15731 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15732 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15733 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15734 /* CD pin widget for input */
15735 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15736
15737 { }
15738};
15739
15740/*
15741 * 6-stack pin configuration:
15742 */
15743static struct hda_verb alc861vd_6stack_init_verbs[] = {
15744 /*
15745 * Set pin mode and muting
15746 */
15747 /* set front pin widgets 0x14 for output */
15748 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15749 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15750 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15751
15752 /* Rear Pin: output 1 (0x0d) */
15753 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15754 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15755 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15756 /* CLFE Pin: output 2 (0x0e) */
15757 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15758 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15759 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15760 /* Side Pin: output 3 (0x0f) */
15761 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15762 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15763 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15764
15765 /* Mic (rear) pin: input vref at 80% */
15766 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15767 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15768 /* Front Mic pin: input vref at 80% */
15769 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15770 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15771 /* Line In pin: input */
15772 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15773 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15774 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15775 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15776 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15777 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15778 /* CD pin widget for input */
15779 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15780
15781 { }
15782};
15783
Kailang Yangbdd148a2007-05-08 15:19:08 +020015784static struct hda_verb alc861vd_eapd_verbs[] = {
15785 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15786 { }
15787};
15788
Kailang Yangf9423e72008-05-27 12:32:25 +020015789static struct hda_verb alc660vd_eapd_verbs[] = {
15790 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15791 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15792 { }
15793};
15794
Kailang Yangbdd148a2007-05-08 15:19:08 +020015795static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15796 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15797 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15798 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15799 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015800 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015801 {}
15802};
15803
Kailang Yangbdd148a2007-05-08 15:19:08 +020015804static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15805{
15806 unsigned int present;
15807 unsigned char bits;
15808
Wu Fengguang864f92b2009-11-18 12:38:02 +080015809 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020015810 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080015811
Takashi Iwai47fd8302007-08-10 17:11:07 +020015812 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15813 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015814}
15815
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015816static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015817{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015818 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015819 spec->autocfg.hp_pins[0] = 0x1b;
15820 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015821}
15822
15823static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15824{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015825 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015826 alc861vd_lenovo_mic_automute(codec);
15827}
15828
15829static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15830 unsigned int res)
15831{
15832 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015833 case ALC880_MIC_EVENT:
15834 alc861vd_lenovo_mic_automute(codec);
15835 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015836 default:
15837 alc_automute_amp_unsol_event(codec, res);
15838 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015839 }
15840}
15841
Kailang Yang272a5272007-05-14 11:00:38 +020015842static struct hda_verb alc861vd_dallas_verbs[] = {
15843 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15844 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15845 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15846 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15847
15848 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15849 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15850 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15851 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15852 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15853 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15854 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15855 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015856
Kailang Yang272a5272007-05-14 11:00:38 +020015857 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15858 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15859 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15860 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15861 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15862 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15863 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15864 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15865
15866 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15867 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15868 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15869 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15870 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15871 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15872 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15873 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15874
15875 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15876 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15877 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15878 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15879
15880 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015881 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015882 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15883
15884 { } /* end */
15885};
15886
15887/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015888static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015889{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015890 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015891
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015892 spec->autocfg.hp_pins[0] = 0x15;
15893 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015894}
15895
Takashi Iwaicb53c622007-08-10 17:21:45 +020015896#ifdef CONFIG_SND_HDA_POWER_SAVE
15897#define alc861vd_loopbacks alc880_loopbacks
15898#endif
15899
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015900/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015901#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15902#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15903#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15904#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15905
15906/*
15907 * configuration and preset
15908 */
15909static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15910 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015911 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015912 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015913 [ALC861VD_3ST] = "3stack",
15914 [ALC861VD_3ST_DIG] = "3stack-digout",
15915 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015916 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015917 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015918 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015919 [ALC861VD_AUTO] = "auto",
15920};
15921
15922static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015923 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15924 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015925 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015926 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015927 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015928 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015929 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015930 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015931 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015932 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015933 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015934 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015935 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015936 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015937 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015938 {}
15939};
15940
15941static struct alc_config_preset alc861vd_presets[] = {
15942 [ALC660VD_3ST] = {
15943 .mixers = { alc861vd_3st_mixer },
15944 .init_verbs = { alc861vd_volume_init_verbs,
15945 alc861vd_3stack_init_verbs },
15946 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15947 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015948 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15949 .channel_mode = alc861vd_3stack_2ch_modes,
15950 .input_mux = &alc861vd_capture_source,
15951 },
Mike Crash6963f842007-06-25 12:12:51 +020015952 [ALC660VD_3ST_DIG] = {
15953 .mixers = { alc861vd_3st_mixer },
15954 .init_verbs = { alc861vd_volume_init_verbs,
15955 alc861vd_3stack_init_verbs },
15956 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15957 .dac_nids = alc660vd_dac_nids,
15958 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015959 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15960 .channel_mode = alc861vd_3stack_2ch_modes,
15961 .input_mux = &alc861vd_capture_source,
15962 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015963 [ALC861VD_3ST] = {
15964 .mixers = { alc861vd_3st_mixer },
15965 .init_verbs = { alc861vd_volume_init_verbs,
15966 alc861vd_3stack_init_verbs },
15967 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15968 .dac_nids = alc861vd_dac_nids,
15969 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15970 .channel_mode = alc861vd_3stack_2ch_modes,
15971 .input_mux = &alc861vd_capture_source,
15972 },
15973 [ALC861VD_3ST_DIG] = {
15974 .mixers = { alc861vd_3st_mixer },
15975 .init_verbs = { alc861vd_volume_init_verbs,
15976 alc861vd_3stack_init_verbs },
15977 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15978 .dac_nids = alc861vd_dac_nids,
15979 .dig_out_nid = ALC861VD_DIGOUT_NID,
15980 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15981 .channel_mode = alc861vd_3stack_2ch_modes,
15982 .input_mux = &alc861vd_capture_source,
15983 },
15984 [ALC861VD_6ST_DIG] = {
15985 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15986 .init_verbs = { alc861vd_volume_init_verbs,
15987 alc861vd_6stack_init_verbs },
15988 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15989 .dac_nids = alc861vd_dac_nids,
15990 .dig_out_nid = ALC861VD_DIGOUT_NID,
15991 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15992 .channel_mode = alc861vd_6stack_modes,
15993 .input_mux = &alc861vd_capture_source,
15994 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015995 [ALC861VD_LENOVO] = {
15996 .mixers = { alc861vd_lenovo_mixer },
15997 .init_verbs = { alc861vd_volume_init_verbs,
15998 alc861vd_3stack_init_verbs,
15999 alc861vd_eapd_verbs,
16000 alc861vd_lenovo_unsol_verbs },
16001 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16002 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016003 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16004 .channel_mode = alc861vd_3stack_2ch_modes,
16005 .input_mux = &alc861vd_capture_source,
16006 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016007 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016008 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016009 },
Kailang Yang272a5272007-05-14 11:00:38 +020016010 [ALC861VD_DALLAS] = {
16011 .mixers = { alc861vd_dallas_mixer },
16012 .init_verbs = { alc861vd_dallas_verbs },
16013 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16014 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016015 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16016 .channel_mode = alc861vd_3stack_2ch_modes,
16017 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016018 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016019 .setup = alc861vd_dallas_setup,
16020 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016021 },
16022 [ALC861VD_HP] = {
16023 .mixers = { alc861vd_hp_mixer },
16024 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16025 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16026 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016027 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016028 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16029 .channel_mode = alc861vd_3stack_2ch_modes,
16030 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016031 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016032 .setup = alc861vd_dallas_setup,
16033 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016034 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016035 [ALC660VD_ASUS_V1S] = {
16036 .mixers = { alc861vd_lenovo_mixer },
16037 .init_verbs = { alc861vd_volume_init_verbs,
16038 alc861vd_3stack_init_verbs,
16039 alc861vd_eapd_verbs,
16040 alc861vd_lenovo_unsol_verbs },
16041 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16042 .dac_nids = alc660vd_dac_nids,
16043 .dig_out_nid = ALC861VD_DIGOUT_NID,
16044 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16045 .channel_mode = alc861vd_3stack_2ch_modes,
16046 .input_mux = &alc861vd_capture_source,
16047 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016048 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016049 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016050 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016051};
16052
16053/*
16054 * BIOS auto configuration
16055 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016056static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16057 const struct auto_pin_cfg *cfg)
16058{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016059 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016060}
16061
16062
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016063static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16064 hda_nid_t nid, int pin_type, int dac_idx)
16065{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016066 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016067}
16068
16069static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16070{
16071 struct alc_spec *spec = codec->spec;
16072 int i;
16073
16074 for (i = 0; i <= HDA_SIDE; i++) {
16075 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016076 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016077 if (nid)
16078 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016079 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016080 }
16081}
16082
16083
16084static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16085{
16086 struct alc_spec *spec = codec->spec;
16087 hda_nid_t pin;
16088
16089 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016090 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016091 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016092 pin = spec->autocfg.speaker_pins[0];
16093 if (pin)
16094 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016095}
16096
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016097#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16098
16099static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16100{
16101 struct alc_spec *spec = codec->spec;
16102 int i;
16103
16104 for (i = 0; i < AUTO_PIN_LAST; i++) {
16105 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020016106 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016107 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016108 if (nid != ALC861VD_PIN_CD_NID &&
16109 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016110 snd_hda_codec_write(codec, nid, 0,
16111 AC_VERB_SET_AMP_GAIN_MUTE,
16112 AMP_OUT_MUTE);
16113 }
16114 }
16115}
16116
Takashi Iwaif511b012008-08-15 16:46:42 +020016117#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16118
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016119#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16120#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16121
16122/* add playback controls from the parsed DAC table */
16123/* Based on ALC880 version. But ALC861VD has separate,
16124 * different NIDs for mute/unmute switch and volume control */
16125static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16126 const struct auto_pin_cfg *cfg)
16127{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016128 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16129 hda_nid_t nid_v, nid_s;
16130 int i, err;
16131
16132 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016133 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016134 continue;
16135 nid_v = alc861vd_idx_to_mixer_vol(
16136 alc880_dac_to_idx(
16137 spec->multiout.dac_nids[i]));
16138 nid_s = alc861vd_idx_to_mixer_switch(
16139 alc880_dac_to_idx(
16140 spec->multiout.dac_nids[i]));
16141
16142 if (i == 2) {
16143 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016144 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16145 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016146 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16147 HDA_OUTPUT));
16148 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016149 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016150 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16151 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016152 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16153 HDA_OUTPUT));
16154 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016155 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016156 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16157 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016158 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16159 HDA_INPUT));
16160 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016161 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016162 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16163 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016164 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16165 HDA_INPUT));
16166 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016167 return err;
16168 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016169 const char *pfx;
16170 if (cfg->line_outs == 1 &&
16171 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16172 if (!cfg->hp_pins)
16173 pfx = "Speaker";
16174 else
16175 pfx = "PCM";
16176 } else
16177 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016178 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016179 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16180 HDA_OUTPUT));
16181 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016182 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016183 if (cfg->line_outs == 1 &&
16184 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16185 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016186 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016187 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016188 HDA_INPUT));
16189 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016190 return err;
16191 }
16192 }
16193 return 0;
16194}
16195
16196/* add playback controls for speaker and HP outputs */
16197/* Based on ALC880 version. But ALC861VD has separate,
16198 * different NIDs for mute/unmute switch and volume control */
16199static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16200 hda_nid_t pin, const char *pfx)
16201{
16202 hda_nid_t nid_v, nid_s;
16203 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016204
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016205 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016206 return 0;
16207
16208 if (alc880_is_fixed_pin(pin)) {
16209 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16210 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016211 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016212 spec->multiout.hp_nid = nid_v;
16213 else
16214 spec->multiout.extra_out_nid[0] = nid_v;
16215 /* control HP volume/switch on the output mixer amp */
16216 nid_v = alc861vd_idx_to_mixer_vol(
16217 alc880_fixed_pin_idx(pin));
16218 nid_s = alc861vd_idx_to_mixer_switch(
16219 alc880_fixed_pin_idx(pin));
16220
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016221 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016222 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16223 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016224 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016225 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016226 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16227 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016228 return err;
16229 } else if (alc880_is_multi_pin(pin)) {
16230 /* set manual connection */
16231 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016232 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016233 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16234 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016235 return err;
16236 }
16237 return 0;
16238}
16239
16240/* parse the BIOS configuration and set up the alc_spec
16241 * return 1 if successful, 0 if the proper config is not found,
16242 * or a negative error code
16243 * Based on ALC880 version - had to change it to override
16244 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16245static int alc861vd_parse_auto_config(struct hda_codec *codec)
16246{
16247 struct alc_spec *spec = codec->spec;
16248 int err;
16249 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16250
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016251 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16252 alc861vd_ignore);
16253 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016254 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016255 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016256 return 0; /* can't find valid BIOS pin config */
16257
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016258 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16259 if (err < 0)
16260 return err;
16261 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
16262 if (err < 0)
16263 return err;
16264 err = alc861vd_auto_create_extra_out(spec,
16265 spec->autocfg.speaker_pins[0],
16266 "Speaker");
16267 if (err < 0)
16268 return err;
16269 err = alc861vd_auto_create_extra_out(spec,
16270 spec->autocfg.hp_pins[0],
16271 "Headphone");
16272 if (err < 0)
16273 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016274 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016275 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016276 return err;
16277
16278 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16279
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016280 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016281 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
16282
Takashi Iwai603c4012008-07-30 15:01:44 +020016283 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016284 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016285
Takashi Iwaid88897e2008-10-31 15:01:37 +010016286 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016287
16288 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016289 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016290
Takashi Iwai776e1842007-08-29 15:07:11 +020016291 err = alc_auto_add_mic_boost(codec);
16292 if (err < 0)
16293 return err;
16294
Kailang Yang6227cdc2010-02-25 08:36:52 +010016295 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016296
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016297 return 1;
16298}
16299
16300/* additional initialization for auto-configuration model */
16301static void alc861vd_auto_init(struct hda_codec *codec)
16302{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016303 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016304 alc861vd_auto_init_multi_out(codec);
16305 alc861vd_auto_init_hp_out(codec);
16306 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016307 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016308 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016309 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016310}
16311
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016312enum {
16313 ALC660VD_FIX_ASUS_GPIO1
16314};
16315
16316/* reset GPIO1 */
16317static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
16318 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
16319 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
16320 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
16321 { }
16322};
16323
16324static const struct alc_fixup alc861vd_fixups[] = {
16325 [ALC660VD_FIX_ASUS_GPIO1] = {
16326 .verbs = alc660vd_fix_asus_gpio1_verbs,
16327 },
16328};
16329
16330static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
16331 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
16332 {}
16333};
16334
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016335static int patch_alc861vd(struct hda_codec *codec)
16336{
16337 struct alc_spec *spec;
16338 int err, board_config;
16339
16340 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16341 if (spec == NULL)
16342 return -ENOMEM;
16343
16344 codec->spec = spec;
16345
16346 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
16347 alc861vd_models,
16348 alc861vd_cfg_tbl);
16349
16350 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016351 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16352 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016353 board_config = ALC861VD_AUTO;
16354 }
16355
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016356 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
16357
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016358 if (board_config == ALC861VD_AUTO) {
16359 /* automatic parse from the BIOS config */
16360 err = alc861vd_parse_auto_config(codec);
16361 if (err < 0) {
16362 alc_free(codec);
16363 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016364 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016365 printk(KERN_INFO
16366 "hda_codec: Cannot set up configuration "
16367 "from BIOS. Using base mode...\n");
16368 board_config = ALC861VD_3ST;
16369 }
16370 }
16371
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016372 err = snd_hda_attach_beep_device(codec, 0x23);
16373 if (err < 0) {
16374 alc_free(codec);
16375 return err;
16376 }
16377
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016378 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016379 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016380
Kailang Yang2f893282008-05-27 12:14:47 +020016381 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020016382 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010016383 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020016384 }
16385
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016386 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
16387 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
16388
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016389 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
16390 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16391
Takashi Iwaidd704692009-08-11 08:45:11 +020016392 if (!spec->adc_nids) {
16393 spec->adc_nids = alc861vd_adc_nids;
16394 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
16395 }
16396 if (!spec->capsrc_nids)
16397 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016398
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016399 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016400 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016401
Takashi Iwai2134ea42008-01-10 16:53:55 +010016402 spec->vmaster_nid = 0x02;
16403
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016404 codec->patch_ops = alc_patch_ops;
16405
16406 if (board_config == ALC861VD_AUTO)
16407 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016408#ifdef CONFIG_SND_HDA_POWER_SAVE
16409 if (!spec->loopback.amplist)
16410 spec->loopback.amplist = alc861vd_loopbacks;
16411#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016412
16413 return 0;
16414}
16415
16416/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016417 * ALC662 support
16418 *
16419 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
16420 * configuration. Each pin widget can choose any input DACs and a mixer.
16421 * Each ADC is connected from a mixer of all inputs. This makes possible
16422 * 6-channel independent captures.
16423 *
16424 * In addition, an independent DAC for the multi-playback (not used in this
16425 * driver yet).
16426 */
16427#define ALC662_DIGOUT_NID 0x06
16428#define ALC662_DIGIN_NID 0x0a
16429
16430static hda_nid_t alc662_dac_nids[4] = {
16431 /* front, rear, clfe, rear_surr */
16432 0x02, 0x03, 0x04
16433};
16434
Kailang Yang622e84c2009-04-21 07:39:04 +020016435static hda_nid_t alc272_dac_nids[2] = {
16436 0x02, 0x03
16437};
16438
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016439static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016440 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016441 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016442};
Takashi Iwaie1406342008-02-11 18:32:32 +010016443
Kailang Yang622e84c2009-04-21 07:39:04 +020016444static hda_nid_t alc272_adc_nids[1] = {
16445 /* ADC1-2 */
16446 0x08,
16447};
16448
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016449static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016450static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
16451
Takashi Iwaie1406342008-02-11 18:32:32 +010016452
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016453/* input MUX */
16454/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016455static struct hda_input_mux alc662_capture_source = {
16456 .num_items = 4,
16457 .items = {
16458 { "Mic", 0x0 },
16459 { "Front Mic", 0x1 },
16460 { "Line", 0x2 },
16461 { "CD", 0x4 },
16462 },
16463};
16464
16465static struct hda_input_mux alc662_lenovo_101e_capture_source = {
16466 .num_items = 2,
16467 .items = {
16468 { "Mic", 0x1 },
16469 { "Line", 0x2 },
16470 },
16471};
Kailang Yang291702f2007-10-16 14:28:03 +020016472
Kailang Yang6dda9f42008-05-27 12:05:31 +020016473static struct hda_input_mux alc663_capture_source = {
16474 .num_items = 3,
16475 .items = {
16476 { "Mic", 0x0 },
16477 { "Front Mic", 0x1 },
16478 { "Line", 0x2 },
16479 },
16480};
16481
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016482#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020016483static struct hda_input_mux alc272_nc10_capture_source = {
16484 .num_items = 16,
16485 .items = {
16486 { "Autoselect Mic", 0x0 },
16487 { "Internal Mic", 0x1 },
16488 { "In-0x02", 0x2 },
16489 { "In-0x03", 0x3 },
16490 { "In-0x04", 0x4 },
16491 { "In-0x05", 0x5 },
16492 { "In-0x06", 0x6 },
16493 { "In-0x07", 0x7 },
16494 { "In-0x08", 0x8 },
16495 { "In-0x09", 0x9 },
16496 { "In-0x0a", 0x0a },
16497 { "In-0x0b", 0x0b },
16498 { "In-0x0c", 0x0c },
16499 { "In-0x0d", 0x0d },
16500 { "In-0x0e", 0x0e },
16501 { "In-0x0f", 0x0f },
16502 },
16503};
16504#endif
16505
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016506/*
16507 * 2ch mode
16508 */
16509static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
16510 { 2, NULL }
16511};
16512
16513/*
16514 * 2ch mode
16515 */
16516static struct hda_verb alc662_3ST_ch2_init[] = {
16517 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
16518 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16519 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
16520 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16521 { } /* end */
16522};
16523
16524/*
16525 * 6ch mode
16526 */
16527static struct hda_verb alc662_3ST_ch6_init[] = {
16528 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16529 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16530 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
16531 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16532 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16533 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
16534 { } /* end */
16535};
16536
16537static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
16538 { 2, alc662_3ST_ch2_init },
16539 { 6, alc662_3ST_ch6_init },
16540};
16541
16542/*
16543 * 2ch mode
16544 */
16545static struct hda_verb alc662_sixstack_ch6_init[] = {
16546 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16547 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16548 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16549 { } /* end */
16550};
16551
16552/*
16553 * 6ch mode
16554 */
16555static struct hda_verb alc662_sixstack_ch8_init[] = {
16556 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16557 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16558 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16559 { } /* end */
16560};
16561
16562static struct hda_channel_mode alc662_5stack_modes[2] = {
16563 { 2, alc662_sixstack_ch6_init },
16564 { 6, alc662_sixstack_ch8_init },
16565};
16566
16567/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16568 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16569 */
16570
16571static struct snd_kcontrol_new alc662_base_mixer[] = {
16572 /* output mixer control */
16573 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016574 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016575 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016576 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016577 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16578 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016579 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16580 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016581 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16582
16583 /*Input mixer control */
16584 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
16585 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
16586 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
16587 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
16588 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
16589 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
16590 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
16591 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016592 { } /* end */
16593};
16594
16595static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
16596 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016597 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016598 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16599 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16600 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16601 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16602 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16603 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16605 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16606 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016607 { } /* end */
16608};
16609
16610static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
16611 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016612 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016613 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016614 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016615 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16616 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016617 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16618 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016619 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16620 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16621 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16622 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16623 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16624 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16625 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16626 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16627 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016628 { } /* end */
16629};
16630
16631static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16632 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16633 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016634 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16635 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016636 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16637 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16638 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16639 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16640 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016641 { } /* end */
16642};
16643
Kailang Yang291702f2007-10-16 14:28:03 +020016644static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016645 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16646 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016647
16648 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16649 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16650 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16651
16652 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16653 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16654 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16655 { } /* end */
16656};
16657
Kailang Yang8c427222008-01-10 13:03:59 +010016658static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016659 ALC262_HIPPO_MASTER_SWITCH,
16660 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016661 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016662 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16663 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016664 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16665 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16666 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16668 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16669 { } /* end */
16670};
16671
Kailang Yangf1d4e282008-08-26 14:03:29 +020016672static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16673 .ops = &snd_hda_bind_vol,
16674 .values = {
16675 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16676 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16677 0
16678 },
16679};
16680
16681static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16682 .ops = &snd_hda_bind_sw,
16683 .values = {
16684 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16685 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16686 0
16687 },
16688};
16689
Kailang Yang6dda9f42008-05-27 12:05:31 +020016690static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016691 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16692 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16693 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16694 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16695 { } /* end */
16696};
16697
16698static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16699 .ops = &snd_hda_bind_sw,
16700 .values = {
16701 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16702 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16703 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16704 0
16705 },
16706};
16707
16708static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16709 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16710 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16711 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16712 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16713 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16714 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16715
16716 { } /* end */
16717};
16718
16719static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16720 .ops = &snd_hda_bind_sw,
16721 .values = {
16722 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16723 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16724 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16725 0
16726 },
16727};
16728
16729static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16730 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16731 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16732 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16733 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16734 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16735 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16736 { } /* end */
16737};
16738
16739static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016740 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16741 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016742 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16743 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16744 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16745 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16746 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16747 { } /* end */
16748};
16749
16750static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16751 .ops = &snd_hda_bind_vol,
16752 .values = {
16753 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16754 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16755 0
16756 },
16757};
16758
16759static struct hda_bind_ctls alc663_asus_two_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(0x16, 3, 0, HDA_OUTPUT),
16764 0
16765 },
16766};
16767
16768static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16769 HDA_BIND_VOL("Master Playback Volume",
16770 &alc663_asus_two_bind_master_vol),
16771 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16772 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016773 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16774 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16775 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016776 { } /* end */
16777};
16778
16779static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16780 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16781 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16782 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16783 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16784 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16785 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016786 { } /* end */
16787};
16788
16789static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16790 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16791 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16792 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16793 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16794 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16795
16796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16797 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16798 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16799 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16800 { } /* end */
16801};
16802
16803static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16804 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16805 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16806 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16807
16808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16809 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16810 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16811 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16812 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16813 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16814 { } /* end */
16815};
16816
Kailang Yangebb83ee2009-12-17 12:23:00 +010016817static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
16818 .ops = &snd_hda_bind_sw,
16819 .values = {
16820 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16821 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16822 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16823 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16824 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16825 0
16826 },
16827};
16828
16829static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
16830 .ops = &snd_hda_bind_sw,
16831 .values = {
16832 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16833 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16834 0
16835 },
16836};
16837
16838static struct snd_kcontrol_new alc663_mode7_mixer[] = {
16839 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16840 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16841 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16842 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16843 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16844 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16845 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16846 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16847 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16848 { } /* end */
16849};
16850
16851static struct snd_kcontrol_new alc663_mode8_mixer[] = {
16852 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16853 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16854 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16855 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16856 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16857 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16858 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16859 { } /* end */
16860};
16861
16862
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016863static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16864 {
16865 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16866 .name = "Channel Mode",
16867 .info = alc_ch_mode_info,
16868 .get = alc_ch_mode_get,
16869 .put = alc_ch_mode_put,
16870 },
16871 { } /* end */
16872};
16873
16874static struct hda_verb alc662_init_verbs[] = {
16875 /* ADC: mute amp left and right */
16876 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16877 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016878
Kailang Yangb60dd392007-09-20 12:50:29 +020016879 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16880 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16881 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16882 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16883 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16884 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016885
16886 /* Front Pin: output 0 (0x0c) */
16887 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16888 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16889
16890 /* Rear Pin: output 1 (0x0d) */
16891 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16892 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16893
16894 /* CLFE Pin: output 2 (0x0e) */
16895 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16896 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16897
16898 /* Mic (rear) pin: input vref at 80% */
16899 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16900 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16901 /* Front Mic pin: input vref at 80% */
16902 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16903 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16904 /* Line In pin: input */
16905 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16906 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16907 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16908 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16909 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16910 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16911 /* CD pin widget for input */
16912 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16913
16914 /* FIXME: use matrix-type input source selection */
16915 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16916 /* Input mixer */
16917 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016918 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016919
16920 /* always trun on EAPD */
16921 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16922 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16923
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016924 { }
16925};
16926
Kailang Yangcec27c82010-02-04 14:18:18 +010016927static struct hda_verb alc663_init_verbs[] = {
16928 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16929 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16930 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16931 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16932 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16933 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16934 { }
16935};
16936
16937static struct hda_verb alc272_init_verbs[] = {
16938 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16939 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16940 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16941 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16942 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16943 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16944 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16945 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16946 { }
16947};
16948
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016949static struct hda_verb alc662_sue_init_verbs[] = {
16950 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16951 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016952 {}
16953};
16954
16955static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16956 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16957 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16958 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016959};
16960
Kailang Yang8c427222008-01-10 13:03:59 +010016961/* Set Unsolicited Event*/
16962static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16963 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16964 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16965 {}
16966};
16967
Kailang Yang6dda9f42008-05-27 12:05:31 +020016968static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016969 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16970 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016971 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16972 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016973 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16974 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16975 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016976 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16977 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16978 {}
16979};
16980
Kailang Yangf1d4e282008-08-26 14:03:29 +020016981static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16982 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16983 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16984 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16985 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16986 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16987 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16988 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16989 {}
16990};
16991
16992static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16993 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16994 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16995 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16996 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16997 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16998 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16999 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17000 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17001 {}
17002};
17003
17004static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17005 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17006 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17007 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17008 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17009 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17010 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17011 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17012 {}
17013};
17014
17015static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17016 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17017 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17018 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17019 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17020 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17021 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17022 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17023 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17024 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17025 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17026 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17027 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17028 {}
17029};
17030
17031static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17032 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17033 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17034 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17035 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17036 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17037 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17038 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17039 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17040 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17041 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17042 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17043 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17044 {}
17045};
17046
Kailang Yang6dda9f42008-05-27 12:05:31 +020017047static struct hda_verb alc663_g71v_init_verbs[] = {
17048 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17049 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17050 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17051
17052 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17053 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17054 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17055
17056 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17057 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17058 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17059 {}
17060};
17061
17062static struct hda_verb alc663_g50v_init_verbs[] = {
17063 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17064 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17065 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17066
17067 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17068 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17069 {}
17070};
17071
Kailang Yangf1d4e282008-08-26 14:03:29 +020017072static struct hda_verb alc662_ecs_init_verbs[] = {
17073 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17074 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17075 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17076 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17077 {}
17078};
17079
Kailang Yang622e84c2009-04-21 07:39:04 +020017080static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17081 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17082 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17083 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17084 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17085 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17086 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17087 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17090 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17091 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17092 {}
17093};
17094
17095static struct hda_verb alc272_dell_init_verbs[] = {
17096 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17097 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17098 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17099 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17100 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17101 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17102 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17103 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17104 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17105 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17106 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17107 {}
17108};
17109
Kailang Yangebb83ee2009-12-17 12:23:00 +010017110static struct hda_verb alc663_mode7_init_verbs[] = {
17111 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17112 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17113 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17114 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17115 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17116 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17117 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17118 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17119 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17120 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17121 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17122 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17123 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17124 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17125 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17126 {}
17127};
17128
17129static struct hda_verb alc663_mode8_init_verbs[] = {
17130 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17131 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17132 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17133 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17134 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17135 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17136 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17137 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17138 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17139 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17140 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17141 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17142 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17143 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17144 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17145 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17146 {}
17147};
17148
Kailang Yangf1d4e282008-08-26 14:03:29 +020017149static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17150 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17151 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17152 { } /* end */
17153};
17154
Kailang Yang622e84c2009-04-21 07:39:04 +020017155static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17156 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17157 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17158 { } /* end */
17159};
17160
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017161static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17162{
17163 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017164 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017165
Wu Fengguang864f92b2009-11-18 12:38:02 +080017166 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017167 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017168
Takashi Iwai47fd8302007-08-10 17:11:07 +020017169 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17170 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017171}
17172
17173static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17174{
17175 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017176 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017177
Wu Fengguang864f92b2009-11-18 12:38:02 +080017178 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017179 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017180
Takashi Iwai47fd8302007-08-10 17:11:07 +020017181 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17182 HDA_AMP_MUTE, bits);
17183 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17184 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017185}
17186
17187static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17188 unsigned int res)
17189{
17190 if ((res >> 26) == ALC880_HP_EVENT)
17191 alc662_lenovo_101e_all_automute(codec);
17192 if ((res >> 26) == ALC880_FRONT_EVENT)
17193 alc662_lenovo_101e_ispeaker_automute(codec);
17194}
17195
Kailang Yang291702f2007-10-16 14:28:03 +020017196/* unsolicited event for HP jack sensing */
17197static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17198 unsigned int res)
17199{
Kailang Yang291702f2007-10-16 14:28:03 +020017200 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017201 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017202 else
17203 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017204}
17205
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017206static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017207{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017208 struct alc_spec *spec = codec->spec;
17209
17210 alc262_hippo1_setup(codec);
17211 spec->ext_mic.pin = 0x18;
17212 spec->ext_mic.mux_idx = 0;
17213 spec->int_mic.pin = 0x19;
17214 spec->int_mic.mux_idx = 1;
17215 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017216}
17217
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017218static void alc662_eeepc_inithook(struct hda_codec *codec)
17219{
17220 alc262_hippo_automute(codec);
17221 alc_mic_automute(codec);
17222}
17223
17224static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017225{
Takashi Iwai42171c12009-05-08 14:11:43 +020017226 struct alc_spec *spec = codec->spec;
17227
17228 spec->autocfg.hp_pins[0] = 0x14;
17229 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017230}
17231
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017232#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17233
Kailang Yang6dda9f42008-05-27 12:05:31 +020017234static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17235{
17236 unsigned int present;
17237 unsigned char bits;
17238
Wu Fengguang864f92b2009-11-18 12:38:02 +080017239 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017240 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017241 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017242 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017243 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017244 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017245}
17246
17247static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17248{
17249 unsigned int present;
17250 unsigned char bits;
17251
Wu Fengguang864f92b2009-11-18 12:38:02 +080017252 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017253 bits = present ? HDA_AMP_MUTE : 0;
17254 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017255 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017256 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017257 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017258 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017259 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017260 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017261 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017262}
17263
17264static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
17265{
17266 unsigned int present;
17267 unsigned char bits;
17268
Wu Fengguang864f92b2009-11-18 12:38:02 +080017269 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017270 bits = present ? HDA_AMP_MUTE : 0;
17271 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017272 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017273 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017274 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017275 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017276 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017277 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017278 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017279}
17280
17281static void alc662_f5z_speaker_automute(struct hda_codec *codec)
17282{
17283 unsigned int present;
17284 unsigned char bits;
17285
Wu Fengguang864f92b2009-11-18 12:38:02 +080017286 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017287 bits = present ? 0 : PIN_OUT;
17288 snd_hda_codec_write(codec, 0x14, 0,
17289 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
17290}
17291
17292static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
17293{
17294 unsigned int present1, present2;
17295
Wu Fengguang864f92b2009-11-18 12:38:02 +080017296 present1 = snd_hda_jack_detect(codec, 0x21);
17297 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017298
17299 if (present1 || present2) {
17300 snd_hda_codec_write_cache(codec, 0x14, 0,
17301 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17302 } else {
17303 snd_hda_codec_write_cache(codec, 0x14, 0,
17304 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17305 }
17306}
17307
17308static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
17309{
17310 unsigned int present1, present2;
17311
Wu Fengguang864f92b2009-11-18 12:38:02 +080017312 present1 = snd_hda_jack_detect(codec, 0x1b);
17313 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017314
17315 if (present1 || present2) {
17316 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017317 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017318 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017319 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017320 } else {
17321 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017322 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017323 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017324 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017325 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020017326}
17327
Kailang Yangebb83ee2009-12-17 12:23:00 +010017328static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
17329{
17330 unsigned int present1, present2;
17331
17332 present1 = snd_hda_codec_read(codec, 0x1b, 0,
17333 AC_VERB_GET_PIN_SENSE, 0)
17334 & AC_PINSENSE_PRESENCE;
17335 present2 = snd_hda_codec_read(codec, 0x21, 0,
17336 AC_VERB_GET_PIN_SENSE, 0)
17337 & AC_PINSENSE_PRESENCE;
17338
17339 if (present1 || present2) {
17340 snd_hda_codec_write_cache(codec, 0x14, 0,
17341 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17342 snd_hda_codec_write_cache(codec, 0x17, 0,
17343 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17344 } else {
17345 snd_hda_codec_write_cache(codec, 0x14, 0,
17346 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17347 snd_hda_codec_write_cache(codec, 0x17, 0,
17348 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17349 }
17350}
17351
17352static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
17353{
17354 unsigned int present1, present2;
17355
17356 present1 = snd_hda_codec_read(codec, 0x21, 0,
17357 AC_VERB_GET_PIN_SENSE, 0)
17358 & AC_PINSENSE_PRESENCE;
17359 present2 = snd_hda_codec_read(codec, 0x15, 0,
17360 AC_VERB_GET_PIN_SENSE, 0)
17361 & AC_PINSENSE_PRESENCE;
17362
17363 if (present1 || present2) {
17364 snd_hda_codec_write_cache(codec, 0x14, 0,
17365 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17366 snd_hda_codec_write_cache(codec, 0x17, 0,
17367 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17368 } else {
17369 snd_hda_codec_write_cache(codec, 0x14, 0,
17370 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17371 snd_hda_codec_write_cache(codec, 0x17, 0,
17372 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17373 }
17374}
17375
Kailang Yang6dda9f42008-05-27 12:05:31 +020017376static void alc663_m51va_unsol_event(struct hda_codec *codec,
17377 unsigned int res)
17378{
17379 switch (res >> 26) {
17380 case ALC880_HP_EVENT:
17381 alc663_m51va_speaker_automute(codec);
17382 break;
17383 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017384 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017385 break;
17386 }
17387}
17388
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017389static void alc663_m51va_setup(struct hda_codec *codec)
17390{
17391 struct alc_spec *spec = codec->spec;
17392 spec->ext_mic.pin = 0x18;
17393 spec->ext_mic.mux_idx = 0;
17394 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017395 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017396 spec->auto_mic = 1;
17397}
17398
Kailang Yang6dda9f42008-05-27 12:05:31 +020017399static void alc663_m51va_inithook(struct hda_codec *codec)
17400{
17401 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017402 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017403}
17404
Kailang Yangf1d4e282008-08-26 14:03:29 +020017405/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017406#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010017407
17408static void alc663_mode1_setup(struct hda_codec *codec)
17409{
17410 struct alc_spec *spec = codec->spec;
17411 spec->ext_mic.pin = 0x18;
17412 spec->ext_mic.mux_idx = 0;
17413 spec->int_mic.pin = 0x19;
17414 spec->int_mic.mux_idx = 1;
17415 spec->auto_mic = 1;
17416}
17417
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017418#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020017419
Kailang Yangf1d4e282008-08-26 14:03:29 +020017420/* ***************** Mode2 ******************************/
17421static void alc662_mode2_unsol_event(struct hda_codec *codec,
17422 unsigned int res)
17423{
17424 switch (res >> 26) {
17425 case ALC880_HP_EVENT:
17426 alc662_f5z_speaker_automute(codec);
17427 break;
17428 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017429 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017430 break;
17431 }
17432}
17433
Kailang Yangebb83ee2009-12-17 12:23:00 +010017434#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017435
Kailang Yangf1d4e282008-08-26 14:03:29 +020017436static void alc662_mode2_inithook(struct hda_codec *codec)
17437{
17438 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017439 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017440}
17441/* ***************** Mode3 ******************************/
17442static void alc663_mode3_unsol_event(struct hda_codec *codec,
17443 unsigned int res)
17444{
17445 switch (res >> 26) {
17446 case ALC880_HP_EVENT:
17447 alc663_two_hp_m1_speaker_automute(codec);
17448 break;
17449 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017450 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017451 break;
17452 }
17453}
17454
Kailang Yangebb83ee2009-12-17 12:23:00 +010017455#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017456
Kailang Yangf1d4e282008-08-26 14:03:29 +020017457static void alc663_mode3_inithook(struct hda_codec *codec)
17458{
17459 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017460 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017461}
17462/* ***************** Mode4 ******************************/
17463static void alc663_mode4_unsol_event(struct hda_codec *codec,
17464 unsigned int res)
17465{
17466 switch (res >> 26) {
17467 case ALC880_HP_EVENT:
17468 alc663_21jd_two_speaker_automute(codec);
17469 break;
17470 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017471 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017472 break;
17473 }
17474}
17475
Kailang Yangebb83ee2009-12-17 12:23:00 +010017476#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017477
Kailang Yangf1d4e282008-08-26 14:03:29 +020017478static void alc663_mode4_inithook(struct hda_codec *codec)
17479{
17480 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017481 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017482}
17483/* ***************** Mode5 ******************************/
17484static void alc663_mode5_unsol_event(struct hda_codec *codec,
17485 unsigned int res)
17486{
17487 switch (res >> 26) {
17488 case ALC880_HP_EVENT:
17489 alc663_15jd_two_speaker_automute(codec);
17490 break;
17491 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017492 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017493 break;
17494 }
17495}
17496
Kailang Yangebb83ee2009-12-17 12:23:00 +010017497#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017498
Kailang Yangf1d4e282008-08-26 14:03:29 +020017499static void alc663_mode5_inithook(struct hda_codec *codec)
17500{
17501 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017502 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017503}
17504/* ***************** Mode6 ******************************/
17505static void alc663_mode6_unsol_event(struct hda_codec *codec,
17506 unsigned int res)
17507{
17508 switch (res >> 26) {
17509 case ALC880_HP_EVENT:
17510 alc663_two_hp_m2_speaker_automute(codec);
17511 break;
17512 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017513 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017514 break;
17515 }
17516}
17517
Kailang Yangebb83ee2009-12-17 12:23:00 +010017518#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017519
Kailang Yangf1d4e282008-08-26 14:03:29 +020017520static void alc663_mode6_inithook(struct hda_codec *codec)
17521{
17522 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017523 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017524}
17525
Kailang Yangebb83ee2009-12-17 12:23:00 +010017526/* ***************** Mode7 ******************************/
17527static void alc663_mode7_unsol_event(struct hda_codec *codec,
17528 unsigned int res)
17529{
17530 switch (res >> 26) {
17531 case ALC880_HP_EVENT:
17532 alc663_two_hp_m7_speaker_automute(codec);
17533 break;
17534 case ALC880_MIC_EVENT:
17535 alc_mic_automute(codec);
17536 break;
17537 }
17538}
17539
17540#define alc663_mode7_setup alc663_mode1_setup
17541
17542static void alc663_mode7_inithook(struct hda_codec *codec)
17543{
17544 alc663_two_hp_m7_speaker_automute(codec);
17545 alc_mic_automute(codec);
17546}
17547
17548/* ***************** Mode8 ******************************/
17549static void alc663_mode8_unsol_event(struct hda_codec *codec,
17550 unsigned int res)
17551{
17552 switch (res >> 26) {
17553 case ALC880_HP_EVENT:
17554 alc663_two_hp_m8_speaker_automute(codec);
17555 break;
17556 case ALC880_MIC_EVENT:
17557 alc_mic_automute(codec);
17558 break;
17559 }
17560}
17561
17562#define alc663_mode8_setup alc663_m51va_setup
17563
17564static void alc663_mode8_inithook(struct hda_codec *codec)
17565{
17566 alc663_two_hp_m8_speaker_automute(codec);
17567 alc_mic_automute(codec);
17568}
17569
Kailang Yang6dda9f42008-05-27 12:05:31 +020017570static void alc663_g71v_hp_automute(struct hda_codec *codec)
17571{
17572 unsigned int present;
17573 unsigned char bits;
17574
Wu Fengguang864f92b2009-11-18 12:38:02 +080017575 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017576 bits = present ? HDA_AMP_MUTE : 0;
17577 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17578 HDA_AMP_MUTE, bits);
17579 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17580 HDA_AMP_MUTE, bits);
17581}
17582
17583static void alc663_g71v_front_automute(struct hda_codec *codec)
17584{
17585 unsigned int present;
17586 unsigned char bits;
17587
Wu Fengguang864f92b2009-11-18 12:38:02 +080017588 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017589 bits = present ? HDA_AMP_MUTE : 0;
17590 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17591 HDA_AMP_MUTE, bits);
17592}
17593
17594static void alc663_g71v_unsol_event(struct hda_codec *codec,
17595 unsigned int res)
17596{
17597 switch (res >> 26) {
17598 case ALC880_HP_EVENT:
17599 alc663_g71v_hp_automute(codec);
17600 break;
17601 case ALC880_FRONT_EVENT:
17602 alc663_g71v_front_automute(codec);
17603 break;
17604 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017605 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017606 break;
17607 }
17608}
17609
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017610#define alc663_g71v_setup alc663_m51va_setup
17611
Kailang Yang6dda9f42008-05-27 12:05:31 +020017612static void alc663_g71v_inithook(struct hda_codec *codec)
17613{
17614 alc663_g71v_front_automute(codec);
17615 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017616 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017617}
17618
17619static void alc663_g50v_unsol_event(struct hda_codec *codec,
17620 unsigned int res)
17621{
17622 switch (res >> 26) {
17623 case ALC880_HP_EVENT:
17624 alc663_m51va_speaker_automute(codec);
17625 break;
17626 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017627 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017628 break;
17629 }
17630}
17631
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017632#define alc663_g50v_setup alc663_m51va_setup
17633
Kailang Yang6dda9f42008-05-27 12:05:31 +020017634static void alc663_g50v_inithook(struct hda_codec *codec)
17635{
17636 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017637 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017638}
17639
Kailang Yangf1d4e282008-08-26 14:03:29 +020017640static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17641 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017642 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017643
17644 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17645 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17646 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17647
17648 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17649 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17650 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17651 { } /* end */
17652};
17653
Chris Pockelé9541ba12009-05-12 08:08:53 +020017654static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17655 /* Master Playback automatically created from Speaker and Headphone */
17656 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17657 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17658 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17659 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17660
17661 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17662 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17663 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17664
17665 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17666 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17667 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17668 { } /* end */
17669};
17670
Takashi Iwaicb53c622007-08-10 17:21:45 +020017671#ifdef CONFIG_SND_HDA_POWER_SAVE
17672#define alc662_loopbacks alc880_loopbacks
17673#endif
17674
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017675
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017676/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017677#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17678#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17679#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17680#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17681
17682/*
17683 * configuration and preset
17684 */
17685static const char *alc662_models[ALC662_MODEL_LAST] = {
17686 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17687 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17688 [ALC662_3ST_6ch] = "3stack-6ch",
17689 [ALC662_5ST_DIG] = "6stack-dig",
17690 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017691 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017692 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017693 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017694 [ALC663_ASUS_M51VA] = "m51va",
17695 [ALC663_ASUS_G71V] = "g71v",
17696 [ALC663_ASUS_H13] = "h13",
17697 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017698 [ALC663_ASUS_MODE1] = "asus-mode1",
17699 [ALC662_ASUS_MODE2] = "asus-mode2",
17700 [ALC663_ASUS_MODE3] = "asus-mode3",
17701 [ALC663_ASUS_MODE4] = "asus-mode4",
17702 [ALC663_ASUS_MODE5] = "asus-mode5",
17703 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017704 [ALC663_ASUS_MODE7] = "asus-mode7",
17705 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017706 [ALC272_DELL] = "dell",
17707 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017708 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017709 [ALC662_AUTO] = "auto",
17710};
17711
17712static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017713 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017714 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17715 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017716 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17717 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010017718 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017719 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17720 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17721 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17722 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017723 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17724 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017725 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017726 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17727 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17728 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17729 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17730 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017731 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017732 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17733 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017734 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17735 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17736 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17737 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017738 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017739 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17740 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17741 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017742 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17743 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17744 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17745 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017746 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017747 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17748 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017749 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017750 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17751 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17752 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017753 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010017754 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017755 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17756 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017757 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17758 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17759 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017760 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017761 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17762 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017763 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017764 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017765 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017766 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17767 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17768 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017769 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017770 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17771 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017772 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017773 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017774 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017775 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017776 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17777 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010017778 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017779 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030017780 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17781 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010017782 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017783 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017784 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017785 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020017786 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020017787 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017788 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17789 ALC663_ASUS_H13),
David Santinoli7aee6742009-12-09 12:34:26 +010017790 SND_PCI_QUIRK(0x8086, 0xd604, "Intel mobo", ALC662_3ST_2ch_DIG),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017791 {}
17792};
17793
17794static struct alc_config_preset alc662_presets[] = {
17795 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017796 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017797 .init_verbs = { alc662_init_verbs },
17798 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17799 .dac_nids = alc662_dac_nids,
17800 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017801 .dig_in_nid = ALC662_DIGIN_NID,
17802 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17803 .channel_mode = alc662_3ST_2ch_modes,
17804 .input_mux = &alc662_capture_source,
17805 },
17806 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017807 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017808 .init_verbs = { alc662_init_verbs },
17809 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17810 .dac_nids = alc662_dac_nids,
17811 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017812 .dig_in_nid = ALC662_DIGIN_NID,
17813 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17814 .channel_mode = alc662_3ST_6ch_modes,
17815 .need_dac_fix = 1,
17816 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017817 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017818 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017819 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017820 .init_verbs = { alc662_init_verbs },
17821 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17822 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017823 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17824 .channel_mode = alc662_3ST_6ch_modes,
17825 .need_dac_fix = 1,
17826 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017827 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017828 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017829 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017830 .init_verbs = { alc662_init_verbs },
17831 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17832 .dac_nids = alc662_dac_nids,
17833 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017834 .dig_in_nid = ALC662_DIGIN_NID,
17835 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
17836 .channel_mode = alc662_5stack_modes,
17837 .input_mux = &alc662_capture_source,
17838 },
17839 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017840 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017841 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
17842 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17843 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017844 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17845 .channel_mode = alc662_3ST_2ch_modes,
17846 .input_mux = &alc662_lenovo_101e_capture_source,
17847 .unsol_event = alc662_lenovo_101e_unsol_event,
17848 .init_hook = alc662_lenovo_101e_all_automute,
17849 },
Kailang Yang291702f2007-10-16 14:28:03 +020017850 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017851 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020017852 .init_verbs = { alc662_init_verbs,
17853 alc662_eeepc_sue_init_verbs },
17854 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17855 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020017856 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17857 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020017858 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017859 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020017860 .init_hook = alc662_eeepc_inithook,
17861 },
Kailang Yang8c427222008-01-10 13:03:59 +010017862 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017863 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010017864 alc662_chmode_mixer },
17865 .init_verbs = { alc662_init_verbs,
17866 alc662_eeepc_ep20_sue_init_verbs },
17867 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17868 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010017869 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17870 .channel_mode = alc662_3ST_6ch_modes,
17871 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020017872 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017873 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010017874 .init_hook = alc662_eeepc_ep20_inithook,
17875 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017876 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017877 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017878 .init_verbs = { alc662_init_verbs,
17879 alc662_ecs_init_verbs },
17880 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17881 .dac_nids = alc662_dac_nids,
17882 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17883 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017884 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017885 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017886 .init_hook = alc662_eeepc_inithook,
17887 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017888 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017889 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017890 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17891 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17892 .dac_nids = alc662_dac_nids,
17893 .dig_out_nid = ALC662_DIGOUT_NID,
17894 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17895 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017896 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017897 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017898 .init_hook = alc663_m51va_inithook,
17899 },
17900 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017901 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017902 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17903 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17904 .dac_nids = alc662_dac_nids,
17905 .dig_out_nid = ALC662_DIGOUT_NID,
17906 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17907 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017908 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017909 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017910 .init_hook = alc663_g71v_inithook,
17911 },
17912 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017913 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017914 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17915 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17916 .dac_nids = alc662_dac_nids,
17917 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17918 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017919 .unsol_event = alc663_m51va_unsol_event,
17920 .init_hook = alc663_m51va_inithook,
17921 },
17922 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017923 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017924 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17925 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17926 .dac_nids = alc662_dac_nids,
17927 .dig_out_nid = ALC662_DIGOUT_NID,
17928 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17929 .channel_mode = alc662_3ST_6ch_modes,
17930 .input_mux = &alc663_capture_source,
17931 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017932 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017933 .init_hook = alc663_g50v_inithook,
17934 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017935 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017936 .mixers = { alc663_m51va_mixer },
17937 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017938 .init_verbs = { alc662_init_verbs,
17939 alc663_21jd_amic_init_verbs },
17940 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17941 .hp_nid = 0x03,
17942 .dac_nids = alc662_dac_nids,
17943 .dig_out_nid = ALC662_DIGOUT_NID,
17944 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17945 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017946 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017947 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017948 .init_hook = alc663_mode1_inithook,
17949 },
17950 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017951 .mixers = { alc662_1bjd_mixer },
17952 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017953 .init_verbs = { alc662_init_verbs,
17954 alc662_1bjd_amic_init_verbs },
17955 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17956 .dac_nids = alc662_dac_nids,
17957 .dig_out_nid = ALC662_DIGOUT_NID,
17958 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17959 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017960 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017961 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017962 .init_hook = alc662_mode2_inithook,
17963 },
17964 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017965 .mixers = { alc663_two_hp_m1_mixer },
17966 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017967 .init_verbs = { alc662_init_verbs,
17968 alc663_two_hp_amic_m1_init_verbs },
17969 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17970 .hp_nid = 0x03,
17971 .dac_nids = alc662_dac_nids,
17972 .dig_out_nid = ALC662_DIGOUT_NID,
17973 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17974 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017975 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017976 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017977 .init_hook = alc663_mode3_inithook,
17978 },
17979 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017980 .mixers = { alc663_asus_21jd_clfe_mixer },
17981 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017982 .init_verbs = { alc662_init_verbs,
17983 alc663_21jd_amic_init_verbs},
17984 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17985 .hp_nid = 0x03,
17986 .dac_nids = alc662_dac_nids,
17987 .dig_out_nid = ALC662_DIGOUT_NID,
17988 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17989 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017990 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017991 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017992 .init_hook = alc663_mode4_inithook,
17993 },
17994 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017995 .mixers = { alc663_asus_15jd_clfe_mixer },
17996 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017997 .init_verbs = { alc662_init_verbs,
17998 alc663_15jd_amic_init_verbs },
17999 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18000 .hp_nid = 0x03,
18001 .dac_nids = alc662_dac_nids,
18002 .dig_out_nid = ALC662_DIGOUT_NID,
18003 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18004 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018005 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018006 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018007 .init_hook = alc663_mode5_inithook,
18008 },
18009 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018010 .mixers = { alc663_two_hp_m2_mixer },
18011 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018012 .init_verbs = { alc662_init_verbs,
18013 alc663_two_hp_amic_m2_init_verbs },
18014 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18015 .hp_nid = 0x03,
18016 .dac_nids = alc662_dac_nids,
18017 .dig_out_nid = ALC662_DIGOUT_NID,
18018 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18019 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018020 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018021 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018022 .init_hook = alc663_mode6_inithook,
18023 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018024 [ALC663_ASUS_MODE7] = {
18025 .mixers = { alc663_mode7_mixer },
18026 .cap_mixer = alc662_auto_capture_mixer,
18027 .init_verbs = { alc662_init_verbs,
18028 alc663_mode7_init_verbs },
18029 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18030 .hp_nid = 0x03,
18031 .dac_nids = alc662_dac_nids,
18032 .dig_out_nid = ALC662_DIGOUT_NID,
18033 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18034 .channel_mode = alc662_3ST_2ch_modes,
18035 .unsol_event = alc663_mode7_unsol_event,
18036 .setup = alc663_mode7_setup,
18037 .init_hook = alc663_mode7_inithook,
18038 },
18039 [ALC663_ASUS_MODE8] = {
18040 .mixers = { alc663_mode8_mixer },
18041 .cap_mixer = alc662_auto_capture_mixer,
18042 .init_verbs = { alc662_init_verbs,
18043 alc663_mode8_init_verbs },
18044 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18045 .hp_nid = 0x03,
18046 .dac_nids = alc662_dac_nids,
18047 .dig_out_nid = ALC662_DIGOUT_NID,
18048 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18049 .channel_mode = alc662_3ST_2ch_modes,
18050 .unsol_event = alc663_mode8_unsol_event,
18051 .setup = alc663_mode8_setup,
18052 .init_hook = alc663_mode8_inithook,
18053 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018054 [ALC272_DELL] = {
18055 .mixers = { alc663_m51va_mixer },
18056 .cap_mixer = alc272_auto_capture_mixer,
18057 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18058 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18059 .dac_nids = alc662_dac_nids,
18060 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18061 .adc_nids = alc272_adc_nids,
18062 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18063 .capsrc_nids = alc272_capsrc_nids,
18064 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018065 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018066 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018067 .init_hook = alc663_m51va_inithook,
18068 },
18069 [ALC272_DELL_ZM1] = {
18070 .mixers = { alc663_m51va_mixer },
18071 .cap_mixer = alc662_auto_capture_mixer,
18072 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18073 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18074 .dac_nids = alc662_dac_nids,
18075 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18076 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018077 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018078 .capsrc_nids = alc662_capsrc_nids,
18079 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018080 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018081 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018082 .init_hook = alc663_m51va_inithook,
18083 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018084 [ALC272_SAMSUNG_NC10] = {
18085 .mixers = { alc272_nc10_mixer },
18086 .init_verbs = { alc662_init_verbs,
18087 alc663_21jd_amic_init_verbs },
18088 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18089 .dac_nids = alc272_dac_nids,
18090 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18091 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018092 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018093 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018094 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018095 .init_hook = alc663_mode4_inithook,
18096 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018097};
18098
18099
18100/*
18101 * BIOS auto configuration
18102 */
18103
Takashi Iwai7085ec12009-10-02 09:03:58 +020018104/* convert from MIX nid to DAC */
18105static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18106{
18107 if (nid == 0x0f)
18108 return 0x02;
18109 else if (nid >= 0x0c && nid <= 0x0e)
18110 return nid - 0x0c + 0x02;
18111 else
18112 return 0;
18113}
18114
18115/* get MIX nid connected to the given pin targeted to DAC */
18116static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18117 hda_nid_t dac)
18118{
18119 hda_nid_t mix[4];
18120 int i, num;
18121
18122 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18123 for (i = 0; i < num; i++) {
18124 if (alc662_mix_to_dac(mix[i]) == dac)
18125 return mix[i];
18126 }
18127 return 0;
18128}
18129
18130/* look for an empty DAC slot */
18131static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18132{
18133 struct alc_spec *spec = codec->spec;
18134 hda_nid_t srcs[5];
18135 int i, j, num;
18136
18137 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18138 if (num < 0)
18139 return 0;
18140 for (i = 0; i < num; i++) {
18141 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18142 if (!nid)
18143 continue;
18144 for (j = 0; j < spec->multiout.num_dacs; j++)
18145 if (spec->multiout.dac_nids[j] == nid)
18146 break;
18147 if (j >= spec->multiout.num_dacs)
18148 return nid;
18149 }
18150 return 0;
18151}
18152
18153/* fill in the dac_nids table from the parsed pin configuration */
18154static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18155 const struct auto_pin_cfg *cfg)
18156{
18157 struct alc_spec *spec = codec->spec;
18158 int i;
18159 hda_nid_t dac;
18160
18161 spec->multiout.dac_nids = spec->private_dac_nids;
18162 for (i = 0; i < cfg->line_outs; i++) {
18163 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18164 if (!dac)
18165 continue;
18166 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18167 }
18168 return 0;
18169}
18170
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018171static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018172 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018173{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018174 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018175 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18176}
18177
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018178static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018179 hda_nid_t nid, unsigned int chs)
18180{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018181 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018182 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18183}
18184
18185#define alc662_add_stereo_vol(spec, pfx, nid) \
18186 alc662_add_vol_ctl(spec, pfx, nid, 3)
18187#define alc662_add_stereo_sw(spec, pfx, nid) \
18188 alc662_add_sw_ctl(spec, pfx, nid, 3)
18189
18190/* add playback controls from the parsed DAC table */
18191static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18192 const struct auto_pin_cfg *cfg)
18193{
18194 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018195 static const char *chname[4] = {
18196 "Front", "Surround", NULL /*CLFE*/, "Side"
18197 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018198 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018199 int i, err;
18200
18201 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018202 nid = spec->multiout.dac_nids[i];
18203 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018204 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018205 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18206 if (!mix)
18207 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018208 if (i == 2) {
18209 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018210 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018211 if (err < 0)
18212 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018213 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018214 if (err < 0)
18215 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018216 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018217 if (err < 0)
18218 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018219 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018220 if (err < 0)
18221 return err;
18222 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018223 const char *pfx;
18224 if (cfg->line_outs == 1 &&
18225 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018226 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018227 pfx = "Speaker";
18228 else
18229 pfx = "PCM";
18230 } else
18231 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018232 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018233 if (err < 0)
18234 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018235 if (cfg->line_outs == 1 &&
18236 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18237 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018238 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018239 if (err < 0)
18240 return err;
18241 }
18242 }
18243 return 0;
18244}
18245
18246/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018247/* return DAC nid if any new DAC is assigned */
18248static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018249 const char *pfx)
18250{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018251 struct alc_spec *spec = codec->spec;
18252 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018253 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018254
18255 if (!pin)
18256 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018257 nid = alc662_look_for_dac(codec, pin);
18258 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018259 /* the corresponding DAC is already occupied */
18260 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
18261 return 0; /* no way */
18262 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018263 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018264 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
18265 }
18266
18267 mix = alc662_dac_to_mix(codec, pin, nid);
18268 if (!mix)
18269 return 0;
18270 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
18271 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020018272 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018273 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
18274 if (err < 0)
18275 return err;
18276 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018277}
18278
18279/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020018280#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020018281 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018282
18283static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
18284 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018285 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018286{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018287 int i, num;
18288 hda_nid_t srcs[4];
18289
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018290 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018291 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018292 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
18293 if (num <= 1)
18294 return;
18295 for (i = 0; i < num; i++) {
18296 if (alc662_mix_to_dac(srcs[i]) != dac)
18297 continue;
18298 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
18299 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018300 }
18301}
18302
18303static void alc662_auto_init_multi_out(struct hda_codec *codec)
18304{
18305 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018306 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018307 int i;
18308
18309 for (i = 0; i <= HDA_SIDE; i++) {
18310 hda_nid_t nid = spec->autocfg.line_out_pins[i];
18311 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020018312 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018313 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018314 }
18315}
18316
18317static void alc662_auto_init_hp_out(struct hda_codec *codec)
18318{
18319 struct alc_spec *spec = codec->spec;
18320 hda_nid_t pin;
18321
18322 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018323 if (pin)
18324 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
18325 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018326 pin = spec->autocfg.speaker_pins[0];
18327 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018328 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
18329 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018330}
18331
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018332#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
18333
18334static void alc662_auto_init_analog_input(struct hda_codec *codec)
18335{
18336 struct alc_spec *spec = codec->spec;
18337 int i;
18338
18339 for (i = 0; i < AUTO_PIN_LAST; i++) {
18340 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020018341 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010018342 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010018343 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010018344 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018345 snd_hda_codec_write(codec, nid, 0,
18346 AC_VERB_SET_AMP_GAIN_MUTE,
18347 AMP_OUT_MUTE);
18348 }
18349 }
18350}
18351
Takashi Iwaif511b012008-08-15 16:46:42 +020018352#define alc662_auto_init_input_src alc882_auto_init_input_src
18353
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018354static int alc662_parse_auto_config(struct hda_codec *codec)
18355{
18356 struct alc_spec *spec = codec->spec;
18357 int err;
18358 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
18359
18360 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
18361 alc662_ignore);
18362 if (err < 0)
18363 return err;
18364 if (!spec->autocfg.line_outs)
18365 return 0; /* can't find valid BIOS pin config */
18366
Takashi Iwai7085ec12009-10-02 09:03:58 +020018367 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018368 if (err < 0)
18369 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018370 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018371 if (err < 0)
18372 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018373 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018374 spec->autocfg.speaker_pins[0],
18375 "Speaker");
18376 if (err < 0)
18377 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018378 if (err)
18379 spec->multiout.extra_out_nid[0] = err;
18380 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018381 "Headphone");
18382 if (err < 0)
18383 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018384 if (err)
18385 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018386 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018387 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018388 return err;
18389
18390 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18391
Takashi Iwai0852d7a2009-02-11 11:35:15 +010018392 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018393 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
18394
Takashi Iwai603c4012008-07-30 15:01:44 +020018395 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018396 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018397
18398 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018399 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018400
Kailang Yangcec27c82010-02-04 14:18:18 +010018401 add_verb(spec, alc662_init_verbs);
18402 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18403 codec->vendor_id == 0x10ec0665)
18404 add_verb(spec, alc663_init_verbs);
18405
18406 if (codec->vendor_id == 0x10ec0272)
18407 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020018408
18409 err = alc_auto_add_mic_boost(codec);
18410 if (err < 0)
18411 return err;
18412
Kailang Yang6227cdc2010-02-25 08:36:52 +010018413 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18414 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
18415 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
18416 else
18417 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018418
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018419 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018420}
18421
18422/* additional initialization for auto-configuration model */
18423static void alc662_auto_init(struct hda_codec *codec)
18424{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018425 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018426 alc662_auto_init_multi_out(codec);
18427 alc662_auto_init_hp_out(codec);
18428 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020018429 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018430 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018431 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018432}
18433
18434static int patch_alc662(struct hda_codec *codec)
18435{
18436 struct alc_spec *spec;
18437 int err, board_config;
18438
18439 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18440 if (!spec)
18441 return -ENOMEM;
18442
18443 codec->spec = spec;
18444
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018445 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18446
Kailang Yang274693f2009-12-03 10:07:50 +010018447 if (alc_read_coef_idx(codec, 0)==0x8020){
18448 kfree(codec->chip_name);
18449 codec->chip_name = kstrdup("ALC661", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018450 if (!codec->chip_name) {
18451 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018452 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018453 }
Kailang Yang274693f2009-12-03 10:07:50 +010018454 }
18455
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018456 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18457 alc662_models,
18458 alc662_cfg_tbl);
18459 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020018460 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18461 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018462 board_config = ALC662_AUTO;
18463 }
18464
18465 if (board_config == ALC662_AUTO) {
18466 /* automatic parse from the BIOS config */
18467 err = alc662_parse_auto_config(codec);
18468 if (err < 0) {
18469 alc_free(codec);
18470 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018471 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018472 printk(KERN_INFO
18473 "hda_codec: Cannot set up configuration "
18474 "from BIOS. Using base mode...\n");
18475 board_config = ALC662_3ST_2ch_DIG;
18476 }
18477 }
18478
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018479 err = snd_hda_attach_beep_device(codec, 0x1);
18480 if (err < 0) {
18481 alc_free(codec);
18482 return err;
18483 }
18484
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018485 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018486 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018487
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018488 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18489 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18490
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018491 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18492 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18493
Takashi Iwaidd704692009-08-11 08:45:11 +020018494 if (!spec->adc_nids) {
18495 spec->adc_nids = alc662_adc_nids;
18496 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
18497 }
18498 if (!spec->capsrc_nids)
18499 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018500
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018501 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018502 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018503
Kailang Yangcec27c82010-02-04 14:18:18 +010018504 switch (codec->vendor_id) {
18505 case 0x10ec0662:
18506 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18507 break;
18508 case 0x10ec0272:
18509 case 0x10ec0663:
18510 case 0x10ec0665:
18511 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
18512 break;
18513 case 0x10ec0273:
18514 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
18515 break;
18516 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010018517 spec->vmaster_nid = 0x02;
18518
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018519 codec->patch_ops = alc_patch_ops;
18520 if (board_config == ALC662_AUTO)
18521 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020018522#ifdef CONFIG_SND_HDA_POWER_SAVE
18523 if (!spec->loopback.amplist)
18524 spec->loopback.amplist = alc662_loopbacks;
18525#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018526
18527 return 0;
18528}
18529
Kailang Yang274693f2009-12-03 10:07:50 +010018530static int patch_alc888(struct hda_codec *codec)
18531{
18532 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
18533 kfree(codec->chip_name);
18534 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018535 if (!codec->chip_name) {
18536 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018537 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018538 }
18539 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018540 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018541 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018542}
18543
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018544/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070018545 * patch entries
18546 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018547static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070018548 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018549 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018550 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020018551 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018552 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018553 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020018554 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018555 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018556 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018557 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018558 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
18559 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
18560 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018561 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018562 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018563 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
18564 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018565 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010018566 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010018567 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018568 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018569 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018570 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020018571 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018572 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020018573 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018574 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018575 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018576 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020018577 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018578 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018579 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018580 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018581 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018582 {} /* terminator */
18583};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018584
18585MODULE_ALIAS("snd-hda-codec-id:10ec*");
18586
18587MODULE_LICENSE("GPL");
18588MODULE_DESCRIPTION("Realtek HD-audio codec");
18589
18590static struct hda_codec_preset_list realtek_list = {
18591 .preset = snd_hda_preset_realtek,
18592 .owner = THIS_MODULE,
18593};
18594
18595static int __init patch_realtek_init(void)
18596{
18597 return snd_hda_add_codec_preset(&realtek_list);
18598}
18599
18600static void __exit patch_realtek_exit(void)
18601{
18602 snd_hda_delete_codec_preset(&realtek_list);
18603}
18604
18605module_init(patch_realtek_init)
18606module_exit(patch_realtek_exit)