blob: 4b35176d34548eaa1a4064619360fa58c25e7523 [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 Iwai7fa90e82010-04-12 08:49:00 +02001393 const struct alc_fixup *fix,
1394 int pre_init)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001395{
1396 const struct alc_pincfg *cfg;
1397
1398 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1399 if (!quirk)
1400 return;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001401 fix += quirk->value;
1402 cfg = fix->pins;
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001403 if (pre_init && cfg) {
1404#ifdef CONFIG_SND_DEBUG_VERBOSE
1405 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1406 codec->chip_name, quirk->name);
1407#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001408 for (; cfg->nid; cfg++)
1409 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1410 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001411 if (!pre_init && fix->verbs) {
1412#ifdef CONFIG_SND_DEBUG_VERBOSE
1413 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1414 codec->chip_name, quirk->name);
1415#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001416 add_verb(codec->spec, fix->verbs);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001417 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001418}
1419
Kailang Yang274693f2009-12-03 10:07:50 +01001420static int alc_read_coef_idx(struct hda_codec *codec,
1421 unsigned int coef_idx)
1422{
1423 unsigned int val;
1424 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1425 coef_idx);
1426 val = snd_hda_codec_read(codec, 0x20, 0,
1427 AC_VERB_GET_PROC_COEF, 0);
1428 return val;
1429}
1430
Takashi Iwaif95474e2007-07-10 00:47:43 +02001431/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001432 * ALC888
1433 */
1434
1435/*
1436 * 2ch mode
1437 */
1438static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1439/* Mic-in jack as mic in */
1440 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1441 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1442/* Line-in jack as Line in */
1443 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1444 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1445/* Line-Out as Front */
1446 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1447 { } /* end */
1448};
1449
1450/*
1451 * 4ch mode
1452 */
1453static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1454/* Mic-in jack as mic in */
1455 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1456 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1457/* Line-in jack as Surround */
1458 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1459 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1460/* Line-Out as Front */
1461 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1462 { } /* end */
1463};
1464
1465/*
1466 * 6ch mode
1467 */
1468static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1469/* Mic-in jack as CLFE */
1470 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1471 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1472/* Line-in jack as Surround */
1473 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1474 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1475/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1476 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1477 { } /* end */
1478};
1479
1480/*
1481 * 8ch mode
1482 */
1483static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1484/* Mic-in jack as CLFE */
1485 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1486 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1487/* Line-in jack as Surround */
1488 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1489 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1490/* Line-Out as Side */
1491 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1492 { } /* end */
1493};
1494
1495static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1496 { 2, alc888_4ST_ch2_intel_init },
1497 { 4, alc888_4ST_ch4_intel_init },
1498 { 6, alc888_4ST_ch6_intel_init },
1499 { 8, alc888_4ST_ch8_intel_init },
1500};
1501
1502/*
1503 * ALC888 Fujitsu Siemens Amillo xa3530
1504 */
1505
1506static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1507/* Front Mic: set to PIN_IN (empty by default) */
1508 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1509/* Connect Internal HP to Front */
1510 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1511 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1512 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1513/* Connect Bass HP to Front */
1514 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1515 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1516 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1517/* Connect Line-Out side jack (SPDIF) to Side */
1518 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1519 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1520 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1521/* Connect Mic jack to CLFE */
1522 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1523 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1524 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1525/* Connect Line-in jack to Surround */
1526 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1527 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1528 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1529/* Connect HP out jack to Front */
1530 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1531 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1532 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1533/* Enable unsolicited event for HP jack and Line-out jack */
1534 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1535 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1536 {}
1537};
1538
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001539static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001540{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001541 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001542 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001543 hda_nid_t nid;
1544 int i;
1545
1546 spec->jack_present = 0;
1547 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1548 nid = spec->autocfg.hp_pins[i];
1549 if (!nid)
1550 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001551 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001552 spec->jack_present = 1;
1553 break;
1554 }
1555 }
1556
1557 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001558 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001559 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1560 nid = spec->autocfg.speaker_pins[i];
1561 if (!nid)
1562 break;
1563 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1564 HDA_AMP_MUTE, mute);
1565 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001566}
1567
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001568static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1569 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001570{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001571 if (codec->vendor_id == 0x10ec0880)
1572 res >>= 28;
1573 else
1574 res >>= 26;
1575 if (res == ALC880_HP_EVENT)
1576 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001577}
1578
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001579static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001580{
1581 struct alc_spec *spec = codec->spec;
1582
1583 spec->autocfg.hp_pins[0] = 0x15;
1584 spec->autocfg.speaker_pins[0] = 0x14;
1585 spec->autocfg.speaker_pins[1] = 0x16;
1586 spec->autocfg.speaker_pins[2] = 0x17;
1587 spec->autocfg.speaker_pins[3] = 0x19;
1588 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001589}
1590
1591static void alc889_intel_init_hook(struct hda_codec *codec)
1592{
1593 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001594 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001595}
1596
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001597static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001598{
1599 struct alc_spec *spec = codec->spec;
1600
1601 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1602 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1603 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1604 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001605}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001606
1607/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001608 * ALC888 Acer Aspire 4930G model
1609 */
1610
1611static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1612/* Front Mic: set to PIN_IN (empty by default) */
1613 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1614/* Unselect Front Mic by default in input mixer 3 */
1615 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001616/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001617 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1618/* Connect Internal HP to front */
1619 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1620 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1621 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1622/* Connect HP out to front */
1623 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1624 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1625 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1626 { }
1627};
1628
Hector Martin3b315d72009-06-02 10:54:19 +02001629/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001630 * ALC888 Acer Aspire 6530G model
1631 */
1632
1633static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01001634/* Route to built-in subwoofer as well as speakers */
1635 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1636 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1637 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1638 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001639/* Bias voltage on for external mic port */
1640 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001641/* Front Mic: set to PIN_IN (empty by default) */
1642 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1643/* Unselect Front Mic by default in input mixer 3 */
1644 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001645/* Enable unsolicited event for HP jack */
1646 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1647/* Enable speaker output */
1648 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1649 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01001650 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001651/* Enable headphone output */
1652 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1653 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1654 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01001655 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001656 { }
1657};
1658
1659/*
Hector Martin018df412009-06-04 00:13:40 +02001660 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001661 */
1662
Hector Martin018df412009-06-04 00:13:40 +02001663static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001664/* Front Mic: set to PIN_IN (empty by default) */
1665 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1666/* Unselect Front Mic by default in input mixer 3 */
1667 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1668/* Enable unsolicited event for HP jack */
1669 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1670/* Connect Internal Front to Front */
1671 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1672 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1673 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1674/* Connect Internal Rear to Rear */
1675 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1676 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1677 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1678/* Connect Internal CLFE to CLFE */
1679 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1680 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1681 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1682/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001683 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001684 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1685 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1686/* Enable all DACs */
1687/* DAC DISABLE/MUTE 1? */
1688/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1689 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1690 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1691/* DAC DISABLE/MUTE 2? */
1692/* some bit here disables the other DACs. Init=0x4900 */
1693 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1694 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02001695/* DMIC fix
1696 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1697 * which makes the stereo useless. However, either the mic or the ALC889
1698 * makes the signal become a difference/sum signal instead of standard
1699 * stereo, which is annoying. So instead we flip this bit which makes the
1700 * codec replicate the sum signal to both channels, turning it into a
1701 * normal mono mic.
1702 */
1703/* DMIC_CONTROL? Init value = 0x0001 */
1704 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1705 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001706 { }
1707};
1708
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001709static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001710 /* Front mic only available on one ADC */
1711 {
1712 .num_items = 4,
1713 .items = {
1714 { "Mic", 0x0 },
1715 { "Line", 0x2 },
1716 { "CD", 0x4 },
1717 { "Front Mic", 0xb },
1718 },
1719 },
1720 {
1721 .num_items = 3,
1722 .items = {
1723 { "Mic", 0x0 },
1724 { "Line", 0x2 },
1725 { "CD", 0x4 },
1726 },
1727 }
1728};
1729
Tony Vroond2fd4b02009-06-21 00:40:10 +01001730static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1731 /* Interal mic only available on one ADC */
1732 {
Tony Vroon684a8842009-06-26 09:27:50 +01001733 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001734 .items = {
1735 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001736 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001737 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001738 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001739 { "Int Mic", 0xb },
1740 },
1741 },
1742 {
Tony Vroon684a8842009-06-26 09:27:50 +01001743 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001744 .items = {
1745 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001746 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001747 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001748 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001749 },
1750 }
1751};
1752
Hector Martin018df412009-06-04 00:13:40 +02001753static struct hda_input_mux alc889_capture_sources[3] = {
1754 /* Digital mic only available on first "ADC" */
1755 {
1756 .num_items = 5,
1757 .items = {
1758 { "Mic", 0x0 },
1759 { "Line", 0x2 },
1760 { "CD", 0x4 },
1761 { "Front Mic", 0xb },
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 .num_items = 4,
1776 .items = {
1777 { "Mic", 0x0 },
1778 { "Line", 0x2 },
1779 { "CD", 0x4 },
1780 { "Input Mix", 0xa },
1781 },
1782 }
1783};
1784
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001785static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001786 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1787 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1788 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1789 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1790 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1791 HDA_OUTPUT),
1792 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1793 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1794 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1795 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1796 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1797 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1798 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1799 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1800 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1801 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1802 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1803 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001804 { } /* end */
1805};
1806
Hector Martin556eea92009-12-20 22:51:23 +01001807static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1808 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1809 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1810 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1811 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1812 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1813 HDA_OUTPUT),
1814 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1815 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1816 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1817 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1818 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1820 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1821 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1822 { } /* end */
1823};
1824
1825
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001826static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001827{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001828 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001829
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001830 spec->autocfg.hp_pins[0] = 0x15;
1831 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01001832 spec->autocfg.speaker_pins[1] = 0x16;
1833 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001834}
1835
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001836static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001837{
1838 struct alc_spec *spec = codec->spec;
1839
1840 spec->autocfg.hp_pins[0] = 0x15;
1841 spec->autocfg.speaker_pins[0] = 0x14;
1842 spec->autocfg.speaker_pins[1] = 0x16;
1843 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001844}
1845
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001846static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001847{
1848 struct alc_spec *spec = codec->spec;
1849
1850 spec->autocfg.hp_pins[0] = 0x15;
1851 spec->autocfg.speaker_pins[0] = 0x14;
1852 spec->autocfg.speaker_pins[1] = 0x16;
1853 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001854}
1855
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001856/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001857 * ALC880 3-stack model
1858 *
1859 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001860 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1861 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862 */
1863
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001864static hda_nid_t alc880_dac_nids[4] = {
1865 /* front, rear, clfe, rear_surr */
1866 0x02, 0x05, 0x04, 0x03
1867};
1868
1869static hda_nid_t alc880_adc_nids[3] = {
1870 /* ADC0-2 */
1871 0x07, 0x08, 0x09,
1872};
1873
1874/* The datasheet says the node 0x07 is connected from inputs,
1875 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001876 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001877 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001878static hda_nid_t alc880_adc_nids_alt[2] = {
1879 /* ADC1-2 */
1880 0x08, 0x09,
1881};
1882
1883#define ALC880_DIGOUT_NID 0x06
1884#define ALC880_DIGIN_NID 0x0a
1885
1886static struct hda_input_mux alc880_capture_source = {
1887 .num_items = 4,
1888 .items = {
1889 { "Mic", 0x0 },
1890 { "Front Mic", 0x3 },
1891 { "Line", 0x2 },
1892 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001893 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001894};
1895
1896/* channel source setting (2/6 channel selection for 3-stack) */
1897/* 2ch mode */
1898static struct hda_verb alc880_threestack_ch2_init[] = {
1899 /* set line-in to input, mute it */
1900 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1901 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1902 /* set mic-in to input vref 80%, mute it */
1903 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1904 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001905 { } /* end */
1906};
1907
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001908/* 6ch mode */
1909static struct hda_verb alc880_threestack_ch6_init[] = {
1910 /* set line-in to output, unmute it */
1911 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1912 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1913 /* set mic-in to output, unmute it */
1914 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1915 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1916 { } /* end */
1917};
1918
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001919static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001920 { 2, alc880_threestack_ch2_init },
1921 { 6, alc880_threestack_ch6_init },
1922};
1923
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001924static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001925 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001926 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001927 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001928 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001929 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1930 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001931 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1932 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001933 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1934 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1935 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1936 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1937 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1939 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1940 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001941 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001942 {
1943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1944 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001945 .info = alc_ch_mode_info,
1946 .get = alc_ch_mode_get,
1947 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001948 },
1949 { } /* end */
1950};
1951
1952/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001953static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1954 struct snd_ctl_elem_info *uinfo)
1955{
1956 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1957 struct alc_spec *spec = codec->spec;
1958 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001959
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001960 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001961 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1962 HDA_INPUT);
1963 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001964 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001965 return err;
1966}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001967
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001968static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1969 unsigned int size, unsigned int __user *tlv)
1970{
1971 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1972 struct alc_spec *spec = codec->spec;
1973 int err;
1974
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001975 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001976 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1977 HDA_INPUT);
1978 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001979 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001980 return err;
1981}
1982
1983typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1984 struct snd_ctl_elem_value *ucontrol);
1985
1986static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1987 struct snd_ctl_elem_value *ucontrol,
1988 getput_call_t func)
1989{
1990 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1991 struct alc_spec *spec = codec->spec;
1992 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1993 int err;
1994
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001995 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001996 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1997 3, 0, HDA_INPUT);
1998 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001999 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002000 return err;
2001}
2002
2003static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2004 struct snd_ctl_elem_value *ucontrol)
2005{
2006 return alc_cap_getput_caller(kcontrol, ucontrol,
2007 snd_hda_mixer_amp_volume_get);
2008}
2009
2010static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2011 struct snd_ctl_elem_value *ucontrol)
2012{
2013 return alc_cap_getput_caller(kcontrol, ucontrol,
2014 snd_hda_mixer_amp_volume_put);
2015}
2016
2017/* capture mixer elements */
2018#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2019
2020static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2021 struct snd_ctl_elem_value *ucontrol)
2022{
2023 return alc_cap_getput_caller(kcontrol, ucontrol,
2024 snd_hda_mixer_amp_switch_get);
2025}
2026
2027static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2028 struct snd_ctl_elem_value *ucontrol)
2029{
2030 return alc_cap_getput_caller(kcontrol, ucontrol,
2031 snd_hda_mixer_amp_switch_put);
2032}
2033
Takashi Iwaia23b6882009-03-23 15:21:36 +01002034#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002035 { \
2036 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2037 .name = "Capture Switch", \
2038 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2039 .count = num, \
2040 .info = alc_cap_sw_info, \
2041 .get = alc_cap_sw_get, \
2042 .put = alc_cap_sw_put, \
2043 }, \
2044 { \
2045 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2046 .name = "Capture Volume", \
2047 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2048 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2049 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2050 .count = num, \
2051 .info = alc_cap_vol_info, \
2052 .get = alc_cap_vol_get, \
2053 .put = alc_cap_vol_put, \
2054 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002055 }
2056
2057#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002058 { \
2059 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2060 /* .name = "Capture Source", */ \
2061 .name = "Input Source", \
2062 .count = num, \
2063 .info = alc_mux_enum_info, \
2064 .get = alc_mux_enum_get, \
2065 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002066 }
2067
2068#define DEFINE_CAPMIX(num) \
2069static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2070 _DEFINE_CAPMIX(num), \
2071 _DEFINE_CAPSRC(num), \
2072 { } /* end */ \
2073}
2074
2075#define DEFINE_CAPMIX_NOSRC(num) \
2076static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2077 _DEFINE_CAPMIX(num), \
2078 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002079}
2080
2081/* up to three ADCs */
2082DEFINE_CAPMIX(1);
2083DEFINE_CAPMIX(2);
2084DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002085DEFINE_CAPMIX_NOSRC(1);
2086DEFINE_CAPMIX_NOSRC(2);
2087DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002088
2089/*
2090 * ALC880 5-stack model
2091 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002092 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2093 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002094 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2095 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2096 */
2097
2098/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002099static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002100 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002101 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002102 { } /* end */
2103};
2104
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002105/* channel source setting (6/8 channel selection for 5-stack) */
2106/* 6ch mode */
2107static struct hda_verb alc880_fivestack_ch6_init[] = {
2108 /* set line-in to input, mute it */
2109 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2110 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002111 { } /* end */
2112};
2113
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002114/* 8ch mode */
2115static struct hda_verb alc880_fivestack_ch8_init[] = {
2116 /* set line-in to output, unmute it */
2117 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2118 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2119 { } /* end */
2120};
2121
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002122static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002123 { 6, alc880_fivestack_ch6_init },
2124 { 8, alc880_fivestack_ch8_init },
2125};
2126
2127
2128/*
2129 * ALC880 6-stack model
2130 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002131 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2132 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002133 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2134 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2135 */
2136
2137static hda_nid_t alc880_6st_dac_nids[4] = {
2138 /* front, rear, clfe, rear_surr */
2139 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002140};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002141
2142static struct hda_input_mux alc880_6stack_capture_source = {
2143 .num_items = 4,
2144 .items = {
2145 { "Mic", 0x0 },
2146 { "Front Mic", 0x1 },
2147 { "Line", 0x2 },
2148 { "CD", 0x4 },
2149 },
2150};
2151
2152/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002153static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002154 { 8, NULL },
2155};
2156
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002157static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002158 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002159 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002160 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002161 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002162 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2163 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002164 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2165 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002166 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002167 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002168 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2169 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2170 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2171 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2172 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2173 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2174 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2175 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002176 {
2177 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2178 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002179 .info = alc_ch_mode_info,
2180 .get = alc_ch_mode_get,
2181 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002182 },
2183 { } /* end */
2184};
2185
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002186
2187/*
2188 * ALC880 W810 model
2189 *
2190 * W810 has rear IO for:
2191 * Front (DAC 02)
2192 * Surround (DAC 03)
2193 * Center/LFE (DAC 04)
2194 * Digital out (06)
2195 *
2196 * The system also has a pair of internal speakers, and a headphone jack.
2197 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002198 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002199 * There is a variable resistor to control the speaker or headphone
2200 * volume. This is a hardware-only device without a software API.
2201 *
2202 * Plugging headphones in will disable the internal speakers. This is
2203 * implemented in hardware, not via the driver using jack sense. In
2204 * a similar fashion, plugging into the rear socket marked "front" will
2205 * disable both the speakers and headphones.
2206 *
2207 * For input, there's a microphone jack, and an "audio in" jack.
2208 * These may not do anything useful with this driver yet, because I
2209 * haven't setup any initialization verbs for these yet...
2210 */
2211
2212static hda_nid_t alc880_w810_dac_nids[3] = {
2213 /* front, rear/surround, clfe */
2214 0x02, 0x03, 0x04
2215};
2216
2217/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002218static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002219 { 6, NULL }
2220};
2221
2222/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002223static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002224 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002225 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002226 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002227 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002228 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2229 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002230 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2231 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002232 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2233 { } /* end */
2234};
2235
2236
2237/*
2238 * Z710V model
2239 *
2240 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002241 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2242 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002243 */
2244
2245static hda_nid_t alc880_z71v_dac_nids[1] = {
2246 0x02
2247};
2248#define ALC880_Z71V_HP_DAC 0x03
2249
2250/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002251static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002252 { 2, NULL }
2253};
2254
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002255static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002256 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002257 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002258 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002259 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002260 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2261 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2262 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2263 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2264 { } /* end */
2265};
2266
2267
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002268/*
2269 * ALC880 F1734 model
2270 *
2271 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2272 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2273 */
2274
2275static hda_nid_t alc880_f1734_dac_nids[1] = {
2276 0x03
2277};
2278#define ALC880_F1734_HP_DAC 0x02
2279
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002280static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002281 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002282 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002283 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2284 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002285 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2286 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002287 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2288 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002289 { } /* end */
2290};
2291
Takashi Iwai937b4162008-02-11 14:52:36 +01002292static struct hda_input_mux alc880_f1734_capture_source = {
2293 .num_items = 2,
2294 .items = {
2295 { "Mic", 0x1 },
2296 { "CD", 0x4 },
2297 },
2298};
2299
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002300
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002301/*
2302 * ALC880 ASUS model
2303 *
2304 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2305 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2306 * Mic = 0x18, Line = 0x1a
2307 */
2308
2309#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2310#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2311
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002312static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002313 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002314 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002315 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002316 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002317 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2318 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002319 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2320 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002321 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2322 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2323 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2324 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2325 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2326 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002327 {
2328 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2329 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002330 .info = alc_ch_mode_info,
2331 .get = alc_ch_mode_get,
2332 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002333 },
2334 { } /* end */
2335};
2336
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002337/*
2338 * ALC880 ASUS W1V model
2339 *
2340 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2341 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2342 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2343 */
2344
2345/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002346static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002347 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2348 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002349 { } /* end */
2350};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002351
Kailang Yangdf694da2005-12-05 19:42:22 +01002352/* TCL S700 */
2353static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2354 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2355 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2356 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2357 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2358 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2359 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2360 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2361 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2362 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002363 { } /* end */
2364};
2365
Kailang Yangccc656c2006-10-17 12:32:26 +02002366/* Uniwill */
2367static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002368 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2369 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2370 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2371 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002372 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2373 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2374 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2375 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2376 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2377 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2378 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2379 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2380 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2381 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2382 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2383 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002384 {
2385 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2386 .name = "Channel Mode",
2387 .info = alc_ch_mode_info,
2388 .get = alc_ch_mode_get,
2389 .put = alc_ch_mode_put,
2390 },
2391 { } /* end */
2392};
2393
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002394static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2395 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2396 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2397 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2398 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2399 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2400 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2401 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2402 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2403 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2404 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2405 { } /* end */
2406};
2407
Kailang Yangccc656c2006-10-17 12:32:26 +02002408static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002409 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2410 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2411 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2412 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002413 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2414 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2415 { } /* end */
2416};
2417
Linus Torvalds1da177e2005-04-16 15:20:36 -07002418/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002419 * virtual master controls
2420 */
2421
2422/*
2423 * slave controls for virtual master
2424 */
2425static const char *alc_slave_vols[] = {
2426 "Front Playback Volume",
2427 "Surround Playback Volume",
2428 "Center Playback Volume",
2429 "LFE Playback Volume",
2430 "Side Playback Volume",
2431 "Headphone Playback Volume",
2432 "Speaker Playback Volume",
2433 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002434 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002435 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002436 NULL,
2437};
2438
2439static const char *alc_slave_sws[] = {
2440 "Front Playback Switch",
2441 "Surround Playback Switch",
2442 "Center Playback Switch",
2443 "LFE Playback Switch",
2444 "Side Playback Switch",
2445 "Headphone Playback Switch",
2446 "Speaker Playback Switch",
2447 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002448 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002449 "Line-Out Playback Switch",
2450 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002451 NULL,
2452};
2453
2454/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002455 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002456 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002457
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002458#define NID_MAPPING (-1)
2459
2460#define SUBDEV_SPEAKER_ (0 << 6)
2461#define SUBDEV_HP_ (1 << 6)
2462#define SUBDEV_LINE_ (2 << 6)
2463#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2464#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2465#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2466
Takashi Iwai603c4012008-07-30 15:01:44 +02002467static void alc_free_kctls(struct hda_codec *codec);
2468
Takashi Iwai67d634c2009-11-16 15:35:59 +01002469#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002470/* additional beep mixers; the actual parameters are overwritten at build */
2471static struct snd_kcontrol_new alc_beep_mixer[] = {
2472 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002473 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002474 { } /* end */
2475};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002476#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002477
Linus Torvalds1da177e2005-04-16 15:20:36 -07002478static int alc_build_controls(struct hda_codec *codec)
2479{
2480 struct alc_spec *spec = codec->spec;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002481 struct snd_kcontrol *kctl;
2482 struct snd_kcontrol_new *knew;
2483 int i, j, err;
2484 unsigned int u;
2485 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002486
2487 for (i = 0; i < spec->num_mixers; i++) {
2488 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2489 if (err < 0)
2490 return err;
2491 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002492 if (spec->cap_mixer) {
2493 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2494 if (err < 0)
2495 return err;
2496 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002497 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002498 err = snd_hda_create_spdif_out_ctls(codec,
2499 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002500 if (err < 0)
2501 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002502 if (!spec->no_analog) {
2503 err = snd_hda_create_spdif_share_sw(codec,
2504 &spec->multiout);
2505 if (err < 0)
2506 return err;
2507 spec->multiout.share_spdif = 1;
2508 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002509 }
2510 if (spec->dig_in_nid) {
2511 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2512 if (err < 0)
2513 return err;
2514 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002515
Takashi Iwai67d634c2009-11-16 15:35:59 +01002516#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002517 /* create beep controls if needed */
2518 if (spec->beep_amp) {
2519 struct snd_kcontrol_new *knew;
2520 for (knew = alc_beep_mixer; knew->name; knew++) {
2521 struct snd_kcontrol *kctl;
2522 kctl = snd_ctl_new1(knew, codec);
2523 if (!kctl)
2524 return -ENOMEM;
2525 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002526 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002527 if (err < 0)
2528 return err;
2529 }
2530 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002531#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002532
Takashi Iwai2134ea42008-01-10 16:53:55 +01002533 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002534 if (!spec->no_analog &&
2535 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002536 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002537 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002538 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002539 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002540 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002541 if (err < 0)
2542 return err;
2543 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002544 if (!spec->no_analog &&
2545 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002546 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2547 NULL, alc_slave_sws);
2548 if (err < 0)
2549 return err;
2550 }
2551
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002552 /* assign Capture Source enums to NID */
2553 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2554 if (!kctl)
2555 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2556 for (i = 0; kctl && i < kctl->count; i++) {
Takashi Iwaid1409ae2009-12-17 15:01:31 +01002557 hda_nid_t *nids = spec->capsrc_nids;
2558 if (!nids)
2559 nids = spec->adc_nids;
Takashi Iwai21949f02009-12-23 08:31:59 +01002560 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002561 if (err < 0)
2562 return err;
2563 }
2564 if (spec->cap_mixer) {
2565 const char *kname = kctl ? kctl->id.name : NULL;
2566 for (knew = spec->cap_mixer; knew->name; knew++) {
2567 if (kname && strcmp(knew->name, kname) == 0)
2568 continue;
2569 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2570 for (i = 0; kctl && i < kctl->count; i++) {
2571 err = snd_hda_add_nid(codec, kctl, i,
2572 spec->adc_nids[i]);
2573 if (err < 0)
2574 return err;
2575 }
2576 }
2577 }
2578
2579 /* other nid->control mapping */
2580 for (i = 0; i < spec->num_mixers; i++) {
2581 for (knew = spec->mixers[i]; knew->name; knew++) {
2582 if (knew->iface != NID_MAPPING)
2583 continue;
2584 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2585 if (kctl == NULL)
2586 continue;
2587 u = knew->subdevice;
2588 for (j = 0; j < 4; j++, u >>= 8) {
2589 nid = u & 0x3f;
2590 if (nid == 0)
2591 continue;
2592 switch (u & 0xc0) {
2593 case SUBDEV_SPEAKER_:
2594 nid = spec->autocfg.speaker_pins[nid];
2595 break;
2596 case SUBDEV_LINE_:
2597 nid = spec->autocfg.line_out_pins[nid];
2598 break;
2599 case SUBDEV_HP_:
2600 nid = spec->autocfg.hp_pins[nid];
2601 break;
2602 default:
2603 continue;
2604 }
2605 err = snd_hda_add_nid(codec, kctl, 0, nid);
2606 if (err < 0)
2607 return err;
2608 }
2609 u = knew->private_value;
2610 for (j = 0; j < 4; j++, u >>= 8) {
2611 nid = u & 0xff;
2612 if (nid == 0)
2613 continue;
2614 err = snd_hda_add_nid(codec, kctl, 0, nid);
2615 if (err < 0)
2616 return err;
2617 }
2618 }
2619 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01002620
2621 alc_free_kctls(codec); /* no longer needed */
2622
Linus Torvalds1da177e2005-04-16 15:20:36 -07002623 return 0;
2624}
2625
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002626
Linus Torvalds1da177e2005-04-16 15:20:36 -07002627/*
2628 * initialize the codec volumes, etc
2629 */
2630
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002631/*
2632 * generic initialization of ADC, input mixers and output mixers
2633 */
2634static struct hda_verb alc880_volume_init_verbs[] = {
2635 /*
2636 * Unmute ADC0-2 and set the default input to mic-in
2637 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002638 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002639 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002640 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002641 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002642 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002643 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002644
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002645 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2646 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002647 * Note: PASD motherboards uses the Line In 2 as the input for front
2648 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002649 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002650 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002651 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2652 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2653 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2654 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2655 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2656 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2657 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002658
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002659 /*
2660 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002661 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002662 /* set vol=0 to output mixers */
2663 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2664 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2665 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2666 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2667 /* set up input amps for analog loopback */
2668 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002669 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2670 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002671 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2672 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002673 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2674 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002675 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2676 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002677
2678 { }
2679};
2680
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002681/*
2682 * 3-stack pin configuration:
2683 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2684 */
2685static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2686 /*
2687 * preset connection lists of input pins
2688 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2689 */
2690 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2691 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2692 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2693
2694 /*
2695 * Set pin mode and muting
2696 */
2697 /* set front pin widgets 0x14 for output */
2698 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2699 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2700 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2701 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2702 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2703 /* Mic2 (as headphone out) for HP output */
2704 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2705 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2706 /* Line In pin widget for input */
2707 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2708 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2709 /* Line2 (as front mic) pin widget for input and vref at 80% */
2710 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2711 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2712 /* CD pin widget for input */
2713 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2714
2715 { }
2716};
2717
2718/*
2719 * 5-stack pin configuration:
2720 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2721 * line-in/side = 0x1a, f-mic = 0x1b
2722 */
2723static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2724 /*
2725 * preset connection lists of input pins
2726 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2727 */
2728 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2729 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2730
2731 /*
2732 * Set pin mode and muting
2733 */
2734 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002735 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2736 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2737 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2738 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002739 /* unmute pins for output (no gain on this amp) */
2740 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2741 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2742 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2743 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2744
Linus Torvalds1da177e2005-04-16 15:20:36 -07002745 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002746 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002747 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2748 /* Mic2 (as headphone out) for HP output */
2749 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002750 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002751 /* Line In pin widget for input */
2752 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2753 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2754 /* Line2 (as front mic) pin widget for input and vref at 80% */
2755 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2756 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2757 /* CD pin widget for input */
2758 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002759
2760 { }
2761};
2762
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002763/*
2764 * W810 pin configuration:
2765 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2766 */
2767static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002768 /* hphone/speaker input selector: front DAC */
2769 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2770
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002771 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2772 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2773 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2774 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2775 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2776 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2777
2778 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002779 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002780
Linus Torvalds1da177e2005-04-16 15:20:36 -07002781 { }
2782};
2783
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002784/*
2785 * Z71V pin configuration:
2786 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2787 */
2788static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002789 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002790 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002791 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002792 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002793
Takashi Iwai16ded522005-06-10 19:58:24 +02002794 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002795 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002796 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002797 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002798
2799 { }
2800};
2801
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002802/*
2803 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002804 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2805 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002806 */
2807static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2808 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2809
Takashi Iwai16ded522005-06-10 19:58:24 +02002810 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002811 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002812 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002813 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002814 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002815 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002816 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002817 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2818
Takashi Iwai16ded522005-06-10 19:58:24 +02002819 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002820 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002821 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002822 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002823 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002824 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002825 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002826 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002827 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002828
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002829 { }
2830};
Takashi Iwai16ded522005-06-10 19:58:24 +02002831
Kailang Yangccc656c2006-10-17 12:32:26 +02002832/*
2833 * Uniwill pin configuration:
2834 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2835 * line = 0x1a
2836 */
2837static struct hda_verb alc880_uniwill_init_verbs[] = {
2838 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2839
2840 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2841 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2842 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2843 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2844 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2845 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2846 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2847 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2848 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2849 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2850 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2851 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2852 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2853 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2854
2855 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2856 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2857 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2858 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2859 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2860 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2861 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2862 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2863 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2864
2865 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2866 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2867
2868 { }
2869};
2870
2871/*
2872* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002873* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002874 */
2875static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2876 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2877
2878 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2879 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2880 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2881 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2882 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2883 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2884 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2885 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2886 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2887 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2888 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2889 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2890
2891 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2892 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2893 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2894 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2895 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2896 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2897
2898 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2899 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2900
2901 { }
2902};
2903
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002904static struct hda_verb alc880_beep_init_verbs[] = {
2905 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2906 { }
2907};
2908
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002909/* auto-toggle front mic */
2910static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2911{
2912 unsigned int present;
2913 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002914
Wu Fengguang864f92b2009-11-18 12:38:02 +08002915 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002916 bits = present ? HDA_AMP_MUTE : 0;
2917 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002918}
2919
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002920static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002921{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002922 struct alc_spec *spec = codec->spec;
2923
2924 spec->autocfg.hp_pins[0] = 0x14;
2925 spec->autocfg.speaker_pins[0] = 0x15;
2926 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002927}
2928
2929static void alc880_uniwill_init_hook(struct hda_codec *codec)
2930{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002931 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002932 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002933}
2934
2935static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2936 unsigned int res)
2937{
2938 /* Looks like the unsol event is incompatible with the standard
2939 * definition. 4bit tag is placed at 28 bit!
2940 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002941 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002942 case ALC880_MIC_EVENT:
2943 alc880_uniwill_mic_automute(codec);
2944 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002945 default:
2946 alc_automute_amp_unsol_event(codec, res);
2947 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002948 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002949}
2950
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002951static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002952{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002953 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002954
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002955 spec->autocfg.hp_pins[0] = 0x14;
2956 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002957}
2958
2959static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2960{
2961 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002962
Kailang Yangccc656c2006-10-17 12:32:26 +02002963 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002964 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2965 present &= HDA_AMP_VOLMASK;
2966 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2967 HDA_AMP_VOLMASK, present);
2968 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2969 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002970}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002971
Kailang Yangccc656c2006-10-17 12:32:26 +02002972static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2973 unsigned int res)
2974{
2975 /* Looks like the unsol event is incompatible with the standard
2976 * definition. 4bit tag is placed at 28 bit!
2977 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002978 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002979 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002980 else
2981 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002982}
2983
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002984/*
2985 * F1734 pin configuration:
2986 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2987 */
2988static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002989 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002990 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2991 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2992 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2993 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2994
2995 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2996 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2997 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2998 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2999
3000 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3001 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003002 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003003 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3004 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3005 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3006 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3007 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3008 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003009
Takashi Iwai937b4162008-02-11 14:52:36 +01003010 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3011 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3012
Takashi Iwai16ded522005-06-10 19:58:24 +02003013 { }
3014};
3015
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003016/*
3017 * ASUS pin configuration:
3018 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3019 */
3020static struct hda_verb alc880_pin_asus_init_verbs[] = {
3021 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3022 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3023 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3024 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3025
3026 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3027 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3028 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3029 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3030 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3031 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3032 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3033 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3034
3035 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3036 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3037 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3038 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3039 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3040 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3041 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3042 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3043 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003044
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003045 { }
3046};
3047
3048/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003049#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3050#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003051#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003052
Kailang Yangdf694da2005-12-05 19:42:22 +01003053/* Clevo m520g init */
3054static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3055 /* headphone output */
3056 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3057 /* line-out */
3058 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3059 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3060 /* Line-in */
3061 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3062 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3063 /* CD */
3064 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3065 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3066 /* Mic1 (rear panel) */
3067 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3068 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3069 /* Mic2 (front panel) */
3070 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3071 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3072 /* headphone */
3073 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3074 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3075 /* change to EAPD mode */
3076 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3077 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3078
3079 { }
3080};
3081
3082static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003083 /* change to EAPD mode */
3084 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3085 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3086
Kailang Yangdf694da2005-12-05 19:42:22 +01003087 /* Headphone output */
3088 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3089 /* Front output*/
3090 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3091 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3092
3093 /* Line In pin widget for input */
3094 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3095 /* CD pin widget for input */
3096 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3097 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3098 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3099
3100 /* change to EAPD mode */
3101 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3102 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3103
3104 { }
3105};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003106
3107/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003108 * LG m1 express dual
3109 *
3110 * Pin assignment:
3111 * Rear Line-In/Out (blue): 0x14
3112 * Build-in Mic-In: 0x15
3113 * Speaker-out: 0x17
3114 * HP-Out (green): 0x1b
3115 * Mic-In/Out (red): 0x19
3116 * SPDIF-Out: 0x1e
3117 */
3118
3119/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3120static hda_nid_t alc880_lg_dac_nids[3] = {
3121 0x05, 0x02, 0x03
3122};
3123
3124/* seems analog CD is not working */
3125static struct hda_input_mux alc880_lg_capture_source = {
3126 .num_items = 3,
3127 .items = {
3128 { "Mic", 0x1 },
3129 { "Line", 0x5 },
3130 { "Internal Mic", 0x6 },
3131 },
3132};
3133
3134/* 2,4,6 channel modes */
3135static struct hda_verb alc880_lg_ch2_init[] = {
3136 /* set line-in and mic-in to input */
3137 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3138 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3139 { }
3140};
3141
3142static struct hda_verb alc880_lg_ch4_init[] = {
3143 /* set line-in to out and mic-in to input */
3144 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3145 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3146 { }
3147};
3148
3149static struct hda_verb alc880_lg_ch6_init[] = {
3150 /* set line-in and mic-in to output */
3151 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3152 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3153 { }
3154};
3155
3156static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3157 { 2, alc880_lg_ch2_init },
3158 { 4, alc880_lg_ch4_init },
3159 { 6, alc880_lg_ch6_init },
3160};
3161
3162static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003163 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3164 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003165 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3166 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3167 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3168 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3169 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3170 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3171 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3172 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3173 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3174 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3175 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3176 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3177 {
3178 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3179 .name = "Channel Mode",
3180 .info = alc_ch_mode_info,
3181 .get = alc_ch_mode_get,
3182 .put = alc_ch_mode_put,
3183 },
3184 { } /* end */
3185};
3186
3187static struct hda_verb alc880_lg_init_verbs[] = {
3188 /* set capture source to mic-in */
3189 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3190 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3191 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3192 /* mute all amp mixer inputs */
3193 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003194 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3195 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003196 /* line-in to input */
3197 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3198 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3199 /* built-in mic */
3200 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3201 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3202 /* speaker-out */
3203 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3204 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3205 /* mic-in to input */
3206 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3207 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3208 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3209 /* HP-out */
3210 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3211 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3212 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3213 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003214 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003215 { }
3216};
3217
3218/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003219static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003220{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003221 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003222
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003223 spec->autocfg.hp_pins[0] = 0x1b;
3224 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003225}
3226
3227/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003228 * LG LW20
3229 *
3230 * Pin assignment:
3231 * Speaker-out: 0x14
3232 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003233 * Built-in Mic-In: 0x19
3234 * Line-In: 0x1b
3235 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003236 * SPDIF-Out: 0x1e
3237 */
3238
Takashi Iwaid6815182006-03-23 16:06:23 +01003239static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003240 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003241 .items = {
3242 { "Mic", 0x0 },
3243 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003244 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003245 },
3246};
3247
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003248#define alc880_lg_lw_modes alc880_threestack_modes
3249
Takashi Iwaid6815182006-03-23 16:06:23 +01003250static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003251 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3252 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3253 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3254 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3255 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3256 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3257 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3258 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3259 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3260 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003261 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3262 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3263 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3264 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003265 {
3266 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3267 .name = "Channel Mode",
3268 .info = alc_ch_mode_info,
3269 .get = alc_ch_mode_get,
3270 .put = alc_ch_mode_put,
3271 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003272 { } /* end */
3273};
3274
3275static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003276 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3277 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3278 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3279
Takashi Iwaid6815182006-03-23 16:06:23 +01003280 /* set capture source to mic-in */
3281 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3282 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3283 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003284 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003285 /* speaker-out */
3286 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3287 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3288 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003289 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3290 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3291 /* mic-in to input */
3292 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3293 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3294 /* built-in mic */
3295 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3296 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3297 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003298 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003299 { }
3300};
3301
3302/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003303static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003304{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003305 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003306
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003307 spec->autocfg.hp_pins[0] = 0x1b;
3308 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003309}
3310
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003311static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3312 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3313 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3314 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3315 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3316 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3317 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3318 { } /* end */
3319};
3320
3321static struct hda_input_mux alc880_medion_rim_capture_source = {
3322 .num_items = 2,
3323 .items = {
3324 { "Mic", 0x0 },
3325 { "Internal Mic", 0x1 },
3326 },
3327};
3328
3329static struct hda_verb alc880_medion_rim_init_verbs[] = {
3330 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3331
3332 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3333 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3334
3335 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3336 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3337 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3338 /* Mic2 (as headphone out) for HP output */
3339 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3340 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3341 /* Internal Speaker */
3342 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3343 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3344
3345 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3346 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3347
3348 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3349 { }
3350};
3351
3352/* toggle speaker-output according to the hp-jack state */
3353static void alc880_medion_rim_automute(struct hda_codec *codec)
3354{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003355 struct alc_spec *spec = codec->spec;
3356 alc_automute_amp(codec);
3357 /* toggle EAPD */
3358 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003359 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3360 else
3361 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3362}
3363
3364static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3365 unsigned int res)
3366{
3367 /* Looks like the unsol event is incompatible with the standard
3368 * definition. 4bit tag is placed at 28 bit!
3369 */
3370 if ((res >> 28) == ALC880_HP_EVENT)
3371 alc880_medion_rim_automute(codec);
3372}
3373
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003374static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003375{
3376 struct alc_spec *spec = codec->spec;
3377
3378 spec->autocfg.hp_pins[0] = 0x14;
3379 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003380}
3381
Takashi Iwaicb53c622007-08-10 17:21:45 +02003382#ifdef CONFIG_SND_HDA_POWER_SAVE
3383static struct hda_amp_list alc880_loopbacks[] = {
3384 { 0x0b, HDA_INPUT, 0 },
3385 { 0x0b, HDA_INPUT, 1 },
3386 { 0x0b, HDA_INPUT, 2 },
3387 { 0x0b, HDA_INPUT, 3 },
3388 { 0x0b, HDA_INPUT, 4 },
3389 { } /* end */
3390};
3391
3392static struct hda_amp_list alc880_lg_loopbacks[] = {
3393 { 0x0b, HDA_INPUT, 1 },
3394 { 0x0b, HDA_INPUT, 6 },
3395 { 0x0b, HDA_INPUT, 7 },
3396 { } /* end */
3397};
3398#endif
3399
Takashi Iwaid6815182006-03-23 16:06:23 +01003400/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003401 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003402 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003403
Linus Torvalds1da177e2005-04-16 15:20:36 -07003404static int alc_init(struct hda_codec *codec)
3405{
3406 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003407 unsigned int i;
3408
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003409 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003410 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003411
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003412 for (i = 0; i < spec->num_init_verbs; i++)
3413 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003414
3415 if (spec->init_hook)
3416 spec->init_hook(codec);
3417
Linus Torvalds1da177e2005-04-16 15:20:36 -07003418 return 0;
3419}
3420
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003421static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3422{
3423 struct alc_spec *spec = codec->spec;
3424
3425 if (spec->unsol_event)
3426 spec->unsol_event(codec, res);
3427}
3428
Takashi Iwaicb53c622007-08-10 17:21:45 +02003429#ifdef CONFIG_SND_HDA_POWER_SAVE
3430static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3431{
3432 struct alc_spec *spec = codec->spec;
3433 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3434}
3435#endif
3436
Linus Torvalds1da177e2005-04-16 15:20:36 -07003437/*
3438 * Analog playback callbacks
3439 */
3440static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3441 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003442 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003443{
3444 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003445 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3446 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003447}
3448
3449static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3450 struct hda_codec *codec,
3451 unsigned int stream_tag,
3452 unsigned int format,
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;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003456 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3457 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003458}
3459
3460static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3461 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003462 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003463{
3464 struct alc_spec *spec = codec->spec;
3465 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3466}
3467
3468/*
3469 * Digital out
3470 */
3471static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3472 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003473 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003474{
3475 struct alc_spec *spec = codec->spec;
3476 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3477}
3478
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003479static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3480 struct hda_codec *codec,
3481 unsigned int stream_tag,
3482 unsigned int format,
3483 struct snd_pcm_substream *substream)
3484{
3485 struct alc_spec *spec = codec->spec;
3486 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3487 stream_tag, format, substream);
3488}
3489
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003490static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3491 struct hda_codec *codec,
3492 struct snd_pcm_substream *substream)
3493{
3494 struct alc_spec *spec = codec->spec;
3495 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3496}
3497
Linus Torvalds1da177e2005-04-16 15:20:36 -07003498static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3499 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003500 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003501{
3502 struct alc_spec *spec = codec->spec;
3503 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3504}
3505
3506/*
3507 * Analog capture
3508 */
Takashi Iwai63300792008-01-24 15:31:36 +01003509static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003510 struct hda_codec *codec,
3511 unsigned int stream_tag,
3512 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003513 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003514{
3515 struct alc_spec *spec = codec->spec;
3516
Takashi Iwai63300792008-01-24 15:31:36 +01003517 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003518 stream_tag, 0, format);
3519 return 0;
3520}
3521
Takashi Iwai63300792008-01-24 15:31:36 +01003522static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003523 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003524 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003525{
3526 struct alc_spec *spec = codec->spec;
3527
Takashi Iwai888afa12008-03-18 09:57:50 +01003528 snd_hda_codec_cleanup_stream(codec,
3529 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003530 return 0;
3531}
3532
3533
3534/*
3535 */
3536static struct hda_pcm_stream alc880_pcm_analog_playback = {
3537 .substreams = 1,
3538 .channels_min = 2,
3539 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003540 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003541 .ops = {
3542 .open = alc880_playback_pcm_open,
3543 .prepare = alc880_playback_pcm_prepare,
3544 .cleanup = alc880_playback_pcm_cleanup
3545 },
3546};
3547
3548static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003549 .substreams = 1,
3550 .channels_min = 2,
3551 .channels_max = 2,
3552 /* NID is set in alc_build_pcms */
3553};
3554
3555static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3556 .substreams = 1,
3557 .channels_min = 2,
3558 .channels_max = 2,
3559 /* NID is set in alc_build_pcms */
3560};
3561
3562static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3563 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003564 .channels_min = 2,
3565 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003566 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003567 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003568 .prepare = alc880_alt_capture_pcm_prepare,
3569 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003570 },
3571};
3572
3573static struct hda_pcm_stream alc880_pcm_digital_playback = {
3574 .substreams = 1,
3575 .channels_min = 2,
3576 .channels_max = 2,
3577 /* NID is set in alc_build_pcms */
3578 .ops = {
3579 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003580 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003581 .prepare = alc880_dig_playback_pcm_prepare,
3582 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003583 },
3584};
3585
3586static struct hda_pcm_stream alc880_pcm_digital_capture = {
3587 .substreams = 1,
3588 .channels_min = 2,
3589 .channels_max = 2,
3590 /* NID is set in alc_build_pcms */
3591};
3592
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003593/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003594static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003595 .substreams = 0,
3596 .channels_min = 0,
3597 .channels_max = 0,
3598};
3599
Linus Torvalds1da177e2005-04-16 15:20:36 -07003600static int alc_build_pcms(struct hda_codec *codec)
3601{
3602 struct alc_spec *spec = codec->spec;
3603 struct hda_pcm *info = spec->pcm_rec;
3604 int i;
3605
3606 codec->num_pcms = 1;
3607 codec->pcm_info = info;
3608
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003609 if (spec->no_analog)
3610 goto skip_analog;
3611
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003612 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3613 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003614 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003615
Takashi Iwai4a471b72005-12-07 13:56:29 +01003616 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003617 if (snd_BUG_ON(!spec->multiout.dac_nids))
3618 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003619 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3620 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3621 }
3622 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003623 if (snd_BUG_ON(!spec->adc_nids))
3624 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003625 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3626 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3627 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003628
Takashi Iwai4a471b72005-12-07 13:56:29 +01003629 if (spec->channel_mode) {
3630 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3631 for (i = 0; i < spec->num_channel_mode; i++) {
3632 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3633 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3634 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003635 }
3636 }
3637
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003638 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003639 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003640 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003641 snprintf(spec->stream_name_digital,
3642 sizeof(spec->stream_name_digital),
3643 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003644 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003645 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003646 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003647 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003648 if (spec->dig_out_type)
3649 info->pcm_type = spec->dig_out_type;
3650 else
3651 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003652 if (spec->multiout.dig_out_nid &&
3653 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003654 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3655 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3656 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003657 if (spec->dig_in_nid &&
3658 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003659 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3660 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3661 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003662 /* FIXME: do we need this for all Realtek codec models? */
3663 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003664 }
3665
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003666 if (spec->no_analog)
3667 return 0;
3668
Takashi Iwaie08a0072006-09-07 17:52:14 +02003669 /* If the use of more than one ADC is requested for the current
3670 * model, configure a second analog capture-only PCM.
3671 */
3672 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003673 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3674 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003675 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003676 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003677 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003678 if (spec->alt_dac_nid) {
3679 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3680 *spec->stream_analog_alt_playback;
3681 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3682 spec->alt_dac_nid;
3683 } else {
3684 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3685 alc_pcm_null_stream;
3686 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3687 }
3688 if (spec->num_adc_nids > 1) {
3689 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3690 *spec->stream_analog_alt_capture;
3691 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3692 spec->adc_nids[1];
3693 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3694 spec->num_adc_nids - 1;
3695 } else {
3696 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3697 alc_pcm_null_stream;
3698 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003699 }
3700 }
3701
Linus Torvalds1da177e2005-04-16 15:20:36 -07003702 return 0;
3703}
3704
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003705static inline void alc_shutup(struct hda_codec *codec)
3706{
3707 snd_hda_shutup_pins(codec);
3708}
3709
Takashi Iwai603c4012008-07-30 15:01:44 +02003710static void alc_free_kctls(struct hda_codec *codec)
3711{
3712 struct alc_spec *spec = codec->spec;
3713
3714 if (spec->kctls.list) {
3715 struct snd_kcontrol_new *kctl = spec->kctls.list;
3716 int i;
3717 for (i = 0; i < spec->kctls.used; i++)
3718 kfree(kctl[i].name);
3719 }
3720 snd_array_free(&spec->kctls);
3721}
3722
Linus Torvalds1da177e2005-04-16 15:20:36 -07003723static void alc_free(struct hda_codec *codec)
3724{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003725 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003726
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003727 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003728 return;
3729
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003730 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02003731 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003732 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003733 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003734}
3735
Hector Martinf5de24b2009-12-20 22:51:31 +01003736#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05003737static void alc_power_eapd(struct hda_codec *codec)
3738{
3739 /* We currently only handle front, HP */
3740 switch (codec->vendor_id) {
3741 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003742 set_eapd(codec, 0x0f, 0);
3743 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003744 break;
3745 case 0x10ec0262:
3746 case 0x10ec0267:
3747 case 0x10ec0268:
3748 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003749 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05003750 case 0x10ec0272:
3751 case 0x10ec0660:
3752 case 0x10ec0662:
3753 case 0x10ec0663:
3754 case 0x10ec0862:
3755 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003756 set_eapd(codec, 0x14, 0);
3757 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003758 break;
3759 }
3760}
3761
Hector Martinf5de24b2009-12-20 22:51:31 +01003762static int alc_suspend(struct hda_codec *codec, pm_message_t state)
3763{
3764 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003765 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003766 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05003767 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003768 return 0;
3769}
3770#endif
3771
Takashi Iwaie044c392008-10-27 16:56:24 +01003772#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003773static int alc_resume(struct hda_codec *codec)
3774{
Takashi Iwaie044c392008-10-27 16:56:24 +01003775 codec->patch_ops.init(codec);
3776 snd_hda_codec_resume_amp(codec);
3777 snd_hda_codec_resume_cache(codec);
3778 return 0;
3779}
Takashi Iwaie044c392008-10-27 16:56:24 +01003780#endif
3781
Linus Torvalds1da177e2005-04-16 15:20:36 -07003782/*
3783 */
3784static struct hda_codec_ops alc_patch_ops = {
3785 .build_controls = alc_build_controls,
3786 .build_pcms = alc_build_pcms,
3787 .init = alc_init,
3788 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003789 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003790#ifdef SND_HDA_NEEDS_RESUME
3791 .resume = alc_resume,
3792#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003793#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01003794 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003795 .check_power_status = alc_check_power_status,
3796#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05003797 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003798};
3799
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003800
3801/*
3802 * Test configuration for debugging
3803 *
3804 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3805 * enum controls.
3806 */
3807#ifdef CONFIG_SND_DEBUG
3808static hda_nid_t alc880_test_dac_nids[4] = {
3809 0x02, 0x03, 0x04, 0x05
3810};
3811
3812static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003813 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003814 .items = {
3815 { "In-1", 0x0 },
3816 { "In-2", 0x1 },
3817 { "In-3", 0x2 },
3818 { "In-4", 0x3 },
3819 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003820 { "Front", 0x5 },
3821 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003822 },
3823};
3824
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003825static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003826 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003827 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003828 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003829 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003830};
3831
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003832static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3833 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003834{
3835 static char *texts[] = {
3836 "N/A", "Line Out", "HP Out",
3837 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3838 };
3839 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3840 uinfo->count = 1;
3841 uinfo->value.enumerated.items = 8;
3842 if (uinfo->value.enumerated.item >= 8)
3843 uinfo->value.enumerated.item = 7;
3844 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3845 return 0;
3846}
3847
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003848static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3849 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003850{
3851 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3852 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3853 unsigned int pin_ctl, item = 0;
3854
3855 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3856 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3857 if (pin_ctl & AC_PINCTL_OUT_EN) {
3858 if (pin_ctl & AC_PINCTL_HP_EN)
3859 item = 2;
3860 else
3861 item = 1;
3862 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3863 switch (pin_ctl & AC_PINCTL_VREFEN) {
3864 case AC_PINCTL_VREF_HIZ: item = 3; break;
3865 case AC_PINCTL_VREF_50: item = 4; break;
3866 case AC_PINCTL_VREF_GRD: item = 5; break;
3867 case AC_PINCTL_VREF_80: item = 6; break;
3868 case AC_PINCTL_VREF_100: item = 7; break;
3869 }
3870 }
3871 ucontrol->value.enumerated.item[0] = item;
3872 return 0;
3873}
3874
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003875static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3876 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003877{
3878 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3879 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3880 static unsigned int ctls[] = {
3881 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3882 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3883 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3884 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3885 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3886 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3887 };
3888 unsigned int old_ctl, new_ctl;
3889
3890 old_ctl = snd_hda_codec_read(codec, nid, 0,
3891 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3892 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3893 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003894 int val;
3895 snd_hda_codec_write_cache(codec, nid, 0,
3896 AC_VERB_SET_PIN_WIDGET_CONTROL,
3897 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003898 val = ucontrol->value.enumerated.item[0] >= 3 ?
3899 HDA_AMP_MUTE : 0;
3900 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3901 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003902 return 1;
3903 }
3904 return 0;
3905}
3906
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003907static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3908 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003909{
3910 static char *texts[] = {
3911 "Front", "Surround", "CLFE", "Side"
3912 };
3913 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3914 uinfo->count = 1;
3915 uinfo->value.enumerated.items = 4;
3916 if (uinfo->value.enumerated.item >= 4)
3917 uinfo->value.enumerated.item = 3;
3918 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3919 return 0;
3920}
3921
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003922static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3923 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003924{
3925 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3926 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3927 unsigned int sel;
3928
3929 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3930 ucontrol->value.enumerated.item[0] = sel & 3;
3931 return 0;
3932}
3933
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003934static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3935 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003936{
3937 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3938 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3939 unsigned int sel;
3940
3941 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3942 if (ucontrol->value.enumerated.item[0] != sel) {
3943 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003944 snd_hda_codec_write_cache(codec, nid, 0,
3945 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003946 return 1;
3947 }
3948 return 0;
3949}
3950
3951#define PIN_CTL_TEST(xname,nid) { \
3952 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3953 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003954 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003955 .info = alc_test_pin_ctl_info, \
3956 .get = alc_test_pin_ctl_get, \
3957 .put = alc_test_pin_ctl_put, \
3958 .private_value = nid \
3959 }
3960
3961#define PIN_SRC_TEST(xname,nid) { \
3962 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3963 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003964 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003965 .info = alc_test_pin_src_info, \
3966 .get = alc_test_pin_src_get, \
3967 .put = alc_test_pin_src_put, \
3968 .private_value = nid \
3969 }
3970
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003971static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003972 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3973 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3974 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3975 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003976 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3977 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3978 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3979 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003980 PIN_CTL_TEST("Front Pin Mode", 0x14),
3981 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3982 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3983 PIN_CTL_TEST("Side Pin Mode", 0x17),
3984 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3985 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3986 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3987 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3988 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3989 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3990 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3991 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3992 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3993 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3994 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3995 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3996 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3997 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3998 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3999 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4000 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4001 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004002 {
4003 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4004 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004005 .info = alc_ch_mode_info,
4006 .get = alc_ch_mode_get,
4007 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004008 },
4009 { } /* end */
4010};
4011
4012static struct hda_verb alc880_test_init_verbs[] = {
4013 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004014 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4015 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4016 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4017 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4018 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4019 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4020 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4021 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004022 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004023 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4024 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4025 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4026 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004027 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004028 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4029 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4030 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4031 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004032 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004033 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4034 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4035 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4036 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004037 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004038 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4039 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004040 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4041 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4042 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004043 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004044 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4045 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4046 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4047 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004048 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004049 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004050 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004051 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004052 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004053 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004054 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004055 /* Analog input/passthru */
4056 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4057 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4058 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4059 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4060 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004061 { }
4062};
4063#endif
4064
Linus Torvalds1da177e2005-04-16 15:20:36 -07004065/*
4066 */
4067
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004068static const char *alc880_models[ALC880_MODEL_LAST] = {
4069 [ALC880_3ST] = "3stack",
4070 [ALC880_TCL_S700] = "tcl",
4071 [ALC880_3ST_DIG] = "3stack-digout",
4072 [ALC880_CLEVO] = "clevo",
4073 [ALC880_5ST] = "5stack",
4074 [ALC880_5ST_DIG] = "5stack-digout",
4075 [ALC880_W810] = "w810",
4076 [ALC880_Z71V] = "z71v",
4077 [ALC880_6ST] = "6stack",
4078 [ALC880_6ST_DIG] = "6stack-digout",
4079 [ALC880_ASUS] = "asus",
4080 [ALC880_ASUS_W1V] = "asus-w1v",
4081 [ALC880_ASUS_DIG] = "asus-dig",
4082 [ALC880_ASUS_DIG2] = "asus-dig2",
4083 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004084 [ALC880_UNIWILL_P53] = "uniwill-p53",
4085 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004086 [ALC880_F1734] = "F1734",
4087 [ALC880_LG] = "lg",
4088 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004089 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004090#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004091 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004092#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004093 [ALC880_AUTO] = "auto",
4094};
4095
4096static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004097 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004098 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4099 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4100 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4101 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4102 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4103 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4104 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4105 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004106 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4107 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004108 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4109 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4110 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4111 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4112 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4113 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4114 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4115 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4116 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4117 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004118 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004119 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4120 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4121 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004122 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004123 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004124 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4125 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004126 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4127 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004128 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4129 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4130 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4131 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004132 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4133 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004134 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004135 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004136 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004137 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004138 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4139 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004140 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004141 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004142 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004143 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004144 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004145 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004146 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004147 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004148 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004149 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4150 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004151 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004152 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4153 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4154 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4155 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004156 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4157 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004158 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004159 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004160 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4161 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004162 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4163 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4164 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004165 /* default Intel */
4166 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004167 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4168 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004169 {}
4170};
4171
Takashi Iwai16ded522005-06-10 19:58:24 +02004172/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004173 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004174 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004175static struct alc_config_preset alc880_presets[] = {
4176 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004177 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004178 .init_verbs = { alc880_volume_init_verbs,
4179 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004180 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004181 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004182 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4183 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004184 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004185 .input_mux = &alc880_capture_source,
4186 },
4187 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004188 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004189 .init_verbs = { alc880_volume_init_verbs,
4190 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004191 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004192 .dac_nids = alc880_dac_nids,
4193 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004194 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4195 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004196 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004197 .input_mux = &alc880_capture_source,
4198 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004199 [ALC880_TCL_S700] = {
4200 .mixers = { alc880_tcl_s700_mixer },
4201 .init_verbs = { alc880_volume_init_verbs,
4202 alc880_pin_tcl_S700_init_verbs,
4203 alc880_gpio2_init_verbs },
4204 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4205 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004206 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4207 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004208 .hp_nid = 0x03,
4209 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4210 .channel_mode = alc880_2_jack_modes,
4211 .input_mux = &alc880_capture_source,
4212 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004213 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004214 .mixers = { alc880_three_stack_mixer,
4215 alc880_five_stack_mixer},
4216 .init_verbs = { alc880_volume_init_verbs,
4217 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004218 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4219 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004220 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4221 .channel_mode = alc880_fivestack_modes,
4222 .input_mux = &alc880_capture_source,
4223 },
4224 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004225 .mixers = { alc880_three_stack_mixer,
4226 alc880_five_stack_mixer },
4227 .init_verbs = { alc880_volume_init_verbs,
4228 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004229 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4230 .dac_nids = alc880_dac_nids,
4231 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004232 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4233 .channel_mode = alc880_fivestack_modes,
4234 .input_mux = &alc880_capture_source,
4235 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004236 [ALC880_6ST] = {
4237 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004238 .init_verbs = { alc880_volume_init_verbs,
4239 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004240 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4241 .dac_nids = alc880_6st_dac_nids,
4242 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4243 .channel_mode = alc880_sixstack_modes,
4244 .input_mux = &alc880_6stack_capture_source,
4245 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004246 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004247 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004248 .init_verbs = { alc880_volume_init_verbs,
4249 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004250 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4251 .dac_nids = alc880_6st_dac_nids,
4252 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004253 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4254 .channel_mode = alc880_sixstack_modes,
4255 .input_mux = &alc880_6stack_capture_source,
4256 },
4257 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004258 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004259 .init_verbs = { alc880_volume_init_verbs,
4260 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004261 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004262 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4263 .dac_nids = alc880_w810_dac_nids,
4264 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004265 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4266 .channel_mode = alc880_w810_modes,
4267 .input_mux = &alc880_capture_source,
4268 },
4269 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004270 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004271 .init_verbs = { alc880_volume_init_verbs,
4272 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004273 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4274 .dac_nids = alc880_z71v_dac_nids,
4275 .dig_out_nid = ALC880_DIGOUT_NID,
4276 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004277 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4278 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004279 .input_mux = &alc880_capture_source,
4280 },
4281 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004282 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004283 .init_verbs = { alc880_volume_init_verbs,
4284 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004285 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4286 .dac_nids = alc880_f1734_dac_nids,
4287 .hp_nid = 0x02,
4288 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4289 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004290 .input_mux = &alc880_f1734_capture_source,
4291 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004292 .setup = alc880_uniwill_p53_setup,
4293 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004294 },
4295 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004296 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004297 .init_verbs = { alc880_volume_init_verbs,
4298 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004299 alc880_gpio1_init_verbs },
4300 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4301 .dac_nids = alc880_asus_dac_nids,
4302 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4303 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004304 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004305 .input_mux = &alc880_capture_source,
4306 },
4307 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004308 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004309 .init_verbs = { alc880_volume_init_verbs,
4310 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004311 alc880_gpio1_init_verbs },
4312 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4313 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004314 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004315 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4316 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004317 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004318 .input_mux = &alc880_capture_source,
4319 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004320 [ALC880_ASUS_DIG2] = {
4321 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004322 .init_verbs = { alc880_volume_init_verbs,
4323 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004324 alc880_gpio2_init_verbs }, /* use GPIO2 */
4325 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4326 .dac_nids = alc880_asus_dac_nids,
4327 .dig_out_nid = ALC880_DIGOUT_NID,
4328 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4329 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004330 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004331 .input_mux = &alc880_capture_source,
4332 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004333 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004334 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004335 .init_verbs = { alc880_volume_init_verbs,
4336 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004337 alc880_gpio1_init_verbs },
4338 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4339 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004340 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004341 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4342 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004343 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004344 .input_mux = &alc880_capture_source,
4345 },
4346 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004347 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004348 .init_verbs = { alc880_volume_init_verbs,
4349 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004350 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4351 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004352 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004353 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4354 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004355 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004356 .input_mux = &alc880_capture_source,
4357 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004358 [ALC880_UNIWILL] = {
4359 .mixers = { alc880_uniwill_mixer },
4360 .init_verbs = { alc880_volume_init_verbs,
4361 alc880_uniwill_init_verbs },
4362 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4363 .dac_nids = alc880_asus_dac_nids,
4364 .dig_out_nid = ALC880_DIGOUT_NID,
4365 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4366 .channel_mode = alc880_threestack_modes,
4367 .need_dac_fix = 1,
4368 .input_mux = &alc880_capture_source,
4369 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004370 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004371 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004372 },
4373 [ALC880_UNIWILL_P53] = {
4374 .mixers = { alc880_uniwill_p53_mixer },
4375 .init_verbs = { alc880_volume_init_verbs,
4376 alc880_uniwill_p53_init_verbs },
4377 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4378 .dac_nids = alc880_asus_dac_nids,
4379 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004380 .channel_mode = alc880_threestack_modes,
4381 .input_mux = &alc880_capture_source,
4382 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004383 .setup = alc880_uniwill_p53_setup,
4384 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004385 },
4386 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004387 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004388 .init_verbs = { alc880_volume_init_verbs,
4389 alc880_uniwill_p53_init_verbs,
4390 alc880_beep_init_verbs },
4391 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4392 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004393 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004394 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4395 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004396 .input_mux = &alc880_capture_source,
4397 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004398 .setup = alc880_uniwill_p53_setup,
4399 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004400 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004401 [ALC880_CLEVO] = {
4402 .mixers = { alc880_three_stack_mixer },
4403 .init_verbs = { alc880_volume_init_verbs,
4404 alc880_pin_clevo_init_verbs },
4405 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4406 .dac_nids = alc880_dac_nids,
4407 .hp_nid = 0x03,
4408 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4409 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004410 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004411 .input_mux = &alc880_capture_source,
4412 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004413 [ALC880_LG] = {
4414 .mixers = { alc880_lg_mixer },
4415 .init_verbs = { alc880_volume_init_verbs,
4416 alc880_lg_init_verbs },
4417 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4418 .dac_nids = alc880_lg_dac_nids,
4419 .dig_out_nid = ALC880_DIGOUT_NID,
4420 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4421 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004422 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004423 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004424 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004425 .setup = alc880_lg_setup,
4426 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004427#ifdef CONFIG_SND_HDA_POWER_SAVE
4428 .loopbacks = alc880_lg_loopbacks,
4429#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004430 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004431 [ALC880_LG_LW] = {
4432 .mixers = { alc880_lg_lw_mixer },
4433 .init_verbs = { alc880_volume_init_verbs,
4434 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004435 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004436 .dac_nids = alc880_dac_nids,
4437 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004438 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4439 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004440 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004441 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004442 .setup = alc880_lg_lw_setup,
4443 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004444 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004445 [ALC880_MEDION_RIM] = {
4446 .mixers = { alc880_medion_rim_mixer },
4447 .init_verbs = { alc880_volume_init_verbs,
4448 alc880_medion_rim_init_verbs,
4449 alc_gpio2_init_verbs },
4450 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4451 .dac_nids = alc880_dac_nids,
4452 .dig_out_nid = ALC880_DIGOUT_NID,
4453 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4454 .channel_mode = alc880_2_jack_modes,
4455 .input_mux = &alc880_medion_rim_capture_source,
4456 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004457 .setup = alc880_medion_rim_setup,
4458 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004459 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004460#ifdef CONFIG_SND_DEBUG
4461 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004462 .mixers = { alc880_test_mixer },
4463 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004464 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4465 .dac_nids = alc880_test_dac_nids,
4466 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004467 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4468 .channel_mode = alc880_test_modes,
4469 .input_mux = &alc880_test_capture_source,
4470 },
4471#endif
4472};
4473
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004474/*
4475 * Automatic parse of I/O pins from the BIOS configuration
4476 */
4477
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004478enum {
4479 ALC_CTL_WIDGET_VOL,
4480 ALC_CTL_WIDGET_MUTE,
4481 ALC_CTL_BIND_MUTE,
4482};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004483static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004484 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4485 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004486 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004487};
4488
4489/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004490static int add_control(struct alc_spec *spec, int type, const char *name,
4491 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004492{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004493 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004494
Takashi Iwai603c4012008-07-30 15:01:44 +02004495 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4496 knew = snd_array_new(&spec->kctls);
4497 if (!knew)
4498 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004499 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004500 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004501 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004502 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004503 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004504 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004505 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004506 return 0;
4507}
4508
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004509static int add_control_with_pfx(struct alc_spec *spec, int type,
4510 const char *pfx, const char *dir,
4511 const char *sfx, unsigned long val)
4512{
4513 char name[32];
4514 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4515 return add_control(spec, type, name, val);
4516}
4517
4518#define add_pb_vol_ctrl(spec, type, pfx, val) \
4519 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4520#define add_pb_sw_ctrl(spec, type, pfx, val) \
4521 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4522
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004523#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4524#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4525#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4526#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004527#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4528#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4529#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4530#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4531#define ALC880_PIN_CD_NID 0x1c
4532
4533/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004534static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4535 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004536{
4537 hda_nid_t nid;
4538 int assigned[4];
4539 int i, j;
4540
4541 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004542 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004543
4544 /* check the pins hardwired to 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 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004549 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004550 assigned[idx] = 1;
4551 }
4552 }
4553 /* left pins can be connect to any audio widget */
4554 for (i = 0; i < cfg->line_outs; i++) {
4555 nid = cfg->line_out_pins[i];
4556 if (alc880_is_fixed_pin(nid))
4557 continue;
4558 /* search for an empty channel */
4559 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004560 if (!assigned[j]) {
4561 spec->multiout.dac_nids[i] =
4562 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004563 assigned[j] = 1;
4564 break;
4565 }
4566 }
4567 }
4568 spec->multiout.num_dacs = cfg->line_outs;
4569 return 0;
4570}
4571
4572/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004573static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4574 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004575{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004576 static const char *chname[4] = {
4577 "Front", "Surround", NULL /*CLFE*/, "Side"
4578 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004579 hda_nid_t nid;
4580 int i, err;
4581
4582 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004583 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004584 continue;
4585 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4586 if (i == 2) {
4587 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004588 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4589 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004590 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4591 HDA_OUTPUT));
4592 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004593 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004594 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4595 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004596 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4597 HDA_OUTPUT));
4598 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004599 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004600 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4601 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004602 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4603 HDA_INPUT));
4604 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004605 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004606 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4607 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004608 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4609 HDA_INPUT));
4610 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004611 return err;
4612 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004613 const char *pfx;
4614 if (cfg->line_outs == 1 &&
4615 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4616 pfx = "Speaker";
4617 else
4618 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004619 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004620 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4621 HDA_OUTPUT));
4622 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004623 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004624 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004625 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4626 HDA_INPUT));
4627 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004628 return err;
4629 }
4630 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004631 return 0;
4632}
4633
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004634/* add playback controls for speaker and HP outputs */
4635static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4636 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004637{
4638 hda_nid_t nid;
4639 int err;
4640
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004641 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004642 return 0;
4643
4644 if (alc880_is_fixed_pin(pin)) {
4645 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004646 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004647 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004648 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004649 else
4650 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004651 /* control HP volume/switch on the output mixer amp */
4652 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004653 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004654 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4655 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004656 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004657 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004658 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4659 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004660 return err;
4661 } else if (alc880_is_multi_pin(pin)) {
4662 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004663 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004664 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004665 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4666 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004667 return err;
4668 }
4669 return 0;
4670}
4671
4672/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004673static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4674 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004675 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004676{
Kailang Yangdf694da2005-12-05 19:42:22 +01004677 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004678
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004679 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004680 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4681 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004682 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004683 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004684 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4685 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004686 return err;
4687 return 0;
4688}
4689
Takashi Iwai05f5f472009-08-25 13:10:18 +02004690static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004691{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004692 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4693 return (pincap & AC_PINCAP_IN) != 0;
4694}
4695
4696/* create playback/capture controls for input pins */
4697static int alc_auto_create_input_ctls(struct hda_codec *codec,
4698 const struct auto_pin_cfg *cfg,
4699 hda_nid_t mixer,
4700 hda_nid_t cap1, hda_nid_t cap2)
4701{
4702 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004703 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004704 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004705
4706 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004707 hda_nid_t pin;
4708
4709 pin = cfg->input_pins[i];
4710 if (!alc_is_input_pin(codec, pin))
4711 continue;
4712
4713 if (mixer) {
4714 idx = get_connection_index(codec, mixer, pin);
4715 if (idx >= 0) {
4716 err = new_analog_input(spec, pin,
4717 auto_pin_cfg_labels[i],
4718 idx, mixer);
4719 if (err < 0)
4720 return err;
4721 }
4722 }
4723
4724 if (!cap1)
4725 continue;
4726 idx = get_connection_index(codec, cap1, pin);
4727 if (idx < 0 && cap2)
4728 idx = get_connection_index(codec, cap2, pin);
4729 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004730 imux->items[imux->num_items].label =
4731 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004732 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004733 imux->num_items++;
4734 }
4735 }
4736 return 0;
4737}
4738
Takashi Iwai05f5f472009-08-25 13:10:18 +02004739static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4740 const struct auto_pin_cfg *cfg)
4741{
4742 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4743}
4744
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004745static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4746 unsigned int pin_type)
4747{
4748 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4749 pin_type);
4750 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004751 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4752 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004753}
4754
Kailang Yangdf694da2005-12-05 19:42:22 +01004755static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4756 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004757 int dac_idx)
4758{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004759 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004760 /* need the manual connection? */
4761 if (alc880_is_multi_pin(nid)) {
4762 struct alc_spec *spec = codec->spec;
4763 int idx = alc880_multi_pin_idx(nid);
4764 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4765 AC_VERB_SET_CONNECT_SEL,
4766 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4767 }
4768}
4769
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004770static int get_pin_type(int line_out_type)
4771{
4772 if (line_out_type == AUTO_PIN_HP_OUT)
4773 return PIN_HP;
4774 else
4775 return PIN_OUT;
4776}
4777
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004778static void alc880_auto_init_multi_out(struct hda_codec *codec)
4779{
4780 struct alc_spec *spec = codec->spec;
4781 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004782
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004783 for (i = 0; i < spec->autocfg.line_outs; i++) {
4784 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004785 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4786 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004787 }
4788}
4789
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004790static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004791{
4792 struct alc_spec *spec = codec->spec;
4793 hda_nid_t pin;
4794
Takashi Iwai82bc9552006-03-21 11:24:42 +01004795 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004796 if (pin) /* connect to front */
4797 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004798 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004799 if (pin) /* connect to front */
4800 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4801}
4802
4803static void alc880_auto_init_analog_input(struct hda_codec *codec)
4804{
4805 struct alc_spec *spec = codec->spec;
4806 int i;
4807
4808 for (i = 0; i < AUTO_PIN_LAST; i++) {
4809 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004810 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004811 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004812 if (nid != ALC880_PIN_CD_NID &&
4813 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004814 snd_hda_codec_write(codec, nid, 0,
4815 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004816 AMP_OUT_MUTE);
4817 }
4818 }
4819}
4820
Takashi Iwai7f311a42010-04-09 17:32:23 +02004821static void alc880_auto_init_input_src(struct hda_codec *codec)
4822{
4823 struct alc_spec *spec = codec->spec;
4824 int c;
4825
4826 for (c = 0; c < spec->num_adc_nids; c++) {
4827 unsigned int mux_idx;
4828 const struct hda_input_mux *imux;
4829 mux_idx = c >= spec->num_mux_defs ? 0 : c;
4830 imux = &spec->input_mux[mux_idx];
4831 if (!imux->num_items && mux_idx > 0)
4832 imux = &spec->input_mux[0];
4833 if (imux)
4834 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
4835 AC_VERB_SET_CONNECT_SEL,
4836 imux->items[0].index);
4837 }
4838}
4839
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004840/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004841/* return 1 if successful, 0 if the proper config is not found,
4842 * or a negative error code
4843 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004844static int alc880_parse_auto_config(struct hda_codec *codec)
4845{
4846 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004847 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004848 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004849
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004850 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4851 alc880_ignore);
4852 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004853 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004854 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004855 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004856
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004857 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4858 if (err < 0)
4859 return err;
4860 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4861 if (err < 0)
4862 return err;
4863 err = alc880_auto_create_extra_out(spec,
4864 spec->autocfg.speaker_pins[0],
4865 "Speaker");
4866 if (err < 0)
4867 return err;
4868 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4869 "Headphone");
4870 if (err < 0)
4871 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004872 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004873 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004874 return err;
4875
4876 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4877
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004878 /* check multiple SPDIF-out (for recent codecs) */
4879 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4880 hda_nid_t dig_nid;
4881 err = snd_hda_get_connections(codec,
4882 spec->autocfg.dig_out_pins[i],
4883 &dig_nid, 1);
4884 if (err < 0)
4885 continue;
4886 if (!i)
4887 spec->multiout.dig_out_nid = dig_nid;
4888 else {
4889 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004890 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004891 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004892 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004893 }
4894 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004895 if (spec->autocfg.dig_in_pin)
4896 spec->dig_in_nid = ALC880_DIGIN_NID;
4897
Takashi Iwai603c4012008-07-30 15:01:44 +02004898 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004899 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004900
Takashi Iwaid88897e2008-10-31 15:01:37 +01004901 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004902
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004903 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004904 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004905
Kailang Yang6227cdc2010-02-25 08:36:52 +01004906 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004907
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004908 return 1;
4909}
4910
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004911/* additional initialization for auto-configuration model */
4912static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004913{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004914 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004915 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004916 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004917 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02004918 alc880_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004919 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004920 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004921}
4922
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004923/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4924 * one of two digital mic pins, e.g. on ALC272
4925 */
4926static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004927{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004928 struct alc_spec *spec = codec->spec;
4929 int i;
4930
4931 for (i = 0; i < spec->num_adc_nids; i++) {
4932 hda_nid_t cap = spec->capsrc_nids ?
4933 spec->capsrc_nids[i] : spec->adc_nids[i];
4934 int iidx, eidx;
4935
4936 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4937 if (iidx < 0)
4938 continue;
4939 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4940 if (eidx < 0)
4941 continue;
4942 spec->int_mic.mux_idx = iidx;
4943 spec->ext_mic.mux_idx = eidx;
4944 if (spec->capsrc_nids)
4945 spec->capsrc_nids += i;
4946 spec->adc_nids += i;
4947 spec->num_adc_nids = 1;
4948 return;
4949 }
4950 snd_printd(KERN_INFO "hda_codec: %s: "
4951 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4952 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4953 spec->auto_mic = 0; /* disable auto-mic to be sure */
4954}
4955
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004956/* choose the ADC/MUX containing the input pin and initialize the setup */
4957static void fixup_single_adc(struct hda_codec *codec)
4958{
4959 struct alc_spec *spec = codec->spec;
Frederik Deweerdtd2db09b2010-03-05 16:34:31 +01004960 hda_nid_t pin = 0;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004961 int i;
4962
4963 /* search for the input pin; there must be only one */
4964 for (i = 0; i < AUTO_PIN_LAST; i++) {
4965 if (spec->autocfg.input_pins[i]) {
4966 pin = spec->autocfg.input_pins[i];
4967 break;
4968 }
4969 }
4970 if (!pin)
4971 return;
4972
4973 /* set the default connection to that pin */
4974 for (i = 0; i < spec->num_adc_nids; i++) {
4975 hda_nid_t cap = spec->capsrc_nids ?
4976 spec->capsrc_nids[i] : spec->adc_nids[i];
4977 int idx;
4978
4979 idx = get_connection_index(codec, cap, pin);
4980 if (idx < 0)
4981 continue;
4982 /* use only this ADC */
4983 if (spec->capsrc_nids)
4984 spec->capsrc_nids += i;
4985 spec->adc_nids += i;
4986 spec->num_adc_nids = 1;
4987 /* select or unmute this route */
4988 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
4989 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
4990 HDA_AMP_MUTE, 0);
4991 } else {
4992 snd_hda_codec_write_cache(codec, cap, 0,
4993 AC_VERB_SET_CONNECT_SEL, idx);
4994 }
4995 return;
4996 }
4997}
4998
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004999static void set_capture_mixer(struct hda_codec *codec)
5000{
5001 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005002 static struct snd_kcontrol_new *caps[2][3] = {
5003 { alc_capture_mixer_nosrc1,
5004 alc_capture_mixer_nosrc2,
5005 alc_capture_mixer_nosrc3 },
5006 { alc_capture_mixer1,
5007 alc_capture_mixer2,
5008 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005009 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005010 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005011 int mux = 0;
5012 if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005013 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005014 else if (spec->input_mux) {
5015 if (spec->input_mux->num_items > 1)
5016 mux = 1;
5017 else if (spec->input_mux->num_items == 1)
5018 fixup_single_adc(codec);
5019 }
Takashi Iwaia23b6882009-03-23 15:21:36 +01005020 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
5021 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005022}
5023
Takashi Iwai66946352010-03-29 17:21:45 +02005024/* fill adc_nids (and capsrc_nids) containing all active input pins */
5025static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5026 int num_nids)
5027{
5028 struct alc_spec *spec = codec->spec;
5029 int n;
5030 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5031
5032 for (n = 0; n < num_nids; n++) {
5033 hda_nid_t adc, cap;
5034 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5035 int nconns, i, j;
5036
5037 adc = nids[n];
5038 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5039 continue;
5040 cap = adc;
5041 nconns = snd_hda_get_connections(codec, cap, conn,
5042 ARRAY_SIZE(conn));
5043 if (nconns == 1) {
5044 cap = conn[0];
5045 nconns = snd_hda_get_connections(codec, cap, conn,
5046 ARRAY_SIZE(conn));
5047 }
5048 if (nconns <= 0)
5049 continue;
5050 if (!fallback_adc) {
5051 fallback_adc = adc;
5052 fallback_cap = cap;
5053 }
5054 for (i = 0; i < AUTO_PIN_LAST; i++) {
5055 hda_nid_t nid = spec->autocfg.input_pins[i];
5056 if (!nid)
5057 continue;
5058 for (j = 0; j < nconns; j++) {
5059 if (conn[j] == nid)
5060 break;
5061 }
5062 if (j >= nconns)
5063 break;
5064 }
5065 if (i >= AUTO_PIN_LAST) {
5066 int num_adcs = spec->num_adc_nids;
5067 spec->private_adc_nids[num_adcs] = adc;
5068 spec->private_capsrc_nids[num_adcs] = cap;
5069 spec->num_adc_nids++;
5070 spec->adc_nids = spec->private_adc_nids;
5071 if (adc != cap)
5072 spec->capsrc_nids = spec->private_capsrc_nids;
5073 }
5074 }
5075 if (!spec->num_adc_nids) {
5076 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005077 " using fallback 0x%x\n",
5078 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005079 spec->private_adc_nids[0] = fallback_adc;
5080 spec->adc_nids = spec->private_adc_nids;
5081 if (fallback_adc != fallback_cap) {
5082 spec->private_capsrc_nids[0] = fallback_cap;
5083 spec->capsrc_nids = spec->private_adc_nids;
5084 }
5085 }
5086}
5087
Takashi Iwai67d634c2009-11-16 15:35:59 +01005088#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005089#define set_beep_amp(spec, nid, idx, dir) \
5090 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01005091#else
5092#define set_beep_amp(spec, nid, idx, dir) /* NOP */
5093#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005094
5095/*
5096 * OK, here we have finally the patch for ALC880
5097 */
5098
Linus Torvalds1da177e2005-04-16 15:20:36 -07005099static int patch_alc880(struct hda_codec *codec)
5100{
5101 struct alc_spec *spec;
5102 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005103 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005104
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005105 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005106 if (spec == NULL)
5107 return -ENOMEM;
5108
5109 codec->spec = spec;
5110
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005111 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5112 alc880_models,
5113 alc880_cfg_tbl);
5114 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005115 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5116 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005117 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005118 }
5119
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005120 if (board_config == ALC880_AUTO) {
5121 /* automatic parse from the BIOS config */
5122 err = alc880_parse_auto_config(codec);
5123 if (err < 0) {
5124 alc_free(codec);
5125 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005126 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005127 printk(KERN_INFO
5128 "hda_codec: Cannot set up configuration "
5129 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005130 board_config = ALC880_3ST;
5131 }
5132 }
5133
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005134 err = snd_hda_attach_beep_device(codec, 0x1);
5135 if (err < 0) {
5136 alc_free(codec);
5137 return err;
5138 }
5139
Kailang Yangdf694da2005-12-05 19:42:22 +01005140 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005141 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005142
Linus Torvalds1da177e2005-04-16 15:20:36 -07005143 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5144 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005145 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005146
Linus Torvalds1da177e2005-04-16 15:20:36 -07005147 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5148 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5149
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005150 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005151 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005152 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005153 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005154 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005155 if (wcap != AC_WID_AUD_IN) {
5156 spec->adc_nids = alc880_adc_nids_alt;
5157 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005158 } else {
5159 spec->adc_nids = alc880_adc_nids;
5160 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005161 }
5162 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005163 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005164 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005165
Takashi Iwai2134ea42008-01-10 16:53:55 +01005166 spec->vmaster_nid = 0x0c;
5167
Linus Torvalds1da177e2005-04-16 15:20:36 -07005168 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005169 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005170 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005171#ifdef CONFIG_SND_HDA_POWER_SAVE
5172 if (!spec->loopback.amplist)
5173 spec->loopback.amplist = alc880_loopbacks;
5174#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005175
5176 return 0;
5177}
5178
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005179
Linus Torvalds1da177e2005-04-16 15:20:36 -07005180/*
5181 * ALC260 support
5182 */
5183
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005184static hda_nid_t alc260_dac_nids[1] = {
5185 /* front */
5186 0x02,
5187};
5188
5189static hda_nid_t alc260_adc_nids[1] = {
5190 /* ADC0 */
5191 0x04,
5192};
5193
Kailang Yangdf694da2005-12-05 19:42:22 +01005194static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005195 /* ADC1 */
5196 0x05,
5197};
5198
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005199/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5200 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5201 */
5202static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005203 /* ADC0, ADC1 */
5204 0x04, 0x05
5205};
5206
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005207#define ALC260_DIGOUT_NID 0x03
5208#define ALC260_DIGIN_NID 0x06
5209
5210static struct hda_input_mux alc260_capture_source = {
5211 .num_items = 4,
5212 .items = {
5213 { "Mic", 0x0 },
5214 { "Front Mic", 0x1 },
5215 { "Line", 0x2 },
5216 { "CD", 0x4 },
5217 },
5218};
5219
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005220/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005221 * headphone jack and the internal CD lines since these are the only pins at
5222 * which audio can appear. For flexibility, also allow the option of
5223 * recording the mixer output on the second ADC (ADC0 doesn't have a
5224 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005225 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005226static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5227 {
5228 .num_items = 3,
5229 .items = {
5230 { "Mic/Line", 0x0 },
5231 { "CD", 0x4 },
5232 { "Headphone", 0x2 },
5233 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005234 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005235 {
5236 .num_items = 4,
5237 .items = {
5238 { "Mic/Line", 0x0 },
5239 { "CD", 0x4 },
5240 { "Headphone", 0x2 },
5241 { "Mixer", 0x5 },
5242 },
5243 },
5244
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005245};
5246
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005247/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5248 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005249 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005250static struct hda_input_mux alc260_acer_capture_sources[2] = {
5251 {
5252 .num_items = 4,
5253 .items = {
5254 { "Mic", 0x0 },
5255 { "Line", 0x2 },
5256 { "CD", 0x4 },
5257 { "Headphone", 0x5 },
5258 },
5259 },
5260 {
5261 .num_items = 5,
5262 .items = {
5263 { "Mic", 0x0 },
5264 { "Line", 0x2 },
5265 { "CD", 0x4 },
5266 { "Headphone", 0x6 },
5267 { "Mixer", 0x5 },
5268 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005269 },
5270};
Michael Schwingencc959482009-02-22 18:58:45 +01005271
5272/* Maxdata Favorit 100XS */
5273static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5274 {
5275 .num_items = 2,
5276 .items = {
5277 { "Line/Mic", 0x0 },
5278 { "CD", 0x4 },
5279 },
5280 },
5281 {
5282 .num_items = 3,
5283 .items = {
5284 { "Line/Mic", 0x0 },
5285 { "CD", 0x4 },
5286 { "Mixer", 0x5 },
5287 },
5288 },
5289};
5290
Linus Torvalds1da177e2005-04-16 15:20:36 -07005291/*
5292 * This is just place-holder, so there's something for alc_build_pcms to look
5293 * at when it calculates the maximum number of channels. ALC260 has no mixer
5294 * element which allows changing the channel mode, so the verb list is
5295 * never used.
5296 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005297static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005298 { 2, NULL },
5299};
5300
Kailang Yangdf694da2005-12-05 19:42:22 +01005301
5302/* Mixer combinations
5303 *
5304 * basic: base_output + input + pc_beep + capture
5305 * HP: base_output + input + capture_alt
5306 * HP_3013: hp_3013 + input + capture
5307 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005308 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005309 */
5310
5311static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005312 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005313 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005314 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5315 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5316 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5317 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5318 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005319};
Kailang Yangdf694da2005-12-05 19:42:22 +01005320
5321static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005322 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5323 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5324 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5325 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5326 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5327 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5328 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5329 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005330 { } /* end */
5331};
5332
Takashi Iwaibec15c32008-01-28 18:16:30 +01005333/* update HP, line and mono out pins according to the master switch */
5334static void alc260_hp_master_update(struct hda_codec *codec,
5335 hda_nid_t hp, hda_nid_t line,
5336 hda_nid_t mono)
5337{
5338 struct alc_spec *spec = codec->spec;
5339 unsigned int val = spec->master_sw ? PIN_HP : 0;
5340 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005341 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005342 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005343 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005344 val);
5345 /* mono (speaker) depending on the HP jack sense */
5346 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005347 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005348 val);
5349}
5350
5351static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5352 struct snd_ctl_elem_value *ucontrol)
5353{
5354 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5355 struct alc_spec *spec = codec->spec;
5356 *ucontrol->value.integer.value = spec->master_sw;
5357 return 0;
5358}
5359
5360static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5361 struct snd_ctl_elem_value *ucontrol)
5362{
5363 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5364 struct alc_spec *spec = codec->spec;
5365 int val = !!*ucontrol->value.integer.value;
5366 hda_nid_t hp, line, mono;
5367
5368 if (val == spec->master_sw)
5369 return 0;
5370 spec->master_sw = val;
5371 hp = (kcontrol->private_value >> 16) & 0xff;
5372 line = (kcontrol->private_value >> 8) & 0xff;
5373 mono = kcontrol->private_value & 0xff;
5374 alc260_hp_master_update(codec, hp, line, mono);
5375 return 1;
5376}
5377
5378static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5379 {
5380 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5381 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005382 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005383 .info = snd_ctl_boolean_mono_info,
5384 .get = alc260_hp_master_sw_get,
5385 .put = alc260_hp_master_sw_put,
5386 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5387 },
5388 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5389 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5390 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5391 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5392 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5393 HDA_OUTPUT),
5394 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5395 { } /* end */
5396};
5397
5398static struct hda_verb alc260_hp_unsol_verbs[] = {
5399 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5400 {},
5401};
5402
5403static void alc260_hp_automute(struct hda_codec *codec)
5404{
5405 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005406
Wu Fengguang864f92b2009-11-18 12:38:02 +08005407 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005408 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5409}
5410
5411static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5412{
5413 if ((res >> 26) == ALC880_HP_EVENT)
5414 alc260_hp_automute(codec);
5415}
5416
Kailang Yangdf694da2005-12-05 19:42:22 +01005417static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005418 {
5419 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5420 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005421 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005422 .info = snd_ctl_boolean_mono_info,
5423 .get = alc260_hp_master_sw_get,
5424 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005425 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005426 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005427 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5428 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5429 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5430 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5431 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5432 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005433 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5434 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005435 { } /* end */
5436};
5437
Kailang Yang3f878302008-08-26 13:02:23 +02005438static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5439 .ops = &snd_hda_bind_vol,
5440 .values = {
5441 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5442 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5443 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5444 0
5445 },
5446};
5447
5448static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5449 .ops = &snd_hda_bind_sw,
5450 .values = {
5451 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5452 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5453 0
5454 },
5455};
5456
5457static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5458 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5459 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5460 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5461 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5462 { } /* end */
5463};
5464
Takashi Iwaibec15c32008-01-28 18:16:30 +01005465static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5466 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5467 {},
5468};
5469
5470static void alc260_hp_3013_automute(struct hda_codec *codec)
5471{
5472 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005473
Wu Fengguang864f92b2009-11-18 12:38:02 +08005474 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005475 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005476}
5477
5478static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5479 unsigned int res)
5480{
5481 if ((res >> 26) == ALC880_HP_EVENT)
5482 alc260_hp_3013_automute(codec);
5483}
5484
Kailang Yang3f878302008-08-26 13:02:23 +02005485static void alc260_hp_3012_automute(struct hda_codec *codec)
5486{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005487 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005488
Kailang Yang3f878302008-08-26 13:02:23 +02005489 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5490 bits);
5491 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5492 bits);
5493 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5494 bits);
5495}
5496
5497static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5498 unsigned int res)
5499{
5500 if ((res >> 26) == ALC880_HP_EVENT)
5501 alc260_hp_3012_automute(codec);
5502}
5503
5504/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005505 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5506 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005507static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005508 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005509 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005510 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005511 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5512 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5513 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5514 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005515 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005516 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5517 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005518 { } /* end */
5519};
5520
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005521/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5522 * versions of the ALC260 don't act on requests to enable mic bias from NID
5523 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5524 * datasheet doesn't mention this restriction. At this stage it's not clear
5525 * whether this behaviour is intentional or is a hardware bug in chip
5526 * revisions available in early 2006. Therefore for now allow the
5527 * "Headphone Jack Mode" control to span all choices, but if it turns out
5528 * that the lack of mic bias for this NID is intentional we could change the
5529 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5530 *
5531 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5532 * don't appear to make the mic bias available from the "line" jack, even
5533 * though the NID used for this jack (0x14) can supply it. The theory is
5534 * that perhaps Acer have included blocking capacitors between the ALC260
5535 * and the output jack. If this turns out to be the case for all such
5536 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5537 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005538 *
5539 * The C20x Tablet series have a mono internal speaker which is controlled
5540 * via the chip's Mono sum widget and pin complex, so include the necessary
5541 * controls for such models. On models without a "mono speaker" the control
5542 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005543 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005544static struct snd_kcontrol_new alc260_acer_mixer[] = {
5545 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5546 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005547 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005548 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005549 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005550 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005551 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005552 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5553 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5554 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5555 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5556 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5557 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5558 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5559 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005560 { } /* end */
5561};
5562
Michael Schwingencc959482009-02-22 18:58:45 +01005563/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5564 */
5565static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5566 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5567 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5568 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5569 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5570 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5571 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5572 { } /* end */
5573};
5574
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005575/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5576 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5577 */
5578static struct snd_kcontrol_new alc260_will_mixer[] = {
5579 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5580 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5581 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5582 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5583 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5584 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5585 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5586 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5587 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5588 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005589 { } /* end */
5590};
5591
5592/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5593 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5594 */
5595static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5596 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5597 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5598 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5599 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5600 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5601 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5602 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5603 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5604 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5605 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5606 { } /* end */
5607};
5608
Kailang Yangdf694da2005-12-05 19:42:22 +01005609/*
5610 * initialization verbs
5611 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005612static struct hda_verb alc260_init_verbs[] = {
5613 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005614 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005615 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005616 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005617 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005618 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005619 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005620 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005621 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005622 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005623 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005624 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005625 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005626 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005627 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005628 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005629 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005630 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5631 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005632 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005633 /* set connection select to line in (default select for this ADC) */
5634 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005635 /* mute capture amp left and right */
5636 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5637 /* set connection select to line in (default select for this ADC) */
5638 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005639 /* set vol=0 Line-Out mixer amp left and right */
5640 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5641 /* unmute pin widget amp left and right (no gain on this amp) */
5642 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5643 /* set vol=0 HP mixer amp left and right */
5644 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5645 /* unmute pin widget amp left and right (no gain on this amp) */
5646 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5647 /* set vol=0 Mono mixer amp left and right */
5648 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5649 /* unmute pin widget amp left and right (no gain on this amp) */
5650 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5651 /* unmute LINE-2 out pin */
5652 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005653 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5654 * Line In 2 = 0x03
5655 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005656 /* mute analog inputs */
5657 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5658 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5659 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5660 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5661 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005662 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005663 /* mute Front out path */
5664 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5665 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5666 /* mute Headphone out path */
5667 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5668 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5669 /* mute Mono out path */
5670 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5671 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005672 { }
5673};
5674
Takashi Iwai474167d2006-05-17 17:17:43 +02005675#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005676static struct hda_verb alc260_hp_init_verbs[] = {
5677 /* Headphone and output */
5678 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5679 /* mono output */
5680 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5681 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5682 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5683 /* Mic2 (front panel) pin widget for input and vref at 80% */
5684 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5685 /* Line In pin widget for input */
5686 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5687 /* Line-2 pin widget for output */
5688 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5689 /* CD pin widget for input */
5690 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5691 /* unmute amp left and right */
5692 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5693 /* set connection select to line in (default select for this ADC) */
5694 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5695 /* unmute Line-Out mixer amp left and right (volume = 0) */
5696 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5697 /* mute pin widget amp left and right (no gain on this amp) */
5698 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5699 /* unmute HP mixer amp left and right (volume = 0) */
5700 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5701 /* mute pin widget amp left and right (no gain on this amp) */
5702 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005703 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5704 * Line In 2 = 0x03
5705 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005706 /* mute analog inputs */
5707 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5708 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5709 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5710 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5711 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005712 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5713 /* Unmute Front out path */
5714 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5715 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5716 /* Unmute Headphone out path */
5717 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5718 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5719 /* Unmute Mono out path */
5720 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5721 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5722 { }
5723};
Takashi Iwai474167d2006-05-17 17:17:43 +02005724#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005725
5726static struct hda_verb alc260_hp_3013_init_verbs[] = {
5727 /* Line out and output */
5728 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5729 /* mono output */
5730 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5731 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5732 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5733 /* Mic2 (front panel) pin widget for input and vref at 80% */
5734 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5735 /* Line In pin widget for input */
5736 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5737 /* Headphone pin widget for output */
5738 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5739 /* CD pin widget for input */
5740 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5741 /* unmute amp left and right */
5742 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5743 /* set connection select to line in (default select for this ADC) */
5744 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5745 /* unmute Line-Out mixer amp left and right (volume = 0) */
5746 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5747 /* mute pin widget amp left and right (no gain on this amp) */
5748 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5749 /* unmute HP mixer amp left and right (volume = 0) */
5750 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5751 /* mute pin widget amp left and right (no gain on this amp) */
5752 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005753 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5754 * Line In 2 = 0x03
5755 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005756 /* mute analog inputs */
5757 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5758 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5759 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5760 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5761 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005762 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5763 /* Unmute Front out path */
5764 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5765 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5766 /* Unmute Headphone out path */
5767 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5768 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5769 /* Unmute Mono out path */
5770 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5771 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5772 { }
5773};
5774
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005775/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005776 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5777 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005778 */
5779static struct hda_verb alc260_fujitsu_init_verbs[] = {
5780 /* Disable all GPIOs */
5781 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5782 /* Internal speaker is connected to headphone pin */
5783 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5784 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5785 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005786 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5787 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5788 /* Ensure all other unused pins are disabled and muted. */
5789 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5790 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005791 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005792 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005793 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005794 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5795 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5796 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005797
Jonathan Woithef7ace402006-02-28 11:46:14 +01005798 /* Disable digital (SPDIF) pins */
5799 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5800 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005801
Kailang Yangea1fb292008-08-26 12:58:38 +02005802 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005803 * when acting as an output.
5804 */
5805 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5806
5807 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005808 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5809 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5810 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5811 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5812 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5813 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5814 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5815 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5816 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005817
Jonathan Woithef7ace402006-02-28 11:46:14 +01005818 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5819 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5820 /* Unmute Line1 pin widget output buffer since it starts as an output.
5821 * If the pin mode is changed by the user the pin mode control will
5822 * take care of enabling the pin's input/output buffers as needed.
5823 * Therefore there's no need to enable the input buffer at this
5824 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005825 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005826 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005827 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005828 * mixer ctrl)
5829 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005830 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005831
Jonathan Woithef7ace402006-02-28 11:46:14 +01005832 /* Mute capture amp left and right */
5833 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005834 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005835 * in (on mic1 pin)
5836 */
5837 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005838
Jonathan Woithef7ace402006-02-28 11:46:14 +01005839 /* Do the same for the second ADC: mute capture input amp and
5840 * set ADC connection to line in (on mic1 pin)
5841 */
5842 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5843 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005844
Jonathan Woithef7ace402006-02-28 11:46:14 +01005845 /* Mute all inputs to mixer widget (even unconnected ones) */
5846 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5847 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5848 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5849 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5850 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005854
5855 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005856};
5857
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005858/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5859 * similar laptops (adapted from Fujitsu init verbs).
5860 */
5861static struct hda_verb alc260_acer_init_verbs[] = {
5862 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5863 * the headphone jack. Turn this on and rely on the standard mute
5864 * methods whenever the user wants to turn these outputs off.
5865 */
5866 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5867 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5868 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5869 /* Internal speaker/Headphone jack is connected to Line-out pin */
5870 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5871 /* Internal microphone/Mic jack is connected to Mic1 pin */
5872 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5873 /* Line In jack is connected to Line1 pin */
5874 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005875 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5876 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005877 /* Ensure all other unused pins are disabled and muted. */
5878 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5879 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005880 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5881 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5882 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5883 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5884 /* Disable digital (SPDIF) pins */
5885 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5886 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5887
Kailang Yangea1fb292008-08-26 12:58:38 +02005888 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005889 * bus when acting as outputs.
5890 */
5891 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5892 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5893
5894 /* Start with output sum widgets muted and their output gains at min */
5895 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5896 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5897 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5898 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5899 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5900 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5901 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5902 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5903 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5904
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005905 /* Unmute Line-out pin widget amp left and right
5906 * (no equiv mixer ctrl)
5907 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005908 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005909 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5910 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005911 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5912 * inputs. If the pin mode is changed by the user the pin mode control
5913 * will take care of enabling the pin's input/output buffers as needed.
5914 * Therefore there's no need to enable the input buffer at this
5915 * stage.
5916 */
5917 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5918 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5919
5920 /* Mute capture amp left and right */
5921 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5922 /* Set ADC connection select to match default mixer setting - mic
5923 * (on mic1 pin)
5924 */
5925 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5926
5927 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005928 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005929 */
5930 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005931 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005932
5933 /* Mute all inputs to mixer widget (even unconnected ones) */
5934 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5935 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5937 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5942
5943 { }
5944};
5945
Michael Schwingencc959482009-02-22 18:58:45 +01005946/* Initialisation sequence for Maxdata Favorit 100XS
5947 * (adapted from Acer init verbs).
5948 */
5949static struct hda_verb alc260_favorit100_init_verbs[] = {
5950 /* GPIO 0 enables the output jack.
5951 * Turn this on and rely on the standard mute
5952 * methods whenever the user wants to turn these outputs off.
5953 */
5954 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5955 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5956 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5957 /* Line/Mic input jack is connected to Mic1 pin */
5958 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5959 /* Ensure all other unused pins are disabled and muted. */
5960 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5961 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5962 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5963 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5964 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5965 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5966 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5967 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5968 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5969 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5970 /* Disable digital (SPDIF) pins */
5971 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5972 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5973
5974 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5975 * bus when acting as outputs.
5976 */
5977 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5978 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5979
5980 /* Start with output sum widgets muted and their output gains at min */
5981 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5982 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5983 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5984 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5985 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5986 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5987 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5988 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5989 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5990
5991 /* Unmute Line-out pin widget amp left and right
5992 * (no equiv mixer ctrl)
5993 */
5994 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5995 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5996 * inputs. If the pin mode is changed by the user the pin mode control
5997 * will take care of enabling the pin's input/output buffers as needed.
5998 * Therefore there's no need to enable the input buffer at this
5999 * stage.
6000 */
6001 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6002
6003 /* Mute capture amp left and right */
6004 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6005 /* Set ADC connection select to match default mixer setting - mic
6006 * (on mic1 pin)
6007 */
6008 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6009
6010 /* Do similar with the second ADC: mute capture input amp and
6011 * set ADC connection to mic to match ALSA's default state.
6012 */
6013 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6014 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6015
6016 /* Mute all inputs to mixer widget (even unconnected ones) */
6017 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6018 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6019 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6020 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6021 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6022 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6023 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6024 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6025
6026 { }
6027};
6028
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006029static struct hda_verb alc260_will_verbs[] = {
6030 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6031 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6032 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6033 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6034 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6035 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6036 {}
6037};
6038
6039static struct hda_verb alc260_replacer_672v_verbs[] = {
6040 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6041 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6042 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6043
6044 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6045 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6046 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6047
6048 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6049 {}
6050};
6051
6052/* toggle speaker-output according to the hp-jack state */
6053static void alc260_replacer_672v_automute(struct hda_codec *codec)
6054{
6055 unsigned int present;
6056
6057 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006058 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006059 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006060 snd_hda_codec_write_cache(codec, 0x01, 0,
6061 AC_VERB_SET_GPIO_DATA, 1);
6062 snd_hda_codec_write_cache(codec, 0x0f, 0,
6063 AC_VERB_SET_PIN_WIDGET_CONTROL,
6064 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006065 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006066 snd_hda_codec_write_cache(codec, 0x01, 0,
6067 AC_VERB_SET_GPIO_DATA, 0);
6068 snd_hda_codec_write_cache(codec, 0x0f, 0,
6069 AC_VERB_SET_PIN_WIDGET_CONTROL,
6070 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006071 }
6072}
6073
6074static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6075 unsigned int res)
6076{
6077 if ((res >> 26) == ALC880_HP_EVENT)
6078 alc260_replacer_672v_automute(codec);
6079}
6080
Kailang Yang3f878302008-08-26 13:02:23 +02006081static struct hda_verb alc260_hp_dc7600_verbs[] = {
6082 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6083 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6084 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6085 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6086 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6087 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6088 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6089 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6090 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6091 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6092 {}
6093};
6094
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006095/* Test configuration for debugging, modelled after the ALC880 test
6096 * configuration.
6097 */
6098#ifdef CONFIG_SND_DEBUG
6099static hda_nid_t alc260_test_dac_nids[1] = {
6100 0x02,
6101};
6102static hda_nid_t alc260_test_adc_nids[2] = {
6103 0x04, 0x05,
6104};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006105/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006106 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006107 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006108 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006109static struct hda_input_mux alc260_test_capture_sources[2] = {
6110 {
6111 .num_items = 7,
6112 .items = {
6113 { "MIC1 pin", 0x0 },
6114 { "MIC2 pin", 0x1 },
6115 { "LINE1 pin", 0x2 },
6116 { "LINE2 pin", 0x3 },
6117 { "CD pin", 0x4 },
6118 { "LINE-OUT pin", 0x5 },
6119 { "HP-OUT pin", 0x6 },
6120 },
6121 },
6122 {
6123 .num_items = 8,
6124 .items = {
6125 { "MIC1 pin", 0x0 },
6126 { "MIC2 pin", 0x1 },
6127 { "LINE1 pin", 0x2 },
6128 { "LINE2 pin", 0x3 },
6129 { "CD pin", 0x4 },
6130 { "Mixer", 0x5 },
6131 { "LINE-OUT pin", 0x6 },
6132 { "HP-OUT pin", 0x7 },
6133 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006134 },
6135};
6136static struct snd_kcontrol_new alc260_test_mixer[] = {
6137 /* Output driver widgets */
6138 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6139 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6140 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6141 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6142 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6143 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6144
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006145 /* Modes for retasking pin widgets
6146 * Note: the ALC260 doesn't seem to act on requests to enable mic
6147 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6148 * mention this restriction. At this stage it's not clear whether
6149 * this behaviour is intentional or is a hardware bug in chip
6150 * revisions available at least up until early 2006. Therefore for
6151 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6152 * choices, but if it turns out that the lack of mic bias for these
6153 * NIDs is intentional we could change their modes from
6154 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6155 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006156 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6157 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6158 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6159 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6160 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6161 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6162
6163 /* Loopback mixer controls */
6164 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6165 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6166 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6167 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6168 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6169 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6170 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6171 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6172 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6173 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006174 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6175 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6176 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6177 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006178
6179 /* Controls for GPIO pins, assuming they are configured as outputs */
6180 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6181 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6182 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6183 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6184
Jonathan Woithe92621f12006-02-28 11:47:47 +01006185 /* Switches to allow the digital IO pins to be enabled. The datasheet
6186 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006187 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006188 */
6189 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6190 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6191
Jonathan Woithef8225f62008-01-08 12:16:54 +01006192 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6193 * this output to turn on an external amplifier.
6194 */
6195 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6196 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6197
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006198 { } /* end */
6199};
6200static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006201 /* Enable all GPIOs as outputs with an initial value of 0 */
6202 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6203 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6204 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6205
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006206 /* Enable retasking pins as output, initially without power amp */
6207 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6208 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6209 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6210 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6211 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6212 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6213
Jonathan Woithe92621f12006-02-28 11:47:47 +01006214 /* Disable digital (SPDIF) pins initially, but users can enable
6215 * them via a mixer switch. In the case of SPDIF-out, this initverb
6216 * payload also sets the generation to 0, output to be in "consumer"
6217 * PCM format, copyright asserted, no pre-emphasis and no validity
6218 * control.
6219 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006220 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6221 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6222
Kailang Yangea1fb292008-08-26 12:58:38 +02006223 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006224 * OUT1 sum bus when acting as an output.
6225 */
6226 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6227 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6228 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6229 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6230
6231 /* Start with output sum widgets muted and their output gains at min */
6232 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6233 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6234 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6235 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6236 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6237 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6238 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6239 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6240 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6241
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006242 /* Unmute retasking pin widget output buffers since the default
6243 * state appears to be output. As the pin mode is changed by the
6244 * user the pin mode control will take care of enabling the pin's
6245 * input/output buffers as needed.
6246 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006247 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6248 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6249 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6250 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6251 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6252 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6253 /* Also unmute the mono-out pin widget */
6254 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6255
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006256 /* Mute capture amp left and right */
6257 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006258 /* Set ADC connection select to match default mixer setting (mic1
6259 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006260 */
6261 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6262
6263 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006264 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006265 */
6266 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6267 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6268
6269 /* Mute all inputs to mixer widget (even unconnected ones) */
6270 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6271 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6272 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6273 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6274 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6275 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6276 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6278
6279 { }
6280};
6281#endif
6282
Takashi Iwai63300792008-01-24 15:31:36 +01006283#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6284#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006285
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006286#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6287#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6288
Kailang Yangdf694da2005-12-05 19:42:22 +01006289/*
6290 * for BIOS auto-configuration
6291 */
6292
6293static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006294 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006295{
6296 hda_nid_t nid_vol;
6297 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006298 int err;
6299
6300 if (nid >= 0x0f && nid < 0x11) {
6301 nid_vol = nid - 0x7;
6302 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6303 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6304 } else if (nid == 0x11) {
6305 nid_vol = nid - 0x7;
6306 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6307 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6308 } else if (nid >= 0x12 && nid <= 0x15) {
6309 nid_vol = 0x08;
6310 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6311 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6312 } else
6313 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006314
Takashi Iwai863b4512008-10-21 17:01:47 +02006315 if (!(*vol_bits & (1 << nid_vol))) {
6316 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006317 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006318 if (err < 0)
6319 return err;
6320 *vol_bits |= (1 << nid_vol);
6321 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006322 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006323 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006324 return err;
6325 return 1;
6326}
6327
6328/* add playback controls from the parsed DAC table */
6329static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6330 const struct auto_pin_cfg *cfg)
6331{
6332 hda_nid_t nid;
6333 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006334 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006335
6336 spec->multiout.num_dacs = 1;
6337 spec->multiout.dac_nids = spec->private_dac_nids;
6338 spec->multiout.dac_nids[0] = 0x02;
6339
6340 nid = cfg->line_out_pins[0];
6341 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006342 const char *pfx;
6343 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6344 pfx = "Master";
6345 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6346 pfx = "Speaker";
6347 else
6348 pfx = "Front";
6349 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006350 if (err < 0)
6351 return err;
6352 }
6353
Takashi Iwai82bc9552006-03-21 11:24:42 +01006354 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006355 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006356 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006357 if (err < 0)
6358 return err;
6359 }
6360
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006361 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006362 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006363 err = alc260_add_playback_controls(spec, nid, "Headphone",
6364 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006365 if (err < 0)
6366 return err;
6367 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006368 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006369}
6370
6371/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006372static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006373 const struct auto_pin_cfg *cfg)
6374{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006375 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006376}
6377
6378static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6379 hda_nid_t nid, int pin_type,
6380 int sel_idx)
6381{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006382 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006383 /* need the manual connection? */
6384 if (nid >= 0x12) {
6385 int idx = nid - 0x12;
6386 snd_hda_codec_write(codec, idx + 0x0b, 0,
6387 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006388 }
6389}
6390
6391static void alc260_auto_init_multi_out(struct hda_codec *codec)
6392{
6393 struct alc_spec *spec = codec->spec;
6394 hda_nid_t nid;
6395
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006396 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006397 if (nid) {
6398 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6399 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6400 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006401
Takashi Iwai82bc9552006-03-21 11:24:42 +01006402 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006403 if (nid)
6404 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6405
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006406 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006407 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006408 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006409}
Kailang Yangdf694da2005-12-05 19:42:22 +01006410
6411#define ALC260_PIN_CD_NID 0x16
6412static void alc260_auto_init_analog_input(struct hda_codec *codec)
6413{
6414 struct alc_spec *spec = codec->spec;
6415 int i;
6416
6417 for (i = 0; i < AUTO_PIN_LAST; i++) {
6418 hda_nid_t nid = spec->autocfg.input_pins[i];
6419 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006420 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006421 if (nid != ALC260_PIN_CD_NID &&
6422 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006423 snd_hda_codec_write(codec, nid, 0,
6424 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006425 AMP_OUT_MUTE);
6426 }
6427 }
6428}
6429
Takashi Iwai7f311a42010-04-09 17:32:23 +02006430#define alc260_auto_init_input_src alc880_auto_init_input_src
6431
Kailang Yangdf694da2005-12-05 19:42:22 +01006432/*
6433 * generic initialization of ADC, input mixers and output mixers
6434 */
6435static struct hda_verb alc260_volume_init_verbs[] = {
6436 /*
6437 * Unmute ADC0-1 and set the default input to mic-in
6438 */
6439 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6440 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6441 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6442 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006443
Kailang Yangdf694da2005-12-05 19:42:22 +01006444 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6445 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006446 * Note: PASD motherboards uses the Line In 2 as the input for
6447 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006448 */
6449 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006450 /* mute analog inputs */
6451 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6452 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6453 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6454 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6455 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006456
6457 /*
6458 * Set up output mixers (0x08 - 0x0a)
6459 */
6460 /* set vol=0 to output mixers */
6461 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6462 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6463 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6464 /* set up input amps for analog loopback */
6465 /* Amp Indices: DAC = 0, mixer = 1 */
6466 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6467 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6468 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6469 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6470 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6471 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006472
Kailang Yangdf694da2005-12-05 19:42:22 +01006473 { }
6474};
6475
6476static int alc260_parse_auto_config(struct hda_codec *codec)
6477{
6478 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006479 int err;
6480 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6481
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006482 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6483 alc260_ignore);
6484 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006485 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006486 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6487 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006488 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006489 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006490 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006491 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006492 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006493 return err;
6494
6495 spec->multiout.max_channels = 2;
6496
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006497 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006498 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006499 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006500 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006501
Takashi Iwaid88897e2008-10-31 15:01:37 +01006502 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006503
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006504 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006505 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006506
Kailang Yang6227cdc2010-02-25 08:36:52 +01006507 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006508
Kailang Yangdf694da2005-12-05 19:42:22 +01006509 return 1;
6510}
6511
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006512/* additional initialization for auto-configuration model */
6513static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006514{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006515 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006516 alc260_auto_init_multi_out(codec);
6517 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02006518 alc260_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006519 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006520 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006521}
6522
Takashi Iwaicb53c622007-08-10 17:21:45 +02006523#ifdef CONFIG_SND_HDA_POWER_SAVE
6524static struct hda_amp_list alc260_loopbacks[] = {
6525 { 0x07, HDA_INPUT, 0 },
6526 { 0x07, HDA_INPUT, 1 },
6527 { 0x07, HDA_INPUT, 2 },
6528 { 0x07, HDA_INPUT, 3 },
6529 { 0x07, HDA_INPUT, 4 },
6530 { } /* end */
6531};
6532#endif
6533
Kailang Yangdf694da2005-12-05 19:42:22 +01006534/*
6535 * ALC260 configurations
6536 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006537static const char *alc260_models[ALC260_MODEL_LAST] = {
6538 [ALC260_BASIC] = "basic",
6539 [ALC260_HP] = "hp",
6540 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006541 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006542 [ALC260_FUJITSU_S702X] = "fujitsu",
6543 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006544 [ALC260_WILL] = "will",
6545 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006546 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006547#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006548 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006549#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006550 [ALC260_AUTO] = "auto",
6551};
6552
6553static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006554 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006555 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006556 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006557 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006558 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006559 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006560 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006561 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006562 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006563 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6564 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6565 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6566 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6567 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6568 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6569 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6570 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6571 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006572 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006573 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006574 {}
6575};
6576
Kailang Yangdf694da2005-12-05 19:42:22 +01006577static struct alc_config_preset alc260_presets[] = {
6578 [ALC260_BASIC] = {
6579 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006580 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006581 .init_verbs = { alc260_init_verbs },
6582 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6583 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006584 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01006585 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006586 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6587 .channel_mode = alc260_modes,
6588 .input_mux = &alc260_capture_source,
6589 },
6590 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006591 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006592 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006593 .init_verbs = { alc260_init_verbs,
6594 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006595 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6596 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006597 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6598 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006599 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6600 .channel_mode = alc260_modes,
6601 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006602 .unsol_event = alc260_hp_unsol_event,
6603 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006604 },
Kailang Yang3f878302008-08-26 13:02:23 +02006605 [ALC260_HP_DC7600] = {
6606 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006607 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006608 .init_verbs = { alc260_init_verbs,
6609 alc260_hp_dc7600_verbs },
6610 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6611 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006612 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6613 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006614 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6615 .channel_mode = alc260_modes,
6616 .input_mux = &alc260_capture_source,
6617 .unsol_event = alc260_hp_3012_unsol_event,
6618 .init_hook = alc260_hp_3012_automute,
6619 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006620 [ALC260_HP_3013] = {
6621 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006622 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006623 .init_verbs = { alc260_hp_3013_init_verbs,
6624 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006625 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6626 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006627 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6628 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006629 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6630 .channel_mode = alc260_modes,
6631 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006632 .unsol_event = alc260_hp_3013_unsol_event,
6633 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006634 },
6635 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006636 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006637 .init_verbs = { alc260_fujitsu_init_verbs },
6638 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6639 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006640 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6641 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006642 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6643 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006644 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6645 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006646 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006647 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006648 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006649 .init_verbs = { alc260_acer_init_verbs },
6650 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6651 .dac_nids = alc260_dac_nids,
6652 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6653 .adc_nids = alc260_dual_adc_nids,
6654 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6655 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006656 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6657 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006658 },
Michael Schwingencc959482009-02-22 18:58:45 +01006659 [ALC260_FAVORIT100] = {
6660 .mixers = { alc260_favorit100_mixer },
6661 .init_verbs = { alc260_favorit100_init_verbs },
6662 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6663 .dac_nids = alc260_dac_nids,
6664 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6665 .adc_nids = alc260_dual_adc_nids,
6666 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6667 .channel_mode = alc260_modes,
6668 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6669 .input_mux = alc260_favorit100_capture_sources,
6670 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006671 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006672 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006673 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6674 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6675 .dac_nids = alc260_dac_nids,
6676 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6677 .adc_nids = alc260_adc_nids,
6678 .dig_out_nid = ALC260_DIGOUT_NID,
6679 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6680 .channel_mode = alc260_modes,
6681 .input_mux = &alc260_capture_source,
6682 },
6683 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006684 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006685 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6686 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6687 .dac_nids = alc260_dac_nids,
6688 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6689 .adc_nids = alc260_adc_nids,
6690 .dig_out_nid = ALC260_DIGOUT_NID,
6691 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6692 .channel_mode = alc260_modes,
6693 .input_mux = &alc260_capture_source,
6694 .unsol_event = alc260_replacer_672v_unsol_event,
6695 .init_hook = alc260_replacer_672v_automute,
6696 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006697#ifdef CONFIG_SND_DEBUG
6698 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006699 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006700 .init_verbs = { alc260_test_init_verbs },
6701 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6702 .dac_nids = alc260_test_dac_nids,
6703 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6704 .adc_nids = alc260_test_adc_nids,
6705 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6706 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006707 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6708 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006709 },
6710#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006711};
6712
Linus Torvalds1da177e2005-04-16 15:20:36 -07006713static int patch_alc260(struct hda_codec *codec)
6714{
6715 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006716 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006717
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006718 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006719 if (spec == NULL)
6720 return -ENOMEM;
6721
6722 codec->spec = spec;
6723
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006724 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6725 alc260_models,
6726 alc260_cfg_tbl);
6727 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006728 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006729 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006730 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006731 }
6732
Kailang Yangdf694da2005-12-05 19:42:22 +01006733 if (board_config == ALC260_AUTO) {
6734 /* automatic parse from the BIOS config */
6735 err = alc260_parse_auto_config(codec);
6736 if (err < 0) {
6737 alc_free(codec);
6738 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006739 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006740 printk(KERN_INFO
6741 "hda_codec: Cannot set up configuration "
6742 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006743 board_config = ALC260_BASIC;
6744 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006745 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006746
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006747 err = snd_hda_attach_beep_device(codec, 0x1);
6748 if (err < 0) {
6749 alc_free(codec);
6750 return err;
6751 }
6752
Kailang Yangdf694da2005-12-05 19:42:22 +01006753 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006754 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006755
Linus Torvalds1da177e2005-04-16 15:20:36 -07006756 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6757 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6758
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006759 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6760 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6761
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006762 if (!spec->adc_nids && spec->input_mux) {
6763 /* check whether NID 0x04 is valid */
6764 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006765 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006766 /* get type */
6767 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6768 spec->adc_nids = alc260_adc_nids_alt;
6769 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6770 } else {
6771 spec->adc_nids = alc260_adc_nids;
6772 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6773 }
6774 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006775 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006776 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006777
Takashi Iwai2134ea42008-01-10 16:53:55 +01006778 spec->vmaster_nid = 0x08;
6779
Linus Torvalds1da177e2005-04-16 15:20:36 -07006780 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006781 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006782 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006783#ifdef CONFIG_SND_HDA_POWER_SAVE
6784 if (!spec->loopback.amplist)
6785 spec->loopback.amplist = alc260_loopbacks;
6786#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006787
6788 return 0;
6789}
6790
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006791
Linus Torvalds1da177e2005-04-16 15:20:36 -07006792/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006793 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006794 *
6795 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6796 * configuration. Each pin widget can choose any input DACs and a mixer.
6797 * Each ADC is connected from a mixer of all inputs. This makes possible
6798 * 6-channel independent captures.
6799 *
6800 * In addition, an independent DAC for the multi-playback (not used in this
6801 * driver yet).
6802 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006803#define ALC882_DIGOUT_NID 0x06
6804#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006805#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6806#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6807#define ALC1200_DIGOUT_NID 0x10
6808
Linus Torvalds1da177e2005-04-16 15:20:36 -07006809
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006810static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006811 { 8, NULL }
6812};
6813
Takashi Iwai4953550a2009-06-30 15:28:30 +02006814/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006815static hda_nid_t alc882_dac_nids[4] = {
6816 /* front, rear, clfe, rear_surr */
6817 0x02, 0x03, 0x04, 0x05
6818};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006819#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006820
Takashi Iwai4953550a2009-06-30 15:28:30 +02006821/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006822#define alc882_adc_nids alc880_adc_nids
6823#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006824#define alc883_adc_nids alc882_adc_nids_alt
6825static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6826static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6827#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006828
Takashi Iwaie1406342008-02-11 18:32:32 +01006829static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6830static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006831#define alc883_capsrc_nids alc882_capsrc_nids_alt
6832static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6833#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006834
Linus Torvalds1da177e2005-04-16 15:20:36 -07006835/* input MUX */
6836/* FIXME: should be a matrix-type input source selection */
6837
6838static struct hda_input_mux alc882_capture_source = {
6839 .num_items = 4,
6840 .items = {
6841 { "Mic", 0x0 },
6842 { "Front Mic", 0x1 },
6843 { "Line", 0x2 },
6844 { "CD", 0x4 },
6845 },
6846};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006847
Takashi Iwai4953550a2009-06-30 15:28:30 +02006848#define alc883_capture_source alc882_capture_source
6849
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006850static struct hda_input_mux alc889_capture_source = {
6851 .num_items = 3,
6852 .items = {
6853 { "Front Mic", 0x0 },
6854 { "Mic", 0x3 },
6855 { "Line", 0x2 },
6856 },
6857};
6858
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006859static struct hda_input_mux mb5_capture_source = {
6860 .num_items = 3,
6861 .items = {
6862 { "Mic", 0x1 },
6863 { "Line", 0x2 },
6864 { "CD", 0x4 },
6865 },
6866};
6867
Luke Yelaviche458b1f2010-02-12 16:28:29 +11006868static struct hda_input_mux macmini3_capture_source = {
6869 .num_items = 2,
6870 .items = {
6871 { "Line", 0x2 },
6872 { "CD", 0x4 },
6873 },
6874};
6875
Takashi Iwai4953550a2009-06-30 15:28:30 +02006876static struct hda_input_mux alc883_3stack_6ch_intel = {
6877 .num_items = 4,
6878 .items = {
6879 { "Mic", 0x1 },
6880 { "Front Mic", 0x0 },
6881 { "Line", 0x2 },
6882 { "CD", 0x4 },
6883 },
6884};
6885
6886static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6887 .num_items = 2,
6888 .items = {
6889 { "Mic", 0x1 },
6890 { "Line", 0x2 },
6891 },
6892};
6893
6894static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6895 .num_items = 4,
6896 .items = {
6897 { "Mic", 0x0 },
6898 { "iMic", 0x1 },
6899 { "Line", 0x2 },
6900 { "CD", 0x4 },
6901 },
6902};
6903
6904static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6905 .num_items = 2,
6906 .items = {
6907 { "Mic", 0x0 },
6908 { "Int Mic", 0x1 },
6909 },
6910};
6911
6912static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6913 .num_items = 3,
6914 .items = {
6915 { "Mic", 0x0 },
6916 { "Front Mic", 0x1 },
6917 { "Line", 0x4 },
6918 },
6919};
6920
6921static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6922 .num_items = 2,
6923 .items = {
6924 { "Mic", 0x0 },
6925 { "Line", 0x2 },
6926 },
6927};
6928
6929static struct hda_input_mux alc889A_mb31_capture_source = {
6930 .num_items = 2,
6931 .items = {
6932 { "Mic", 0x0 },
6933 /* Front Mic (0x01) unused */
6934 { "Line", 0x2 },
6935 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02006936 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006937 },
6938};
6939
6940/*
6941 * 2ch mode
6942 */
6943static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6944 { 2, NULL }
6945};
6946
Kailang Yangdf694da2005-12-05 19:42:22 +01006947/*
Kailang Yang272a5272007-05-14 11:00:38 +02006948 * 2ch mode
6949 */
6950static struct hda_verb alc882_3ST_ch2_init[] = {
6951 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6952 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6953 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6954 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6955 { } /* end */
6956};
6957
6958/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006959 * 4ch mode
6960 */
6961static struct hda_verb alc882_3ST_ch4_init[] = {
6962 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6963 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6964 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6965 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6966 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6967 { } /* end */
6968};
6969
6970/*
Kailang Yang272a5272007-05-14 11:00:38 +02006971 * 6ch mode
6972 */
6973static struct hda_verb alc882_3ST_ch6_init[] = {
6974 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6975 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6976 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6977 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6978 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6979 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6980 { } /* end */
6981};
6982
Takashi Iwai4953550a2009-06-30 15:28:30 +02006983static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006984 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006985 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006986 { 6, alc882_3ST_ch6_init },
6987};
6988
Takashi Iwai4953550a2009-06-30 15:28:30 +02006989#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6990
Kailang Yang272a5272007-05-14 11:00:38 +02006991/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306992 * 2ch mode
6993 */
6994static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6995 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6996 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6997 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6998 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6999 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7000 { } /* end */
7001};
7002
7003/*
7004 * 4ch mode
7005 */
7006static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7007 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7008 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7009 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7010 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7011 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7012 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7013 { } /* end */
7014};
7015
7016/*
7017 * 6ch mode
7018 */
7019static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7020 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7021 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7022 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7023 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7024 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7025 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7026 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7027 { } /* end */
7028};
7029
7030static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7031 { 2, alc883_3ST_ch2_clevo_init },
7032 { 4, alc883_3ST_ch4_clevo_init },
7033 { 6, alc883_3ST_ch6_clevo_init },
7034};
7035
7036
7037/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007038 * 6ch mode
7039 */
7040static struct hda_verb alc882_sixstack_ch6_init[] = {
7041 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7042 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7043 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7044 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7045 { } /* end */
7046};
7047
7048/*
7049 * 8ch mode
7050 */
7051static struct hda_verb alc882_sixstack_ch8_init[] = {
7052 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7053 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7054 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7055 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7056 { } /* end */
7057};
7058
7059static struct hda_channel_mode alc882_sixstack_modes[2] = {
7060 { 6, alc882_sixstack_ch6_init },
7061 { 8, alc882_sixstack_ch8_init },
7062};
7063
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007064
7065/* Macbook Air 2,1 */
7066
7067static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7068 { 2, NULL },
7069};
7070
Takashi Iwai87350ad2007-08-16 18:19:38 +02007071/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007072 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007073 */
7074
7075/*
7076 * 2ch mode
7077 */
7078static struct hda_verb alc885_mbp_ch2_init[] = {
7079 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7080 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7081 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7082 { } /* end */
7083};
7084
7085/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007086 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007087 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007088static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007089 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7090 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7091 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7092 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7093 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7094 { } /* end */
7095};
7096
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007097static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007098 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007099 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007100};
7101
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007102/*
7103 * 2ch
7104 * Speakers/Woofer/HP = Front
7105 * LineIn = Input
7106 */
7107static struct hda_verb alc885_mb5_ch2_init[] = {
7108 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7109 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7110 { } /* end */
7111};
7112
7113/*
7114 * 6ch mode
7115 * Speakers/HP = Front
7116 * Woofer = LFE
7117 * LineIn = Surround
7118 */
7119static struct hda_verb alc885_mb5_ch6_init[] = {
7120 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7121 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7122 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7123 { } /* end */
7124};
7125
7126static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7127 { 2, alc885_mb5_ch2_init },
7128 { 6, alc885_mb5_ch6_init },
7129};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007130
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007131#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007132
7133/*
7134 * 2ch mode
7135 */
7136static struct hda_verb alc883_4ST_ch2_init[] = {
7137 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7138 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7139 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7140 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7141 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7142 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7143 { } /* end */
7144};
7145
7146/*
7147 * 4ch mode
7148 */
7149static struct hda_verb alc883_4ST_ch4_init[] = {
7150 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7151 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7152 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7153 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7154 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7155 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7156 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7157 { } /* end */
7158};
7159
7160/*
7161 * 6ch mode
7162 */
7163static struct hda_verb alc883_4ST_ch6_init[] = {
7164 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7165 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7166 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7167 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7168 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7169 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7170 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7171 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7172 { } /* end */
7173};
7174
7175/*
7176 * 8ch mode
7177 */
7178static struct hda_verb alc883_4ST_ch8_init[] = {
7179 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7180 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7181 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7182 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7183 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7184 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7185 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7186 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7187 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7188 { } /* end */
7189};
7190
7191static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7192 { 2, alc883_4ST_ch2_init },
7193 { 4, alc883_4ST_ch4_init },
7194 { 6, alc883_4ST_ch6_init },
7195 { 8, alc883_4ST_ch8_init },
7196};
7197
7198
7199/*
7200 * 2ch mode
7201 */
7202static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7203 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7204 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7205 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7206 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7207 { } /* end */
7208};
7209
7210/*
7211 * 4ch mode
7212 */
7213static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7214 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7215 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7216 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7217 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7218 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7219 { } /* end */
7220};
7221
7222/*
7223 * 6ch mode
7224 */
7225static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7226 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7227 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7228 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7229 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7230 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7231 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7232 { } /* end */
7233};
7234
7235static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7236 { 2, alc883_3ST_ch2_intel_init },
7237 { 4, alc883_3ST_ch4_intel_init },
7238 { 6, alc883_3ST_ch6_intel_init },
7239};
7240
7241/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007242 * 2ch mode
7243 */
7244static struct hda_verb alc889_ch2_intel_init[] = {
7245 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7246 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7247 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7248 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7249 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7250 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7251 { } /* end */
7252};
7253
7254/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007255 * 6ch mode
7256 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007257static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007258 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7259 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7260 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7261 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7262 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007263 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7264 { } /* end */
7265};
7266
7267/*
7268 * 8ch mode
7269 */
7270static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007271 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7272 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7273 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7274 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7275 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007276 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7277 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007278 { } /* end */
7279};
7280
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007281static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7282 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007283 { 6, alc889_ch6_intel_init },
7284 { 8, alc889_ch8_intel_init },
7285};
7286
7287/*
7288 * 6ch mode
7289 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007290static struct hda_verb alc883_sixstack_ch6_init[] = {
7291 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7292 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7293 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7294 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7295 { } /* end */
7296};
7297
7298/*
7299 * 8ch mode
7300 */
7301static struct hda_verb alc883_sixstack_ch8_init[] = {
7302 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7303 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7304 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7305 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7306 { } /* end */
7307};
7308
7309static struct hda_channel_mode alc883_sixstack_modes[2] = {
7310 { 6, alc883_sixstack_ch6_init },
7311 { 8, alc883_sixstack_ch8_init },
7312};
7313
7314
Linus Torvalds1da177e2005-04-16 15:20:36 -07007315/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7316 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7317 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007318static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007319 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007320 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007321 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007322 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007323 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7324 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007325 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7326 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007327 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007328 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007329 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7330 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7331 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7332 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7333 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007335 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007336 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7337 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007338 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007339 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007340 { } /* end */
7341};
7342
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007343/* Macbook Air 2,1 same control for HP and internal Speaker */
7344
7345static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7346 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7347 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7348 { }
7349};
7350
7351
Takashi Iwai87350ad2007-08-16 18:19:38 +02007352static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007353 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7354 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7355 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7356 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7357 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007358 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7359 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007360 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7361 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007362 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007363 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7364 { } /* end */
7365};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007366
7367static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007368 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7369 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7370 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7371 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7372 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7373 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307374 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7375 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007376 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7377 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7378 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7379 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7380 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7381 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7382 { } /* end */
7383};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007384
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007385static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7386 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7387 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7388 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7389 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7390 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7391 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7392 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7393 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7394 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7395 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7396 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7397 { } /* end */
7398};
7399
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007400static struct snd_kcontrol_new alc885_imac91_mixer[] = {
7401 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7402 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
7403 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
7404 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7405 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7406 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7407 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7408 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7409 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7410 { } /* end */
7411};
7412
7413
Kailang Yangbdd148a2007-05-08 15:19:08 +02007414static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7415 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7416 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7417 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7418 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7419 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7420 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7421 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7422 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7423 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007424 { } /* end */
7425};
7426
Kailang Yang272a5272007-05-14 11:00:38 +02007427static struct snd_kcontrol_new alc882_targa_mixer[] = {
7428 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7429 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7430 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7431 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7432 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7433 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7434 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7435 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7436 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007437 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007438 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7439 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007440 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007441 { } /* end */
7442};
7443
7444/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7445 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7446 */
7447static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7448 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7449 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7450 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7451 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7452 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7453 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7454 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7455 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7456 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7457 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7458 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7459 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007460 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007461 { } /* end */
7462};
7463
Takashi Iwai914759b2007-09-06 14:52:04 +02007464static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7465 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7466 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7467 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7468 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7469 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7470 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7471 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7473 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7474 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007475 { } /* end */
7476};
7477
Kailang Yangdf694da2005-12-05 19:42:22 +01007478static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7479 {
7480 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7481 .name = "Channel Mode",
7482 .info = alc_ch_mode_info,
7483 .get = alc_ch_mode_get,
7484 .put = alc_ch_mode_put,
7485 },
7486 { } /* end */
7487};
7488
Takashi Iwai4953550a2009-06-30 15:28:30 +02007489static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007490 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007491 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7492 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007493 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007494 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7495 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007496 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007497 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7498 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007499 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007500 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7501 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007502
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007503 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007504 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007505 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007506 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007507 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007508 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007509 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007510 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007511 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007512 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007513 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007514 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007515 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007516 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007517 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007518 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007519 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007520 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007521 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7522 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007523 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007524 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7525 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007526 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007527 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7528 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7529 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7530 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7531 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007532 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007533 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007534
7535 /* FIXME: use matrix-type input source selection */
7536 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007537 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007538 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007539 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007540 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007541 /* ADC2: mute amp left and right */
7542 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007543 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007544 /* ADC3: mute amp left and right */
7545 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007546 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007547
7548 { }
7549};
7550
Takashi Iwai4953550a2009-06-30 15:28:30 +02007551static struct hda_verb alc882_adc1_init_verbs[] = {
7552 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7553 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7554 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7555 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7556 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7557 /* ADC1: mute amp left and right */
7558 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7559 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7560 { }
7561};
7562
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007563static struct hda_verb alc882_eapd_verbs[] = {
7564 /* change to EAPD mode */
7565 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007566 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007567 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007568};
7569
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007570static struct hda_verb alc889_eapd_verbs[] = {
7571 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7572 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7573 { }
7574};
7575
Wu Fengguang6732bd02009-07-30 09:19:14 +02007576static struct hda_verb alc_hp15_unsol_verbs[] = {
7577 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7578 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7579 {}
7580};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007581
7582static struct hda_verb alc885_init_verbs[] = {
7583 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01007584 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7585 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007586 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007587 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7588 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007589 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007590 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7591 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007592 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007593 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7594 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007595
7596 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007597 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007598 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7599 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7600 /* Front Pin: output 0 (0x0c) */
7601 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7602 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7603 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7604 /* Rear Pin: output 1 (0x0d) */
7605 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7606 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7607 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7608 /* CLFE Pin: output 2 (0x0e) */
7609 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7610 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7611 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7612 /* Side Pin: output 3 (0x0f) */
7613 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7614 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7615 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7616 /* Mic (rear) pin: input vref at 80% */
7617 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7618 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7619 /* Front Mic pin: input vref at 80% */
7620 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7621 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7622 /* Line In pin: input */
7623 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7624 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7625
7626 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7627 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01007628 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007629 /* Input mixer2 */
7630 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007631 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01007632 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007633 /* ADC2: mute amp left and right */
7634 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7635 /* ADC3: mute amp left and right */
7636 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7637
7638 { }
7639};
7640
7641static struct hda_verb alc885_init_input_verbs[] = {
7642 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7643 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7644 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7645 { }
7646};
7647
7648
7649/* Unmute Selector 24h and set the default input to front mic */
7650static struct hda_verb alc889_init_input_verbs[] = {
7651 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7652 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7653 { }
7654};
7655
7656
Takashi Iwai4953550a2009-06-30 15:28:30 +02007657#define alc883_init_verbs alc882_base_init_verbs
7658
Tobin Davis9102cd12006-12-15 10:02:12 +01007659/* Mac Pro test */
7660static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7661 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7662 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7663 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7664 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7665 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007666 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007667 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7668 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007669 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007670 { } /* end */
7671};
7672
7673static struct hda_verb alc882_macpro_init_verbs[] = {
7674 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7675 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7676 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7678 /* Front Pin: output 0 (0x0c) */
7679 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7680 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7681 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7682 /* Front Mic pin: input vref at 80% */
7683 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7684 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7685 /* Speaker: output */
7686 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7687 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7688 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7689 /* Headphone output (output 0 - 0x0c) */
7690 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7691 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7692 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7693
7694 /* FIXME: use matrix-type input source selection */
7695 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7696 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7697 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7698 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7699 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7700 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7701 /* Input mixer2 */
7702 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7703 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7704 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7705 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7706 /* Input mixer3 */
7707 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7708 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7709 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7710 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7711 /* ADC1: mute amp left and right */
7712 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7713 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7714 /* ADC2: mute amp left and right */
7715 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7716 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7717 /* ADC3: mute amp left and right */
7718 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7719 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7720
7721 { }
7722};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007723
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007724/* Macbook 5,1 */
7725static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007726 /* DACs */
7727 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7728 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7729 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7730 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007731 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007732 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7733 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7734 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007735 /* Surround mixer */
7736 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7737 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7738 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7739 /* LFE mixer */
7740 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7741 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7742 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7743 /* HP mixer */
7744 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7745 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7746 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7747 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007748 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7749 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007750 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7751 /* LFE Pin (0x0e) */
7752 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7753 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7754 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7755 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007756 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7757 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007758 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10307759 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007760 /* Front Mic pin: input vref at 80% */
7761 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7762 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7763 /* Line In pin */
7764 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7765 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7766
7767 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7768 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7769 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7770 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7771 { }
7772};
7773
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007774/* Macmini 3,1 */
7775static struct hda_verb alc885_macmini3_init_verbs[] = {
7776 /* DACs */
7777 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7778 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7779 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7780 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7781 /* Front mixer */
7782 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7783 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7784 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7785 /* Surround mixer */
7786 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7787 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7788 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7789 /* LFE mixer */
7790 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7791 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7792 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7793 /* HP mixer */
7794 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7795 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7796 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7797 /* Front Pin (0x0c) */
7798 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7799 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7800 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7801 /* LFE Pin (0x0e) */
7802 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7803 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7804 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7805 /* HP Pin (0x0f) */
7806 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7807 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7808 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
7809 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7810 /* Line In pin */
7811 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7812 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7813
7814 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7815 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7816 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7817 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7818 { }
7819};
7820
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007821
7822static struct hda_verb alc885_mba21_init_verbs[] = {
7823 /*Internal and HP Speaker Mixer*/
7824 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7825 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7826 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7827 /*Internal Speaker Pin (0x0c)*/
7828 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
7829 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7830 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7831 /* HP Pin: output 0 (0x0e) */
7832 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7833 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7834 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7835 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
7836 /* Line in (is hp when jack connected)*/
7837 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
7838 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7839
7840 { }
7841 };
7842
7843
Takashi Iwai87350ad2007-08-16 18:19:38 +02007844/* Macbook Pro rev3 */
7845static struct hda_verb alc885_mbp3_init_verbs[] = {
7846 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7847 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7848 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7849 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7850 /* Rear mixer */
7851 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7852 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7853 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007854 /* HP mixer */
7855 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7856 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7857 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007858 /* Front Pin: output 0 (0x0c) */
7859 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7860 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7861 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007862 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007863 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7865 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007866 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7867 /* Mic (rear) pin: input vref at 80% */
7868 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7869 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7870 /* Front Mic pin: input vref at 80% */
7871 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7872 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7873 /* Line In pin: use output 1 when in LineOut mode */
7874 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7875 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7876 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7877
7878 /* FIXME: use matrix-type input source selection */
7879 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7880 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7881 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7882 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7883 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7884 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7885 /* Input mixer2 */
7886 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7887 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7888 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7889 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7890 /* Input mixer3 */
7891 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7892 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7893 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7894 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7895 /* ADC1: mute amp left and right */
7896 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7897 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7898 /* ADC2: mute amp left and right */
7899 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7900 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7901 /* ADC3: mute amp left and right */
7902 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7903 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7904
7905 { }
7906};
7907
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007908/* iMac 9,1 */
7909static struct hda_verb alc885_imac91_init_verbs[] = {
7910 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
7911 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7912 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7913 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7914 /* Rear mixer */
7915 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7916 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7917 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7918 /* HP Pin: output 0 (0x0c) */
7919 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7920 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7921 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7922 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7923 /* Internal Speakers: output 0 (0x0d) */
7924 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7925 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7926 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7927 /* Mic (rear) pin: input vref at 80% */
7928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7930 /* Front Mic pin: input vref at 80% */
7931 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7932 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7933 /* Line In pin: use output 1 when in LineOut mode */
7934 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7935 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7936 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7937
7938 /* FIXME: use matrix-type input source selection */
7939 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7940 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7941 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7942 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7943 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7944 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7945 /* Input mixer2 */
7946 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7947 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7948 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7949 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7950 /* Input mixer3 */
7951 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7954 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7955 /* ADC1: mute amp left and right */
7956 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7957 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7958 /* ADC2: mute amp left and right */
7959 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7960 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7961 /* ADC3: mute amp left and right */
7962 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7963 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7964
7965 { }
7966};
7967
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007968/* iMac 24 mixer. */
7969static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7970 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7971 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7972 { } /* end */
7973};
7974
7975/* iMac 24 init verbs. */
7976static struct hda_verb alc885_imac24_init_verbs[] = {
7977 /* Internal speakers: output 0 (0x0c) */
7978 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7979 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7980 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7981 /* Internal speakers: output 0 (0x0c) */
7982 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7983 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7984 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7985 /* Headphone: output 0 (0x0c) */
7986 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7987 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7988 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7989 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7990 /* Front Mic: input vref at 80% */
7991 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7992 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7993 { }
7994};
7995
7996/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007997static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007998{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007999 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008000
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008001 spec->autocfg.hp_pins[0] = 0x14;
8002 spec->autocfg.speaker_pins[0] = 0x18;
8003 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008004}
8005
Takashi Iwai9d54f082010-02-22 08:34:40 +01008006#define alc885_mb5_setup alc885_imac24_setup
8007#define alc885_macmini3_setup alc885_imac24_setup
8008
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008009/* Macbook Air 2,1 */
8010static void alc885_mba21_setup(struct hda_codec *codec)
8011{
8012 struct alc_spec *spec = codec->spec;
8013
8014 spec->autocfg.hp_pins[0] = 0x14;
8015 spec->autocfg.speaker_pins[0] = 0x18;
8016}
8017
8018
8019
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008020static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008021{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008022 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008023
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008024 spec->autocfg.hp_pins[0] = 0x15;
8025 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008026}
8027
Takashi Iwai9d54f082010-02-22 08:34:40 +01008028static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308029{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008030 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308031
Takashi Iwai9d54f082010-02-22 08:34:40 +01008032 spec->autocfg.hp_pins[0] = 0x14;
8033 spec->autocfg.speaker_pins[0] = 0x15;
8034 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008035}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008036
Kailang Yang272a5272007-05-14 11:00:38 +02008037static struct hda_verb alc882_targa_verbs[] = {
8038 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8039 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8040
8041 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8042 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008043
Kailang Yang272a5272007-05-14 11:00:38 +02008044 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8045 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8046 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8047
8048 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008049 { } /* end */
8050};
8051
8052/* toggle speaker-output according to the hp-jack state */
8053static void alc882_targa_automute(struct hda_codec *codec)
8054{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008055 struct alc_spec *spec = codec->spec;
8056 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008057 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008058 spec->jack_present ? 1 : 3);
8059}
8060
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008061static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008062{
8063 struct alc_spec *spec = codec->spec;
8064
8065 spec->autocfg.hp_pins[0] = 0x14;
8066 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008067}
8068
8069static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8070{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008071 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008072 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008073}
8074
8075static struct hda_verb alc882_asus_a7j_verbs[] = {
8076 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8077 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8078
8079 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8080 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8081 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008082
Kailang Yang272a5272007-05-14 11:00:38 +02008083 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8084 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8085 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8086
8087 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8088 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8089 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8090 { } /* end */
8091};
8092
Takashi Iwai914759b2007-09-06 14:52:04 +02008093static struct hda_verb alc882_asus_a7m_verbs[] = {
8094 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8095 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8096
8097 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8098 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8099 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008100
Takashi Iwai914759b2007-09-06 14:52:04 +02008101 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8102 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8103 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8104
8105 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8106 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8107 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8108 { } /* end */
8109};
8110
Tobin Davis9102cd12006-12-15 10:02:12 +01008111static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8112{
8113 unsigned int gpiostate, gpiomask, gpiodir;
8114
8115 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8116 AC_VERB_GET_GPIO_DATA, 0);
8117
8118 if (!muted)
8119 gpiostate |= (1 << pin);
8120 else
8121 gpiostate &= ~(1 << pin);
8122
8123 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8124 AC_VERB_GET_GPIO_MASK, 0);
8125 gpiomask |= (1 << pin);
8126
8127 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8128 AC_VERB_GET_GPIO_DIRECTION, 0);
8129 gpiodir |= (1 << pin);
8130
8131
8132 snd_hda_codec_write(codec, codec->afg, 0,
8133 AC_VERB_SET_GPIO_MASK, gpiomask);
8134 snd_hda_codec_write(codec, codec->afg, 0,
8135 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8136
8137 msleep(1);
8138
8139 snd_hda_codec_write(codec, codec->afg, 0,
8140 AC_VERB_SET_GPIO_DATA, gpiostate);
8141}
8142
Takashi Iwai7debbe52007-08-16 15:01:03 +02008143/* set up GPIO at initialization */
8144static void alc885_macpro_init_hook(struct hda_codec *codec)
8145{
8146 alc882_gpio_mute(codec, 0, 0);
8147 alc882_gpio_mute(codec, 1, 0);
8148}
8149
8150/* set up GPIO and update auto-muting at initialization */
8151static void alc885_imac24_init_hook(struct hda_codec *codec)
8152{
8153 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008154 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008155}
8156
Kailang Yangdf694da2005-12-05 19:42:22 +01008157/*
8158 * generic initialization of ADC, input mixers and output mixers
8159 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008160static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008161 /*
8162 * Unmute ADC0-2 and set the default input to mic-in
8163 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008164 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8165 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8166 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8167 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8168
Kailang Yangdf694da2005-12-05 19:42:22 +01008169 /*
8170 * Set up output mixers (0x0c - 0x0f)
8171 */
8172 /* set vol=0 to output mixers */
8173 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8174 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8175 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8176 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8177 /* set up input amps for analog loopback */
8178 /* Amp Indices: DAC = 0, mixer = 1 */
8179 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8180 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8181 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8182 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8183 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8184 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8185 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8186 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8187 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8188 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8189
8190 /* FIXME: use matrix-type input source selection */
8191 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008192 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008193 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008194 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008195 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008196 { }
8197};
8198
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008199/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8200static struct hda_verb alc889A_mb31_ch2_init[] = {
8201 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8202 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8203 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8204 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8205 { } /* end */
8206};
8207
8208/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8209static struct hda_verb alc889A_mb31_ch4_init[] = {
8210 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8211 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8212 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8213 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8214 { } /* end */
8215};
8216
8217/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8218static struct hda_verb alc889A_mb31_ch5_init[] = {
8219 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8220 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8221 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8222 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8223 { } /* end */
8224};
8225
8226/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8227static struct hda_verb alc889A_mb31_ch6_init[] = {
8228 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8229 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8230 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8231 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8232 { } /* end */
8233};
8234
8235static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8236 { 2, alc889A_mb31_ch2_init },
8237 { 4, alc889A_mb31_ch4_init },
8238 { 5, alc889A_mb31_ch5_init },
8239 { 6, alc889A_mb31_ch6_init },
8240};
8241
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008242static struct hda_verb alc883_medion_eapd_verbs[] = {
8243 /* eanable EAPD on medion laptop */
8244 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8245 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8246 { }
8247};
8248
Takashi Iwai4953550a2009-06-30 15:28:30 +02008249#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008250
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008251static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8252 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8253 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8254 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8255 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8256 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8257 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8258 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8259 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8260 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8261 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8262 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8263 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8264 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008265 { } /* end */
8266};
8267
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008268static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008269 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8270 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8271 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8272 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8273 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8274 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8275 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8276 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8277 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8278 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008279 { } /* end */
8280};
8281
Jiang zhefb97dc62008-03-06 11:07:11 +01008282static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8283 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8284 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8285 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8286 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8287 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8288 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8289 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8290 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8291 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8292 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008293 { } /* end */
8294};
8295
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008296static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8297 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8298 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8299 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8300 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8301 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8302 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8303 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8304 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008305 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008306 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8307 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008308 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008309 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008310 { } /* end */
8311};
8312
8313static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8314 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8315 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8316 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8317 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8318 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8319 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8320 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8321 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8322 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8323 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8324 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8325 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8326 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8327 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008328 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008329 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8330 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008331 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008332 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008333 { } /* end */
8334};
8335
Jiang zhe17bba1b2008-06-04 12:11:07 +02008336static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8337 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8338 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8339 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8340 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8341 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8342 HDA_OUTPUT),
8343 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8344 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8345 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8346 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8347 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8348 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8349 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8350 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8351 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8352 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8353 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8354 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8355 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8356 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008357 { } /* end */
8358};
8359
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008360static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8361 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8362 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8363 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8364 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8365 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8366 HDA_OUTPUT),
8367 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8368 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8369 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8370 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8371 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8372 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8373 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8374 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8375 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8376 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8377 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8378 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8379 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8380 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8381 { } /* end */
8382};
8383
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008384static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008385 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008386 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008387 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008388 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008389 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8390 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008391 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8392 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008393 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8394 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8395 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8396 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8397 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8398 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008399 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008400 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8401 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008402 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008403 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008404 { } /* end */
8405};
8406
Sasha Alexandrc2592492009-06-16 14:52:54 -04008407static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008408 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008409 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008410 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008411 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008412 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8413 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8414 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8415 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8416 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8417 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8418 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8419 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8420 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8421 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8422 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008423 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008424 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008425 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008426};
Kailang Yangccc656c2006-10-17 12:32:26 +02008427
Sasha Alexandrc2592492009-06-16 14:52:54 -04008428static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008429 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008430 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008431 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008432 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008433 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8434 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8435 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008436 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008437 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008438 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8439 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8440 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008441 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008442};
Kailang Yangccc656c2006-10-17 12:32:26 +02008443
Takashi Iwaib99dba32009-09-17 18:23:00 +02008444static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8445 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8446 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8447 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8448 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8449 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8450 { } /* end */
8451};
8452
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008453static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8454 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8455 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008456 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8457 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008458 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8459 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8460 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8461 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008462 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008463};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008464
Kailang Yang272a5272007-05-14 11:00:38 +02008465static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8466 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8467 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8468 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8469 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8470 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8471 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8472 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8473 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8474 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008475 { } /* end */
8476};
8477
8478static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8479 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8480 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8481 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8482 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8483 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8484 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8485 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8486 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8487 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008488 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008489};
Kailang Yang272a5272007-05-14 11:00:38 +02008490
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02008491static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
8492 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8493 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8494 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8495 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
8496 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
8497 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
8498 { } /* end */
8499};
8500
8501static struct hda_verb alc883_medion_wim2160_verbs[] = {
8502 /* Unmute front mixer */
8503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8505
8506 /* Set speaker pin to front mixer */
8507 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8508
8509 /* Init headphone pin */
8510 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8511 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8512 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8513 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8514
8515 { } /* end */
8516};
8517
8518/* toggle speaker-output according to the hp-jack state */
8519static void alc883_medion_wim2160_setup(struct hda_codec *codec)
8520{
8521 struct alc_spec *spec = codec->spec;
8522
8523 spec->autocfg.hp_pins[0] = 0x1a;
8524 spec->autocfg.speaker_pins[0] = 0x15;
8525}
8526
Tobin Davis2880a862007-08-07 11:50:26 +02008527static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008528 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8529 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008530 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008531 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8532 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008533 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8534 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8535 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008536 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008537};
Tobin Davis2880a862007-08-07 11:50:26 +02008538
Tony Vroond2fd4b02009-06-21 00:40:10 +01008539static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8540 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008541 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008542 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8543 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008544 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8545 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8546 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8547 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8548 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8549 { } /* end */
8550};
8551
Kailang Yange2757d52008-08-26 13:17:46 +02008552static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8553 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8554 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8555 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8556 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8557 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8558 0x0d, 1, 0x0, HDA_OUTPUT),
8559 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8560 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8561 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8562 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8563 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008564 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8565 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, 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 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8569 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8570 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8571 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8572 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8573 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008574 { } /* end */
8575};
8576
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008577static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8578 /* Output mixers */
8579 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8580 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8581 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8582 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8583 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8584 HDA_OUTPUT),
8585 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8586 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8587 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8588 /* Output switches */
8589 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8590 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8591 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8592 /* Boost mixers */
8593 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8594 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8595 /* Input mixers */
8596 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8597 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8598 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8599 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8600 { } /* end */
8601};
8602
Guido Günther3e1647c2009-06-05 00:47:26 +02008603static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8604 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8605 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8606 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8607 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8608 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8609 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8610 { } /* end */
8611};
8612
Kailang Yange2757d52008-08-26 13:17:46 +02008613static struct hda_bind_ctls alc883_bind_cap_vol = {
8614 .ops = &snd_hda_bind_vol,
8615 .values = {
8616 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8617 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8618 0
8619 },
8620};
8621
8622static struct hda_bind_ctls alc883_bind_cap_switch = {
8623 .ops = &snd_hda_bind_sw,
8624 .values = {
8625 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8626 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8627 0
8628 },
8629};
8630
8631static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8632 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8633 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8634 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8635 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8636 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8637 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8638 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8639 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008640 { } /* end */
8641};
8642
8643static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008644 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8645 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8646 {
8647 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8648 /* .name = "Capture Source", */
8649 .name = "Input Source",
8650 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008651 .info = alc_mux_enum_info,
8652 .get = alc_mux_enum_get,
8653 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008654 },
8655 { } /* end */
8656};
8657
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008658static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8659 {
8660 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8661 .name = "Channel Mode",
8662 .info = alc_ch_mode_info,
8663 .get = alc_ch_mode_get,
8664 .put = alc_ch_mode_put,
8665 },
8666 { } /* end */
8667};
8668
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008669/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008670static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008671{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008672 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008673
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008674 spec->autocfg.hp_pins[0] = 0x15;
8675 spec->autocfg.speaker_pins[0] = 0x14;
8676 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008677}
8678
8679/* auto-toggle front mic */
8680/*
8681static void alc883_mitac_mic_automute(struct hda_codec *codec)
8682{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008683 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008684
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008685 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8686}
8687*/
8688
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008689static struct hda_verb alc883_mitac_verbs[] = {
8690 /* HP */
8691 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8692 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8693 /* Subwoofer */
8694 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8695 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8696
8697 /* enable unsolicited event */
8698 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8699 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8700
8701 { } /* end */
8702};
8703
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308704static struct hda_verb alc883_clevo_m540r_verbs[] = {
8705 /* HP */
8706 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8707 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8708 /* Int speaker */
8709 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8710
8711 /* enable unsolicited event */
8712 /*
8713 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8714 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8715 */
8716
8717 { } /* end */
8718};
8719
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008720static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008721 /* HP */
8722 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8723 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8724 /* Int speaker */
8725 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8726 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8727
8728 /* enable unsolicited event */
8729 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008730 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008731
8732 { } /* end */
8733};
8734
Jiang zhefb97dc62008-03-06 11:07:11 +01008735static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8736 /* HP */
8737 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8738 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8739 /* Subwoofer */
8740 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8741 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8742
8743 /* enable unsolicited event */
8744 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8745
8746 { } /* end */
8747};
8748
Sasha Alexandrc2592492009-06-16 14:52:54 -04008749static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008750 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8751 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8752
8753 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8754 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008755
David Heidelberger64a8be72009-06-08 16:15:18 +02008756/* Connect Line-Out side jack (SPDIF) to Side */
8757 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8758 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8759 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8760/* Connect Mic jack to CLFE */
8761 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8762 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8763 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8764/* Connect Line-in jack to Surround */
8765 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8766 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8767 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8768/* Connect HP out jack to Front */
8769 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8770 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8771 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008772
8773 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008774
8775 { } /* end */
8776};
8777
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008778static struct hda_verb alc883_lenovo_101e_verbs[] = {
8779 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8780 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8781 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8782 { } /* end */
8783};
8784
Kailang Yang272a5272007-05-14 11:00:38 +02008785static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8786 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8787 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8788 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8789 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8790 { } /* end */
8791};
8792
8793static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8794 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8795 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8796 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8797 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8798 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8799 { } /* end */
8800};
8801
Kailang Yang189609a2007-08-20 11:31:23 +02008802static struct hda_verb alc883_haier_w66_verbs[] = {
8803 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8804 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8805
8806 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8807
8808 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8809 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8810 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8811 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8812 { } /* end */
8813};
8814
Kailang Yange2757d52008-08-26 13:17:46 +02008815static struct hda_verb alc888_lenovo_sky_verbs[] = {
8816 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8817 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8818 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8819 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8820 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8821 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8822 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8823 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8824 { } /* end */
8825};
8826
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008827static struct hda_verb alc888_6st_dell_verbs[] = {
8828 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8829 { }
8830};
8831
Guido Günther3e1647c2009-06-05 00:47:26 +02008832static struct hda_verb alc883_vaiott_verbs[] = {
8833 /* HP */
8834 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8835 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8836
8837 /* enable unsolicited event */
8838 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8839
8840 { } /* end */
8841};
8842
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008843static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008844{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008845 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008846
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008847 spec->autocfg.hp_pins[0] = 0x1b;
8848 spec->autocfg.speaker_pins[0] = 0x14;
8849 spec->autocfg.speaker_pins[1] = 0x16;
8850 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008851}
8852
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008853static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008854 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008855 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8856 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008857 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008858 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008859};
8860
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008861/*
8862 * 2ch mode
8863 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008864static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008865 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8866 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8867 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8868 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008869 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008870};
8871
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008872/*
8873 * 4ch mode
8874 */
8875static struct hda_verb alc888_3st_hp_4ch_init[] = {
8876 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8877 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8878 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8879 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8880 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8881 { } /* end */
8882};
8883
8884/*
8885 * 6ch mode
8886 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008887static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008888 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8889 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008890 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008891 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8892 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008893 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8894 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008895};
8896
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008897static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008898 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008899 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008900 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008901};
8902
Kailang Yang272a5272007-05-14 11:00:38 +02008903/* toggle front-jack and RCA according to the hp-jack state */
8904static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8905{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008906 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008907
Takashi Iwai47fd8302007-08-10 17:11:07 +02008908 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8909 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8910 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8911 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008912}
8913
8914/* toggle RCA according to the front-jack state */
8915static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8916{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008917 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02008918
Takashi Iwai47fd8302007-08-10 17:11:07 +02008919 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8920 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008921}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008922
Kailang Yang272a5272007-05-14 11:00:38 +02008923static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8924 unsigned int res)
8925{
8926 if ((res >> 26) == ALC880_HP_EVENT)
8927 alc888_lenovo_ms7195_front_automute(codec);
8928 if ((res >> 26) == ALC880_FRONT_EVENT)
8929 alc888_lenovo_ms7195_rca_automute(codec);
8930}
8931
8932static struct hda_verb alc883_medion_md2_verbs[] = {
8933 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8934 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8935
8936 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8937
8938 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8939 { } /* end */
8940};
8941
8942/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008943static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008944{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008945 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008946
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008947 spec->autocfg.hp_pins[0] = 0x14;
8948 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008949}
8950
Kailang Yangccc656c2006-10-17 12:32:26 +02008951/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008952#define alc883_targa_init_hook alc882_targa_init_hook
8953#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008954
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008955static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8956{
8957 unsigned int present;
8958
Takashi Iwaid56757a2009-11-18 08:00:14 +01008959 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008960 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8961 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8962}
8963
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008964static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008965{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008966 struct alc_spec *spec = codec->spec;
8967
8968 spec->autocfg.hp_pins[0] = 0x15;
8969 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008970}
8971
8972static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8973{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008974 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008975 alc883_clevo_m720_mic_automute(codec);
8976}
8977
8978static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008979 unsigned int res)
8980{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008981 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008982 case ALC880_MIC_EVENT:
8983 alc883_clevo_m720_mic_automute(codec);
8984 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008985 default:
8986 alc_automute_amp_unsol_event(codec, res);
8987 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008988 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008989}
8990
Jiang zhefb97dc62008-03-06 11:07:11 +01008991/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008992static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008993{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008994 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008995
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008996 spec->autocfg.hp_pins[0] = 0x14;
8997 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008998}
8999
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009000static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009001{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009002 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009003
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009004 spec->autocfg.hp_pins[0] = 0x1b;
9005 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009006}
9007
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009008static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9009{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009010 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009011
Takashi Iwai47fd8302007-08-10 17:11:07 +02009012 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9013 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009014}
9015
9016static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9017{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009018 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009019
Takashi Iwai47fd8302007-08-10 17:11:07 +02009020 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9021 HDA_AMP_MUTE, bits);
9022 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9023 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009024}
9025
9026static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9027 unsigned int res)
9028{
9029 if ((res >> 26) == ALC880_HP_EVENT)
9030 alc883_lenovo_101e_all_automute(codec);
9031 if ((res >> 26) == ALC880_FRONT_EVENT)
9032 alc883_lenovo_101e_ispeaker_automute(codec);
9033}
9034
Takashi Iwai676a9b52007-08-16 15:23:35 +02009035/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009036static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009037{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009038 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009039
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009040 spec->autocfg.hp_pins[0] = 0x14;
9041 spec->autocfg.speaker_pins[0] = 0x15;
9042 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009043}
9044
Kailang Yangd1a991a2007-08-15 16:21:59 +02009045static struct hda_verb alc883_acer_eapd_verbs[] = {
9046 /* HP Pin: output 0 (0x0c) */
9047 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9048 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9049 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9050 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009051 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9052 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009053 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009054 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9055 /* eanable EAPD on medion laptop */
9056 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9057 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009058 /* enable unsolicited event */
9059 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009060 { }
9061};
9062
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009063static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
9064 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9065 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9066 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9067 { } /* end */
9068};
9069
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009070static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009071{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009072 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009073
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009074 spec->autocfg.hp_pins[0] = 0x1b;
9075 spec->autocfg.speaker_pins[0] = 0x14;
9076 spec->autocfg.speaker_pins[1] = 0x15;
9077 spec->autocfg.speaker_pins[2] = 0x16;
9078 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009079}
9080
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009081static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009082{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009083 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009084
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009085 spec->autocfg.hp_pins[0] = 0x1b;
9086 spec->autocfg.speaker_pins[0] = 0x14;
9087 spec->autocfg.speaker_pins[1] = 0x15;
9088 spec->autocfg.speaker_pins[2] = 0x16;
9089 spec->autocfg.speaker_pins[3] = 0x17;
9090 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009091}
9092
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009093static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009094{
9095 struct alc_spec *spec = codec->spec;
9096
9097 spec->autocfg.hp_pins[0] = 0x15;
9098 spec->autocfg.speaker_pins[0] = 0x14;
9099 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009100}
9101
Kailang Yange2757d52008-08-26 13:17:46 +02009102static struct hda_verb alc888_asus_m90v_verbs[] = {
9103 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9104 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9105 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9106 /* enable unsolicited event */
9107 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9108 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9109 { } /* end */
9110};
9111
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009112static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009113{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009114 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009115
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009116 spec->autocfg.hp_pins[0] = 0x1b;
9117 spec->autocfg.speaker_pins[0] = 0x14;
9118 spec->autocfg.speaker_pins[1] = 0x15;
9119 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009120 spec->ext_mic.pin = 0x18;
9121 spec->int_mic.pin = 0x19;
9122 spec->ext_mic.mux_idx = 0;
9123 spec->int_mic.mux_idx = 1;
9124 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009125}
9126
9127static struct hda_verb alc888_asus_eee1601_verbs[] = {
9128 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9129 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9130 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9131 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9132 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9133 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9134 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9135 /* enable unsolicited event */
9136 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9137 { } /* end */
9138};
9139
Kailang Yange2757d52008-08-26 13:17:46 +02009140static void alc883_eee1601_inithook(struct hda_codec *codec)
9141{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009142 struct alc_spec *spec = codec->spec;
9143
9144 spec->autocfg.hp_pins[0] = 0x14;
9145 spec->autocfg.speaker_pins[0] = 0x1b;
9146 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009147}
9148
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009149static struct hda_verb alc889A_mb31_verbs[] = {
9150 /* Init rear pin (used as headphone output) */
9151 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9152 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9153 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9154 /* Init line pin (used as output in 4ch and 6ch mode) */
9155 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9156 /* Init line 2 pin (used as headphone out by default) */
9157 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9158 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9159 { } /* end */
9160};
9161
9162/* Mute speakers according to the headphone jack state */
9163static void alc889A_mb31_automute(struct hda_codec *codec)
9164{
9165 unsigned int present;
9166
9167 /* Mute only in 2ch or 4ch mode */
9168 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9169 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009170 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009171 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9172 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9173 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9174 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9175 }
9176}
9177
9178static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9179{
9180 if ((res >> 26) == ALC880_HP_EVENT)
9181 alc889A_mb31_automute(codec);
9182}
9183
Takashi Iwai4953550a2009-06-30 15:28:30 +02009184
Takashi Iwaicb53c622007-08-10 17:21:45 +02009185#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009186#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009187#endif
9188
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009189/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009190#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9191#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9192#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9193#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9194
9195static hda_nid_t alc883_slave_dig_outs[] = {
9196 ALC1200_DIGOUT_NID, 0,
9197};
9198
9199static hda_nid_t alc1200_slave_dig_outs[] = {
9200 ALC883_DIGOUT_NID, 0,
9201};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009202
9203/*
9204 * configuration and preset
9205 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009206static const char *alc882_models[ALC882_MODEL_LAST] = {
9207 [ALC882_3ST_DIG] = "3stack-dig",
9208 [ALC882_6ST_DIG] = "6stack-dig",
9209 [ALC882_ARIMA] = "arima",
9210 [ALC882_W2JC] = "w2jc",
9211 [ALC882_TARGA] = "targa",
9212 [ALC882_ASUS_A7J] = "asus-a7j",
9213 [ALC882_ASUS_A7M] = "asus-a7m",
9214 [ALC885_MACPRO] = "macpro",
9215 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009216 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009217 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009218 [ALC885_MBP3] = "mbp3",
9219 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009220 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009221 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009222 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9223 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009224 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009225 [ALC883_TARGA_DIG] = "targa-dig",
9226 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009227 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009228 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009229 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009230 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009231 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009232 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009233 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009234 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009235 [ALC883_MEDION_MD2] = "medion-md2",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009236 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009237 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009238 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009239 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9240 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009241 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009242 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009243 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009244 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009245 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309246 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009247 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009248 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009249 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009250 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009251 [ALC889A_INTEL] = "intel-alc889a",
9252 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009253 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009254 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009255 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009256 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009257};
9258
Takashi Iwai4953550a2009-06-30 15:28:30 +02009259static struct snd_pci_quirk alc882_cfg_tbl[] = {
9260 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9261
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009262 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009263 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009264 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009265 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9266 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009267 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009268 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9269 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009270 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009271 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009272 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9273 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009274 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9275 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009276 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9277 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009278 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009279 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009280 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009281 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009282 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9283 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009284 /* default Acer -- disabled as it causes more problems.
9285 * model=auto should work fine now
9286 */
9287 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009288
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009289 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009290
Tobin Davisfebe3372007-06-12 11:27:46 +02009291 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009292 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9293 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009294 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009295 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009296 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009297
9298 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9299 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9300 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009301 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009302 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9303 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9304 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009305 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009306 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009307 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009308 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009309
9310 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009311 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009312 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009313 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009314 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9315 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009316 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009317 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009318 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9319
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009320 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9321 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9322 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009323 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009324 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009325 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009326 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009327 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009328 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9329 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9330 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9331 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9332 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9333 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009334 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009335 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9336 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9337 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009338 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009339 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009340 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9341 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009342 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009343 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009344 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009345 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009346 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009347 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009348 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009349 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009350 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009351
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009352 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009353 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9354 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309355 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009356 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009357 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009358 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009359 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009360 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009361 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009362 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009363 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009364 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009365 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009366 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9367 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009368 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009369 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009370 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009371 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009372 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009373
Jiang zhe17bba1b2008-06-04 12:11:07 +02009374 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9375 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009376 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009377 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9378 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9379 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009380 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009381
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009382 {}
9383};
9384
Takashi Iwai4953550a2009-06-30 15:28:30 +02009385/* codec SSID table for Intel Mac */
9386static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9387 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9388 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9389 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9390 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9391 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9392 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9393 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
9394 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9395 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9396 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009397 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009398 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009399 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9400 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009401 */
9402 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009403 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009404 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009405 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009406};
9407
Takashi Iwai4953550a2009-06-30 15:28:30 +02009408static struct alc_config_preset alc882_presets[] = {
9409 [ALC882_3ST_DIG] = {
9410 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009411 .init_verbs = { alc882_base_init_verbs,
9412 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009413 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9414 .dac_nids = alc882_dac_nids,
9415 .dig_out_nid = ALC882_DIGOUT_NID,
9416 .dig_in_nid = ALC882_DIGIN_NID,
9417 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9418 .channel_mode = alc882_ch_modes,
9419 .need_dac_fix = 1,
9420 .input_mux = &alc882_capture_source,
9421 },
9422 [ALC882_6ST_DIG] = {
9423 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009424 .init_verbs = { alc882_base_init_verbs,
9425 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009426 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9427 .dac_nids = alc882_dac_nids,
9428 .dig_out_nid = ALC882_DIGOUT_NID,
9429 .dig_in_nid = ALC882_DIGIN_NID,
9430 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9431 .channel_mode = alc882_sixstack_modes,
9432 .input_mux = &alc882_capture_source,
9433 },
9434 [ALC882_ARIMA] = {
9435 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009436 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9437 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009438 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9439 .dac_nids = alc882_dac_nids,
9440 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9441 .channel_mode = alc882_sixstack_modes,
9442 .input_mux = &alc882_capture_source,
9443 },
9444 [ALC882_W2JC] = {
9445 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009446 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9447 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009448 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9449 .dac_nids = alc882_dac_nids,
9450 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9451 .channel_mode = alc880_threestack_modes,
9452 .need_dac_fix = 1,
9453 .input_mux = &alc882_capture_source,
9454 .dig_out_nid = ALC882_DIGOUT_NID,
9455 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009456 [ALC885_MBA21] = {
9457 .mixers = { alc885_mba21_mixer },
9458 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9459 .num_dacs = 2,
9460 .dac_nids = alc882_dac_nids,
9461 .channel_mode = alc885_mba21_ch_modes,
9462 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9463 .input_mux = &alc882_capture_source,
9464 .unsol_event = alc_automute_amp_unsol_event,
9465 .setup = alc885_mba21_setup,
9466 .init_hook = alc_automute_amp,
9467 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009468 [ALC885_MBP3] = {
9469 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9470 .init_verbs = { alc885_mbp3_init_verbs,
9471 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009472 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009473 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009474 .hp_nid = 0x04,
9475 .channel_mode = alc885_mbp_4ch_modes,
9476 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009477 .input_mux = &alc882_capture_source,
9478 .dig_out_nid = ALC882_DIGOUT_NID,
9479 .dig_in_nid = ALC882_DIGIN_NID,
9480 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009481 .setup = alc885_mbp3_setup,
9482 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009483 },
9484 [ALC885_MB5] = {
9485 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9486 .init_verbs = { alc885_mb5_init_verbs,
9487 alc880_gpio1_init_verbs },
9488 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9489 .dac_nids = alc882_dac_nids,
9490 .channel_mode = alc885_mb5_6ch_modes,
9491 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9492 .input_mux = &mb5_capture_source,
9493 .dig_out_nid = ALC882_DIGOUT_NID,
9494 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009495 .unsol_event = alc_automute_amp_unsol_event,
9496 .setup = alc885_mb5_setup,
9497 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009498 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009499 [ALC885_MACMINI3] = {
9500 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9501 .init_verbs = { alc885_macmini3_init_verbs,
9502 alc880_gpio1_init_verbs },
9503 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9504 .dac_nids = alc882_dac_nids,
9505 .channel_mode = alc885_macmini3_6ch_modes,
9506 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9507 .input_mux = &macmini3_capture_source,
9508 .dig_out_nid = ALC882_DIGOUT_NID,
9509 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009510 .unsol_event = alc_automute_amp_unsol_event,
9511 .setup = alc885_macmini3_setup,
9512 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009513 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009514 [ALC885_MACPRO] = {
9515 .mixers = { alc882_macpro_mixer },
9516 .init_verbs = { alc882_macpro_init_verbs },
9517 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9518 .dac_nids = alc882_dac_nids,
9519 .dig_out_nid = ALC882_DIGOUT_NID,
9520 .dig_in_nid = ALC882_DIGIN_NID,
9521 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9522 .channel_mode = alc882_ch_modes,
9523 .input_mux = &alc882_capture_source,
9524 .init_hook = alc885_macpro_init_hook,
9525 },
9526 [ALC885_IMAC24] = {
9527 .mixers = { alc885_imac24_mixer },
9528 .init_verbs = { alc885_imac24_init_verbs },
9529 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9530 .dac_nids = alc882_dac_nids,
9531 .dig_out_nid = ALC882_DIGOUT_NID,
9532 .dig_in_nid = ALC882_DIGIN_NID,
9533 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9534 .channel_mode = alc882_ch_modes,
9535 .input_mux = &alc882_capture_source,
9536 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009537 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009538 .init_hook = alc885_imac24_init_hook,
9539 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009540 [ALC885_IMAC91] = {
9541 .mixers = { alc885_imac91_mixer, alc882_chmode_mixer },
9542 .init_verbs = { alc885_imac91_init_verbs,
9543 alc880_gpio1_init_verbs },
9544 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9545 .dac_nids = alc882_dac_nids,
9546 .channel_mode = alc885_mbp_4ch_modes,
9547 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
9548 .input_mux = &alc882_capture_source,
9549 .dig_out_nid = ALC882_DIGOUT_NID,
9550 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009551 .unsol_event = alc_automute_amp_unsol_event,
9552 .setup = alc885_imac91_setup,
9553 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009554 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009555 [ALC882_TARGA] = {
9556 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009557 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009558 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009559 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9560 .dac_nids = alc882_dac_nids,
9561 .dig_out_nid = ALC882_DIGOUT_NID,
9562 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9563 .adc_nids = alc882_adc_nids,
9564 .capsrc_nids = alc882_capsrc_nids,
9565 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9566 .channel_mode = alc882_3ST_6ch_modes,
9567 .need_dac_fix = 1,
9568 .input_mux = &alc882_capture_source,
9569 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009570 .setup = alc882_targa_setup,
9571 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009572 },
9573 [ALC882_ASUS_A7J] = {
9574 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009575 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9576 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009577 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9578 .dac_nids = alc882_dac_nids,
9579 .dig_out_nid = ALC882_DIGOUT_NID,
9580 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9581 .adc_nids = alc882_adc_nids,
9582 .capsrc_nids = alc882_capsrc_nids,
9583 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9584 .channel_mode = alc882_3ST_6ch_modes,
9585 .need_dac_fix = 1,
9586 .input_mux = &alc882_capture_source,
9587 },
9588 [ALC882_ASUS_A7M] = {
9589 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009590 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9591 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009592 alc882_asus_a7m_verbs },
9593 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9594 .dac_nids = alc882_dac_nids,
9595 .dig_out_nid = ALC882_DIGOUT_NID,
9596 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9597 .channel_mode = alc880_threestack_modes,
9598 .need_dac_fix = 1,
9599 .input_mux = &alc882_capture_source,
9600 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009601 [ALC883_3ST_2ch_DIG] = {
9602 .mixers = { alc883_3ST_2ch_mixer },
9603 .init_verbs = { alc883_init_verbs },
9604 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9605 .dac_nids = alc883_dac_nids,
9606 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009607 .dig_in_nid = ALC883_DIGIN_NID,
9608 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9609 .channel_mode = alc883_3ST_2ch_modes,
9610 .input_mux = &alc883_capture_source,
9611 },
9612 [ALC883_3ST_6ch_DIG] = {
9613 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9614 .init_verbs = { alc883_init_verbs },
9615 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9616 .dac_nids = alc883_dac_nids,
9617 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009618 .dig_in_nid = ALC883_DIGIN_NID,
9619 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9620 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009621 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009622 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009623 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009624 [ALC883_3ST_6ch] = {
9625 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9626 .init_verbs = { alc883_init_verbs },
9627 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9628 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009629 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9630 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009631 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009632 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009633 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009634 [ALC883_3ST_6ch_INTEL] = {
9635 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9636 .init_verbs = { alc883_init_verbs },
9637 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9638 .dac_nids = alc883_dac_nids,
9639 .dig_out_nid = ALC883_DIGOUT_NID,
9640 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009641 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009642 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9643 .channel_mode = alc883_3ST_6ch_intel_modes,
9644 .need_dac_fix = 1,
9645 .input_mux = &alc883_3stack_6ch_intel,
9646 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009647 [ALC889A_INTEL] = {
9648 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009649 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9650 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009651 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9652 .dac_nids = alc883_dac_nids,
9653 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9654 .adc_nids = alc889_adc_nids,
9655 .dig_out_nid = ALC883_DIGOUT_NID,
9656 .dig_in_nid = ALC883_DIGIN_NID,
9657 .slave_dig_outs = alc883_slave_dig_outs,
9658 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9659 .channel_mode = alc889_8ch_intel_modes,
9660 .capsrc_nids = alc889_capsrc_nids,
9661 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009662 .setup = alc889_automute_setup,
9663 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009664 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009665 .need_dac_fix = 1,
9666 },
9667 [ALC889_INTEL] = {
9668 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9669 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009670 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009671 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9672 .dac_nids = alc883_dac_nids,
9673 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9674 .adc_nids = alc889_adc_nids,
9675 .dig_out_nid = ALC883_DIGOUT_NID,
9676 .dig_in_nid = ALC883_DIGIN_NID,
9677 .slave_dig_outs = alc883_slave_dig_outs,
9678 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9679 .channel_mode = alc889_8ch_intel_modes,
9680 .capsrc_nids = alc889_capsrc_nids,
9681 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009682 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009683 .init_hook = alc889_intel_init_hook,
9684 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009685 .need_dac_fix = 1,
9686 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009687 [ALC883_6ST_DIG] = {
9688 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9689 .init_verbs = { alc883_init_verbs },
9690 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9691 .dac_nids = alc883_dac_nids,
9692 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009693 .dig_in_nid = ALC883_DIGIN_NID,
9694 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9695 .channel_mode = alc883_sixstack_modes,
9696 .input_mux = &alc883_capture_source,
9697 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009698 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009699 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009700 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9701 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009702 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9703 .dac_nids = alc883_dac_nids,
9704 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009705 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9706 .channel_mode = alc883_3ST_6ch_modes,
9707 .need_dac_fix = 1,
9708 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009709 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009710 .setup = alc882_targa_setup,
9711 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009712 },
9713 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009714 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009715 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9716 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009717 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9718 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009719 .adc_nids = alc883_adc_nids_alt,
9720 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009721 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009722 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009723 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9724 .channel_mode = alc883_3ST_2ch_modes,
9725 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009726 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009727 .setup = alc882_targa_setup,
9728 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009729 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009730 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009731 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9732 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009733 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009734 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009735 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9736 .dac_nids = alc883_dac_nids,
9737 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9738 .adc_nids = alc883_adc_nids_rev,
9739 .capsrc_nids = alc883_capsrc_nids_rev,
9740 .dig_out_nid = ALC883_DIGOUT_NID,
9741 .dig_in_nid = ALC883_DIGIN_NID,
9742 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9743 .channel_mode = alc883_4ST_8ch_modes,
9744 .need_dac_fix = 1,
9745 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009746 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009747 .setup = alc882_targa_setup,
9748 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009749 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009750 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009751 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009752 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9753 * and the headphone jack. Turn this on and rely on the
9754 * standard mute methods whenever the user wants to turn
9755 * these outputs off.
9756 */
9757 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9758 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9759 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009760 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9761 .channel_mode = alc883_3ST_2ch_modes,
9762 .input_mux = &alc883_capture_source,
9763 },
Tobin Davis2880a862007-08-07 11:50:26 +02009764 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009765 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009766 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009767 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9768 .dac_nids = alc883_dac_nids,
9769 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009770 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9771 .channel_mode = alc883_3ST_2ch_modes,
9772 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009773 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009774 .setup = alc883_acer_aspire_setup,
9775 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009776 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009777 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009778 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009779 alc883_chmode_mixer },
9780 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9781 alc888_acer_aspire_4930g_verbs },
9782 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9783 .dac_nids = alc883_dac_nids,
9784 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9785 .adc_nids = alc883_adc_nids_rev,
9786 .capsrc_nids = alc883_capsrc_nids_rev,
9787 .dig_out_nid = ALC883_DIGOUT_NID,
9788 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9789 .channel_mode = alc883_3ST_6ch_modes,
9790 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +01009791 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009792 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009793 ARRAY_SIZE(alc888_2_capture_sources),
9794 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009795 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009796 .setup = alc888_acer_aspire_4930g_setup,
9797 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009798 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009799 [ALC888_ACER_ASPIRE_6530G] = {
9800 .mixers = { alc888_acer_aspire_6530_mixer },
9801 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9802 alc888_acer_aspire_6530g_verbs },
9803 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9804 .dac_nids = alc883_dac_nids,
9805 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9806 .adc_nids = alc883_adc_nids_rev,
9807 .capsrc_nids = alc883_capsrc_nids_rev,
9808 .dig_out_nid = ALC883_DIGOUT_NID,
9809 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9810 .channel_mode = alc883_3ST_2ch_modes,
9811 .num_mux_defs =
9812 ARRAY_SIZE(alc888_2_capture_sources),
9813 .input_mux = alc888_acer_aspire_6530_sources,
9814 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009815 .setup = alc888_acer_aspire_6530g_setup,
9816 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009817 },
Hector Martin3b315d72009-06-02 10:54:19 +02009818 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +01009819 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +02009820 alc883_chmode_mixer },
9821 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +01009822 alc889_acer_aspire_8930g_verbs,
9823 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +02009824 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9825 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009826 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9827 .adc_nids = alc889_adc_nids,
9828 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009829 .dig_out_nid = ALC883_DIGOUT_NID,
9830 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9831 .channel_mode = alc883_3ST_6ch_modes,
9832 .need_dac_fix = 1,
9833 .const_channel_count = 6,
9834 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009835 ARRAY_SIZE(alc889_capture_sources),
9836 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009837 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009838 .setup = alc889_acer_aspire_8930g_setup,
9839 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +01009840#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05009841 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +01009842#endif
Hector Martin3b315d72009-06-02 10:54:19 +02009843 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009844 [ALC888_ACER_ASPIRE_7730G] = {
9845 .mixers = { alc883_3ST_6ch_mixer,
9846 alc883_chmode_mixer },
9847 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9848 alc888_acer_aspire_7730G_verbs },
9849 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9850 .dac_nids = alc883_dac_nids,
9851 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9852 .adc_nids = alc883_adc_nids_rev,
9853 .capsrc_nids = alc883_capsrc_nids_rev,
9854 .dig_out_nid = ALC883_DIGOUT_NID,
9855 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9856 .channel_mode = alc883_3ST_6ch_modes,
9857 .need_dac_fix = 1,
9858 .const_channel_count = 6,
9859 .input_mux = &alc883_capture_source,
9860 .unsol_event = alc_automute_amp_unsol_event,
9861 .setup = alc888_acer_aspire_6530g_setup,
9862 .init_hook = alc_automute_amp,
9863 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009864 [ALC883_MEDION] = {
9865 .mixers = { alc883_fivestack_mixer,
9866 alc883_chmode_mixer },
9867 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009868 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009869 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9870 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009871 .adc_nids = alc883_adc_nids_alt,
9872 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009873 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009874 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9875 .channel_mode = alc883_sixstack_modes,
9876 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009877 },
Kailang Yang272a5272007-05-14 11:00:38 +02009878 [ALC883_MEDION_MD2] = {
9879 .mixers = { alc883_medion_md2_mixer},
9880 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9881 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9882 .dac_nids = alc883_dac_nids,
9883 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009884 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9885 .channel_mode = alc883_3ST_2ch_modes,
9886 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009887 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009888 .setup = alc883_medion_md2_setup,
9889 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009890 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009891 [ALC883_MEDION_WIM2160] = {
9892 .mixers = { alc883_medion_wim2160_mixer },
9893 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
9894 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9895 .dac_nids = alc883_dac_nids,
9896 .dig_out_nid = ALC883_DIGOUT_NID,
9897 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9898 .adc_nids = alc883_adc_nids,
9899 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9900 .channel_mode = alc883_3ST_2ch_modes,
9901 .input_mux = &alc883_capture_source,
9902 .unsol_event = alc_automute_amp_unsol_event,
9903 .setup = alc883_medion_wim2160_setup,
9904 .init_hook = alc_automute_amp,
9905 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009906 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009907 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009908 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9909 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9910 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009911 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9912 .channel_mode = alc883_3ST_2ch_modes,
9913 .input_mux = &alc883_capture_source,
9914 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309915 [ALC883_CLEVO_M540R] = {
9916 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9917 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9918 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9919 .dac_nids = alc883_dac_nids,
9920 .dig_out_nid = ALC883_DIGOUT_NID,
9921 .dig_in_nid = ALC883_DIGIN_NID,
9922 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9923 .channel_mode = alc883_3ST_6ch_clevo_modes,
9924 .need_dac_fix = 1,
9925 .input_mux = &alc883_capture_source,
9926 /* This machine has the hardware HP auto-muting, thus
9927 * we need no software mute via unsol event
9928 */
9929 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009930 [ALC883_CLEVO_M720] = {
9931 .mixers = { alc883_clevo_m720_mixer },
9932 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009933 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9934 .dac_nids = alc883_dac_nids,
9935 .dig_out_nid = ALC883_DIGOUT_NID,
9936 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9937 .channel_mode = alc883_3ST_2ch_modes,
9938 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009939 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009940 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009941 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009942 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009943 [ALC883_LENOVO_101E_2ch] = {
9944 .mixers = { alc883_lenovo_101e_2ch_mixer},
9945 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9946 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9947 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009948 .adc_nids = alc883_adc_nids_alt,
9949 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009950 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009951 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9952 .channel_mode = alc883_3ST_2ch_modes,
9953 .input_mux = &alc883_lenovo_101e_capture_source,
9954 .unsol_event = alc883_lenovo_101e_unsol_event,
9955 .init_hook = alc883_lenovo_101e_all_automute,
9956 },
Kailang Yang272a5272007-05-14 11:00:38 +02009957 [ALC883_LENOVO_NB0763] = {
9958 .mixers = { alc883_lenovo_nb0763_mixer },
9959 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9960 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9961 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009962 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9963 .channel_mode = alc883_3ST_2ch_modes,
9964 .need_dac_fix = 1,
9965 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009966 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009967 .setup = alc883_medion_md2_setup,
9968 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009969 },
9970 [ALC888_LENOVO_MS7195_DIG] = {
9971 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9972 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9973 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9974 .dac_nids = alc883_dac_nids,
9975 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009976 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9977 .channel_mode = alc883_3ST_6ch_modes,
9978 .need_dac_fix = 1,
9979 .input_mux = &alc883_capture_source,
9980 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9981 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009982 },
9983 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009984 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009985 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9986 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9987 .dac_nids = alc883_dac_nids,
9988 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009989 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9990 .channel_mode = alc883_3ST_2ch_modes,
9991 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009992 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009993 .setup = alc883_haier_w66_setup,
9994 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009995 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009996 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009997 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009998 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009999 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10000 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010001 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10002 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010003 .need_dac_fix = 1,
10004 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010005 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010006 .setup = alc888_3st_hp_setup,
10007 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010008 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010009 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010010 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010011 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10012 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10013 .dac_nids = alc883_dac_nids,
10014 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010015 .dig_in_nid = ALC883_DIGIN_NID,
10016 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10017 .channel_mode = alc883_sixstack_modes,
10018 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010019 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010020 .setup = alc888_6st_dell_setup,
10021 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010022 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010023 [ALC883_MITAC] = {
10024 .mixers = { alc883_mitac_mixer },
10025 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10026 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10027 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010028 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10029 .channel_mode = alc883_3ST_2ch_modes,
10030 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010031 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010032 .setup = alc883_mitac_setup,
10033 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010034 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010035 [ALC883_FUJITSU_PI2515] = {
10036 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10037 .init_verbs = { alc883_init_verbs,
10038 alc883_2ch_fujitsu_pi2515_verbs},
10039 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10040 .dac_nids = alc883_dac_nids,
10041 .dig_out_nid = ALC883_DIGOUT_NID,
10042 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10043 .channel_mode = alc883_3ST_2ch_modes,
10044 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010045 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010046 .setup = alc883_2ch_fujitsu_pi2515_setup,
10047 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010048 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010049 [ALC888_FUJITSU_XA3530] = {
10050 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10051 .init_verbs = { alc883_init_verbs,
10052 alc888_fujitsu_xa3530_verbs },
10053 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10054 .dac_nids = alc883_dac_nids,
10055 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10056 .adc_nids = alc883_adc_nids_rev,
10057 .capsrc_nids = alc883_capsrc_nids_rev,
10058 .dig_out_nid = ALC883_DIGOUT_NID,
10059 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10060 .channel_mode = alc888_4ST_8ch_intel_modes,
10061 .num_mux_defs =
10062 ARRAY_SIZE(alc888_2_capture_sources),
10063 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010064 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010065 .setup = alc888_fujitsu_xa3530_setup,
10066 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010067 },
Kailang Yange2757d52008-08-26 13:17:46 +020010068 [ALC888_LENOVO_SKY] = {
10069 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10070 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10071 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10072 .dac_nids = alc883_dac_nids,
10073 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010074 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10075 .channel_mode = alc883_sixstack_modes,
10076 .need_dac_fix = 1,
10077 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010078 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010079 .setup = alc888_lenovo_sky_setup,
10080 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010081 },
10082 [ALC888_ASUS_M90V] = {
10083 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10084 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10085 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10086 .dac_nids = alc883_dac_nids,
10087 .dig_out_nid = ALC883_DIGOUT_NID,
10088 .dig_in_nid = ALC883_DIGIN_NID,
10089 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10090 .channel_mode = alc883_3ST_6ch_modes,
10091 .need_dac_fix = 1,
10092 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010093 .unsol_event = alc_sku_unsol_event,
10094 .setup = alc883_mode2_setup,
10095 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010096 },
10097 [ALC888_ASUS_EEE1601] = {
10098 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010099 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010100 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10101 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10102 .dac_nids = alc883_dac_nids,
10103 .dig_out_nid = ALC883_DIGOUT_NID,
10104 .dig_in_nid = ALC883_DIGIN_NID,
10105 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10106 .channel_mode = alc883_3ST_2ch_modes,
10107 .need_dac_fix = 1,
10108 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010109 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010110 .init_hook = alc883_eee1601_inithook,
10111 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010112 [ALC1200_ASUS_P5Q] = {
10113 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10114 .init_verbs = { alc883_init_verbs },
10115 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10116 .dac_nids = alc883_dac_nids,
10117 .dig_out_nid = ALC1200_DIGOUT_NID,
10118 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010119 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010120 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10121 .channel_mode = alc883_sixstack_modes,
10122 .input_mux = &alc883_capture_source,
10123 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010124 [ALC889A_MB31] = {
10125 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10126 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10127 alc880_gpio1_init_verbs },
10128 .adc_nids = alc883_adc_nids,
10129 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010130 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010131 .dac_nids = alc883_dac_nids,
10132 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10133 .channel_mode = alc889A_mb31_6ch_modes,
10134 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10135 .input_mux = &alc889A_mb31_capture_source,
10136 .dig_out_nid = ALC883_DIGOUT_NID,
10137 .unsol_event = alc889A_mb31_unsol_event,
10138 .init_hook = alc889A_mb31_automute,
10139 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010140 [ALC883_SONY_VAIO_TT] = {
10141 .mixers = { alc883_vaiott_mixer },
10142 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10143 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10144 .dac_nids = alc883_dac_nids,
10145 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10146 .channel_mode = alc883_3ST_2ch_modes,
10147 .input_mux = &alc883_capture_source,
10148 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010149 .setup = alc883_vaiott_setup,
10150 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010151 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010152};
10153
10154
10155/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010156 * Pin config fixes
10157 */
10158enum {
10159 PINFIX_ABIT_AW9D_MAX
10160};
10161
10162static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
10163 { 0x15, 0x01080104 }, /* side */
10164 { 0x16, 0x01011012 }, /* rear */
10165 { 0x17, 0x01016011 }, /* clfe */
10166 { }
10167};
10168
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010169static const struct alc_fixup alc882_fixups[] = {
10170 [PINFIX_ABIT_AW9D_MAX] = {
10171 .pins = alc882_abit_aw9d_pinfix
10172 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010173};
10174
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010175static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +020010176 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10177 {}
10178};
10179
10180/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010181 * BIOS auto configuration
10182 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010183static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10184 const struct auto_pin_cfg *cfg)
10185{
10186 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10187}
10188
Takashi Iwai4953550a2009-06-30 15:28:30 +020010189static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010190 hda_nid_t nid, int pin_type,
10191 int dac_idx)
10192{
10193 /* set as output */
10194 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010195 int idx;
10196
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010197 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaif9700d52010-04-05 23:25:13 +020010198 if (dac_idx >= spec->multiout.num_dacs)
10199 return;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010200 if (spec->multiout.dac_nids[dac_idx] == 0x25)
10201 idx = 4;
Takashi Iwaif9700d52010-04-05 23:25:13 +020010202 else
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010203 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010204 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
10205
10206}
10207
Takashi Iwai4953550a2009-06-30 15:28:30 +020010208static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010209{
10210 struct alc_spec *spec = codec->spec;
10211 int i;
10212
10213 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010214 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010215 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010216 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010217 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010218 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010219 }
10220}
10221
Takashi Iwai4953550a2009-06-30 15:28:30 +020010222static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010223{
10224 struct alc_spec *spec = codec->spec;
10225 hda_nid_t pin;
10226
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010227 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010228 if (pin) /* connect to front */
10229 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010230 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010231 pin = spec->autocfg.speaker_pins[0];
10232 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010233 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010234}
10235
Takashi Iwai4953550a2009-06-30 15:28:30 +020010236static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010237{
10238 struct alc_spec *spec = codec->spec;
10239 int i;
10240
10241 for (i = 0; i < AUTO_PIN_LAST; i++) {
10242 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010243 if (!nid)
10244 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +020010245 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010246 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10247 snd_hda_codec_write(codec, nid, 0,
10248 AC_VERB_SET_AMP_GAIN_MUTE,
10249 AMP_OUT_MUTE);
10250 }
10251}
10252
10253static void alc882_auto_init_input_src(struct hda_codec *codec)
10254{
10255 struct alc_spec *spec = codec->spec;
10256 int c;
10257
10258 for (c = 0; c < spec->num_adc_nids; c++) {
10259 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10260 hda_nid_t nid = spec->capsrc_nids[c];
10261 unsigned int mux_idx;
10262 const struct hda_input_mux *imux;
10263 int conns, mute, idx, item;
10264
10265 conns = snd_hda_get_connections(codec, nid, conn_list,
10266 ARRAY_SIZE(conn_list));
10267 if (conns < 0)
10268 continue;
10269 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10270 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010271 if (!imux->num_items && mux_idx > 0)
10272 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010273 for (idx = 0; idx < conns; idx++) {
10274 /* if the current connection is the selected one,
10275 * unmute it as default - otherwise mute it
10276 */
10277 mute = AMP_IN_MUTE(idx);
10278 for (item = 0; item < imux->num_items; item++) {
10279 if (imux->items[item].index == idx) {
10280 if (spec->cur_mux[c] == item)
10281 mute = AMP_IN_UNMUTE(idx);
10282 break;
10283 }
10284 }
10285 /* check if we have a selector or mixer
10286 * we could check for the widget type instead, but
10287 * just check for Amp-In presence (in case of mixer
10288 * without amp-in there is something wrong, this
10289 * function shouldn't be used or capsrc nid is wrong)
10290 */
10291 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010292 snd_hda_codec_write(codec, nid, 0,
10293 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010294 mute);
10295 else if (mute != AMP_IN_MUTE(idx))
10296 snd_hda_codec_write(codec, nid, 0,
10297 AC_VERB_SET_CONNECT_SEL,
10298 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010299 }
10300 }
10301}
10302
Takashi Iwai4953550a2009-06-30 15:28:30 +020010303/* add mic boosts if needed */
10304static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010305{
10306 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010307 int err;
10308 hda_nid_t nid;
10309
10310 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
10311 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10312 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10313 "Mic Boost",
10314 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10315 if (err < 0)
10316 return err;
10317 }
10318 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
10319 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10320 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10321 "Front Mic Boost",
10322 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10323 if (err < 0)
10324 return err;
10325 }
10326 return 0;
10327}
10328
10329/* almost identical with ALC880 parser... */
10330static int alc882_parse_auto_config(struct hda_codec *codec)
10331{
10332 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010333 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
10334 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010335
Takashi Iwai05f5f472009-08-25 13:10:18 +020010336 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10337 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010338 if (err < 0)
10339 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010340 if (!spec->autocfg.line_outs)
10341 return 0; /* can't find valid BIOS pin config */
10342
10343 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10344 if (err < 0)
10345 return err;
10346 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10347 if (err < 0)
10348 return err;
10349 err = alc880_auto_create_extra_out(spec,
10350 spec->autocfg.speaker_pins[0],
10351 "Speaker");
10352 if (err < 0)
10353 return err;
10354 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10355 "Headphone");
10356 if (err < 0)
10357 return err;
10358 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10359 if (err < 0)
10360 return err;
10361
10362 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10363
10364 /* check multiple SPDIF-out (for recent codecs) */
10365 for (i = 0; i < spec->autocfg.dig_outs; i++) {
10366 hda_nid_t dig_nid;
10367 err = snd_hda_get_connections(codec,
10368 spec->autocfg.dig_out_pins[i],
10369 &dig_nid, 1);
10370 if (err < 0)
10371 continue;
10372 if (!i)
10373 spec->multiout.dig_out_nid = dig_nid;
10374 else {
10375 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010376 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +020010377 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010378 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010379 }
10380 }
10381 if (spec->autocfg.dig_in_pin)
10382 spec->dig_in_nid = ALC880_DIGIN_NID;
10383
10384 if (spec->kctls.list)
10385 add_mixer(spec, spec->kctls.list);
10386
10387 add_verb(spec, alc883_auto_init_verbs);
10388 /* if ADC 0x07 is available, initialize it, too */
10389 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10390 add_verb(spec, alc882_adc1_init_verbs);
10391
10392 spec->num_mux_defs = 1;
10393 spec->input_mux = &spec->private_imux[0];
10394
Kailang Yang6227cdc2010-02-25 08:36:52 +010010395 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010396
10397 err = alc_auto_add_mic_boost(codec);
10398 if (err < 0)
10399 return err;
10400
Takashi Iwai776e1842007-08-29 15:07:11 +020010401 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010402}
10403
10404/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010405static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010406{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010407 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010408 alc882_auto_init_multi_out(codec);
10409 alc882_auto_init_hp_out(codec);
10410 alc882_auto_init_analog_input(codec);
10411 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010412 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010413 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010414}
10415
Takashi Iwai4953550a2009-06-30 15:28:30 +020010416static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010417{
10418 struct alc_spec *spec;
10419 int err, board_config;
10420
10421 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10422 if (spec == NULL)
10423 return -ENOMEM;
10424
10425 codec->spec = spec;
10426
Takashi Iwai4953550a2009-06-30 15:28:30 +020010427 switch (codec->vendor_id) {
10428 case 0x10ec0882:
10429 case 0x10ec0885:
10430 break;
10431 default:
10432 /* ALC883 and variants */
10433 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10434 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010435 }
10436
Takashi Iwai4953550a2009-06-30 15:28:30 +020010437 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10438 alc882_models,
10439 alc882_cfg_tbl);
10440
10441 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10442 board_config = snd_hda_check_board_codec_sid_config(codec,
10443 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10444
10445 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010446 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010447 codec->chip_name);
10448 board_config = ALC882_AUTO;
10449 }
10450
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010451 if (board_config == ALC882_AUTO)
10452 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010453
10454 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010455 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010456 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010457 if (err < 0) {
10458 alc_free(codec);
10459 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010460 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010461 printk(KERN_INFO
10462 "hda_codec: Cannot set up configuration "
10463 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010464 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010465 }
10466 }
10467
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010468 err = snd_hda_attach_beep_device(codec, 0x1);
10469 if (err < 0) {
10470 alc_free(codec);
10471 return err;
10472 }
10473
Takashi Iwai4953550a2009-06-30 15:28:30 +020010474 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010475 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010476
Takashi Iwai4953550a2009-06-30 15:28:30 +020010477 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10478 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10479 /* FIXME: setup DAC5 */
10480 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10481 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10482
10483 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10484 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10485
10486 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010487 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010488
10489 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010490 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010491 spec->num_adc_nids = 0;
10492 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010493 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010494 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010495 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010496 hda_nid_t nid = alc882_adc_nids[i];
10497 unsigned int wcap = get_wcaps(codec, nid);
10498 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010499 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010500 if (wcap != AC_WID_AUD_IN)
10501 continue;
10502 spec->private_adc_nids[spec->num_adc_nids] = nid;
10503 err = snd_hda_get_connections(codec, nid, &cap, 1);
10504 if (err < 0)
10505 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010506 err = snd_hda_get_connections(codec, cap, items,
10507 ARRAY_SIZE(items));
10508 if (err < 0)
10509 continue;
10510 for (j = 0; j < imux->num_items; j++)
10511 if (imux->items[j].index >= err)
10512 break;
10513 if (j < imux->num_items)
10514 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010515 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10516 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010517 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010518 spec->adc_nids = spec->private_adc_nids;
10519 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010520 }
10521
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010522 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010010523 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010524
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010525 if (board_config == ALC882_AUTO)
10526 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
10527
Takashi Iwai2134ea42008-01-10 16:53:55 +010010528 spec->vmaster_nid = 0x0c;
10529
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010530 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010531 if (board_config == ALC882_AUTO)
10532 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010533#ifdef CONFIG_SND_HDA_POWER_SAVE
10534 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010535 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010536#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010537
10538 return 0;
10539}
10540
Takashi Iwai4953550a2009-06-30 15:28:30 +020010541
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010542/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010543 * ALC262 support
10544 */
10545
10546#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10547#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10548
10549#define alc262_dac_nids alc260_dac_nids
10550#define alc262_adc_nids alc882_adc_nids
10551#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010552#define alc262_capsrc_nids alc882_capsrc_nids
10553#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010554
10555#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010556#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010557
Kailang Yang4e555fe2008-08-26 13:05:55 +020010558static hda_nid_t alc262_dmic_adc_nids[1] = {
10559 /* ADC0 */
10560 0x09
10561};
10562
10563static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10564
Kailang Yangdf694da2005-12-05 19:42:22 +010010565static struct snd_kcontrol_new alc262_base_mixer[] = {
10566 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10567 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10568 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10569 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10570 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10571 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10572 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10573 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010574 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010575 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10576 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010577 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010578 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10579 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10580 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10581 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010582 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010583};
10584
Takashi Iwaice875f02008-01-28 18:17:43 +010010585/* update HP, line and mono-out pins according to the master switch */
10586static void alc262_hp_master_update(struct hda_codec *codec)
10587{
10588 struct alc_spec *spec = codec->spec;
10589 int val = spec->master_sw;
10590
10591 /* HP & line-out */
10592 snd_hda_codec_write_cache(codec, 0x1b, 0,
10593 AC_VERB_SET_PIN_WIDGET_CONTROL,
10594 val ? PIN_HP : 0);
10595 snd_hda_codec_write_cache(codec, 0x15, 0,
10596 AC_VERB_SET_PIN_WIDGET_CONTROL,
10597 val ? PIN_HP : 0);
10598 /* mono (speaker) depending on the HP jack sense */
10599 val = val && !spec->jack_present;
10600 snd_hda_codec_write_cache(codec, 0x16, 0,
10601 AC_VERB_SET_PIN_WIDGET_CONTROL,
10602 val ? PIN_OUT : 0);
10603}
10604
10605static void alc262_hp_bpc_automute(struct hda_codec *codec)
10606{
10607 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010608
10609 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010610 alc262_hp_master_update(codec);
10611}
10612
10613static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10614{
10615 if ((res >> 26) != ALC880_HP_EVENT)
10616 return;
10617 alc262_hp_bpc_automute(codec);
10618}
10619
10620static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10621{
10622 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010623
10624 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010625 alc262_hp_master_update(codec);
10626}
10627
10628static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10629 unsigned int res)
10630{
10631 if ((res >> 26) != ALC880_HP_EVENT)
10632 return;
10633 alc262_hp_wildwest_automute(codec);
10634}
10635
Takashi Iwaib72519b2009-05-08 14:31:55 +020010636#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010637
10638static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10639 struct snd_ctl_elem_value *ucontrol)
10640{
10641 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10642 struct alc_spec *spec = codec->spec;
10643 int val = !!*ucontrol->value.integer.value;
10644
10645 if (val == spec->master_sw)
10646 return 0;
10647 spec->master_sw = val;
10648 alc262_hp_master_update(codec);
10649 return 1;
10650}
10651
Takashi Iwaib72519b2009-05-08 14:31:55 +020010652#define ALC262_HP_MASTER_SWITCH \
10653 { \
10654 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10655 .name = "Master Playback Switch", \
10656 .info = snd_ctl_boolean_mono_info, \
10657 .get = alc262_hp_master_sw_get, \
10658 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010659 }, \
10660 { \
10661 .iface = NID_MAPPING, \
10662 .name = "Master Playback Switch", \
10663 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020010664 }
10665
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010666
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010667static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010668 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010669 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10670 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10671 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010672 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10673 HDA_OUTPUT),
10674 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10675 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010676 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10677 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010678 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010679 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10680 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010681 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010682 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10683 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10684 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10685 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010686 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10687 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10688 { } /* end */
10689};
10690
Kailang Yangcd7509a2007-01-26 18:33:17 +010010691static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010692 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010693 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10694 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10695 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10696 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010697 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10698 HDA_OUTPUT),
10699 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10700 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010701 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10702 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010703 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010704 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10705 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10706 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10707 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010708 { } /* end */
10709};
10710
10711static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10712 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10713 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010714 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010715 { } /* end */
10716};
10717
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010718/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010719static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010720{
10721 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010722
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010723 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010010724 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010725}
10726
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010727static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010728 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10729 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010730 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10731 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10732 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10733 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10734 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10735 { } /* end */
10736};
10737
10738static struct hda_verb alc262_hp_t5735_verbs[] = {
10739 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10740 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10741
10742 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10743 { }
10744};
10745
Kailang Yang8c427222008-01-10 13:03:59 +010010746static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010747 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10748 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010749 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10750 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010751 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10752 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10753 { } /* end */
10754};
10755
10756static struct hda_verb alc262_hp_rp5700_verbs[] = {
10757 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10758 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10759 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10760 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10761 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10762 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10763 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10764 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10765 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10766 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10767 {}
10768};
10769
10770static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10771 .num_items = 1,
10772 .items = {
10773 { "Line", 0x1 },
10774 },
10775};
10776
Takashi Iwai42171c12009-05-08 14:11:43 +020010777/* bind hp and internal speaker mute (with plug check) as master switch */
10778static void alc262_hippo_master_update(struct hda_codec *codec)
10779{
10780 struct alc_spec *spec = codec->spec;
10781 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10782 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10783 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10784 unsigned int mute;
10785
10786 /* HP */
10787 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10788 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10789 HDA_AMP_MUTE, mute);
10790 /* mute internal speaker per jack sense */
10791 if (spec->jack_present)
10792 mute = HDA_AMP_MUTE;
10793 if (line_nid)
10794 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10795 HDA_AMP_MUTE, mute);
10796 if (speaker_nid && speaker_nid != line_nid)
10797 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10798 HDA_AMP_MUTE, mute);
10799}
10800
10801#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10802
10803static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10804 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010805{
10806 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010807 struct alc_spec *spec = codec->spec;
10808 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010809
Takashi Iwai42171c12009-05-08 14:11:43 +020010810 if (val == spec->master_sw)
10811 return 0;
10812 spec->master_sw = val;
10813 alc262_hippo_master_update(codec);
10814 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010815}
Takashi Iwai5b319542007-07-26 11:49:22 +020010816
Takashi Iwai42171c12009-05-08 14:11:43 +020010817#define ALC262_HIPPO_MASTER_SWITCH \
10818 { \
10819 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10820 .name = "Master Playback Switch", \
10821 .info = snd_ctl_boolean_mono_info, \
10822 .get = alc262_hippo_master_sw_get, \
10823 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010824 }, \
10825 { \
10826 .iface = NID_MAPPING, \
10827 .name = "Master Playback Switch", \
10828 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
10829 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020010830 }
10831
10832static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10833 ALC262_HIPPO_MASTER_SWITCH,
10834 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10835 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10836 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10837 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10838 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10839 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10840 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10841 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10842 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10843 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10844 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10845 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10846 { } /* end */
10847};
10848
10849static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10850 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10851 ALC262_HIPPO_MASTER_SWITCH,
10852 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10853 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10854 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10855 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10856 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10857 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10858 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10859 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10860 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10861 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10862 { } /* end */
10863};
10864
10865/* mute/unmute internal speaker according to the hp jack and mute state */
10866static void alc262_hippo_automute(struct hda_codec *codec)
10867{
10868 struct alc_spec *spec = codec->spec;
10869 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010870
Wu Fengguang864f92b2009-11-18 12:38:02 +080010871 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010872 alc262_hippo_master_update(codec);
10873}
10874
10875static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10876{
10877 if ((res >> 26) != ALC880_HP_EVENT)
10878 return;
10879 alc262_hippo_automute(codec);
10880}
10881
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010882static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010883{
10884 struct alc_spec *spec = codec->spec;
10885
10886 spec->autocfg.hp_pins[0] = 0x15;
10887 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010888}
10889
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010890static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010891{
10892 struct alc_spec *spec = codec->spec;
10893
10894 spec->autocfg.hp_pins[0] = 0x1b;
10895 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010896}
10897
10898
Kailang Yang272a5272007-05-14 11:00:38 +020010899static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010900 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010901 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010902 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10903 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10904 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10905 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10906 { } /* end */
10907};
10908
Kailang Yang83c34212007-07-05 11:43:05 +020010909static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010910 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10911 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010912 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10913 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10914 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10915 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10916 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10917 { } /* end */
10918};
Kailang Yang272a5272007-05-14 11:00:38 +020010919
Tony Vroonba340e82009-02-02 19:01:30 +000010920static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10921 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10922 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10923 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10924 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10925 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10926 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10927 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10928 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10929 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10930 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10931 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10932 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10933 { } /* end */
10934};
10935
10936static struct hda_verb alc262_tyan_verbs[] = {
10937 /* Headphone automute */
10938 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10939 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10940 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10941
10942 /* P11 AUX_IN, white 4-pin connector */
10943 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10944 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10945 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10946 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10947
10948 {}
10949};
10950
10951/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010952static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010953{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010954 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010955
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010956 spec->autocfg.hp_pins[0] = 0x1b;
10957 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010958}
10959
Tony Vroonba340e82009-02-02 19:01:30 +000010960
Kailang Yangdf694da2005-12-05 19:42:22 +010010961#define alc262_capture_mixer alc882_capture_mixer
10962#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10963
10964/*
10965 * generic initialization of ADC, input mixers and output mixers
10966 */
10967static struct hda_verb alc262_init_verbs[] = {
10968 /*
10969 * Unmute ADC0-2 and set the default input to mic-in
10970 */
10971 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10972 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10973 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10974 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10975 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10976 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10977
Takashi Iwaicb53c622007-08-10 17:21:45 +020010978 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010979 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010980 * Note: PASD motherboards uses the Line In 2 as the input for
10981 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010982 */
10983 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010984 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10985 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10986 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10987 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10988 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010989
10990 /*
10991 * Set up output mixers (0x0c - 0x0e)
10992 */
10993 /* set vol=0 to output mixers */
10994 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10995 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10996 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10997 /* set up input amps for analog loopback */
10998 /* Amp Indices: DAC = 0, mixer = 1 */
10999 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11000 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11001 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11002 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11003 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11004 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11005
11006 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11007 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11008 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11009 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11010 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11011 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11012
11013 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11014 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11015 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11016 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11017 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011018
Kailang Yangdf694da2005-12-05 19:42:22 +010011019 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11020 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011021
Kailang Yangdf694da2005-12-05 19:42:22 +010011022 /* FIXME: use matrix-type input source selection */
11023 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11024 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11025 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11026 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11027 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11028 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11029 /* Input mixer2 */
11030 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11031 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11032 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11033 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11034 /* Input mixer3 */
11035 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11036 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11037 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011038 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011039
11040 { }
11041};
11042
Kailang Yang4e555fe2008-08-26 13:05:55 +020011043static struct hda_verb alc262_eapd_verbs[] = {
11044 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11045 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11046 { }
11047};
11048
Kailang Yangccc656c2006-10-17 12:32:26 +020011049static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11050 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11051 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11052 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11053
11054 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11055 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11056 {}
11057};
11058
Kailang Yang272a5272007-05-14 11:00:38 +020011059static struct hda_verb alc262_sony_unsol_verbs[] = {
11060 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11061 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11062 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11063
11064 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11065 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011066 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011067};
11068
Kailang Yang4e555fe2008-08-26 13:05:55 +020011069static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11070 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11071 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11072 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11073 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11074 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011075 { } /* end */
11076};
11077
11078static struct hda_verb alc262_toshiba_s06_verbs[] = {
11079 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11080 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11081 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11082 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11083 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11084 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11085 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11086 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11087 {}
11088};
11089
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011090static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011091{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011092 struct alc_spec *spec = codec->spec;
11093
11094 spec->autocfg.hp_pins[0] = 0x15;
11095 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011096 spec->ext_mic.pin = 0x18;
11097 spec->ext_mic.mux_idx = 0;
11098 spec->int_mic.pin = 0x12;
11099 spec->int_mic.mux_idx = 9;
11100 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011101}
11102
Takashi Iwai834be882006-03-01 14:16:17 +010011103/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011104 * nec model
11105 * 0x15 = headphone
11106 * 0x16 = internal speaker
11107 * 0x18 = external mic
11108 */
11109
11110static struct snd_kcontrol_new alc262_nec_mixer[] = {
11111 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11112 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11113
11114 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11115 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11116 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11117
11118 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11119 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11120 { } /* end */
11121};
11122
11123static struct hda_verb alc262_nec_verbs[] = {
11124 /* Unmute Speaker */
11125 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11126
11127 /* Headphone */
11128 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11129 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11130
11131 /* External mic to headphone */
11132 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11133 /* External mic to speaker */
11134 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11135 {}
11136};
11137
11138/*
Takashi Iwai834be882006-03-01 14:16:17 +010011139 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011140 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11141 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011142 */
11143
11144#define ALC_HP_EVENT 0x37
11145
11146static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11147 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11148 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011149 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11150 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011151 {}
11152};
11153
Jiang zhe0e31daf2008-03-20 12:12:39 +010011154static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11155 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11156 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11157 {}
11158};
11159
Daniel T Chene2595322009-12-19 18:19:02 -050011160static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11161 /* Front Mic pin: input vref at 50% */
11162 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11163 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11164 {}
11165};
11166
Takashi Iwai834be882006-03-01 14:16:17 +010011167static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011168 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011169 .items = {
11170 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011171 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011172 { "CD", 0x4 },
11173 },
11174};
11175
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011176static struct hda_input_mux alc262_HP_capture_source = {
11177 .num_items = 5,
11178 .items = {
11179 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011180 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011181 { "Line", 0x2 },
11182 { "CD", 0x4 },
11183 { "AUX IN", 0x6 },
11184 },
11185};
11186
zhejiangaccbe492007-08-31 12:36:05 +020011187static struct hda_input_mux alc262_HP_D7000_capture_source = {
11188 .num_items = 4,
11189 .items = {
11190 { "Mic", 0x0 },
11191 { "Front Mic", 0x2 },
11192 { "Line", 0x1 },
11193 { "CD", 0x4 },
11194 },
11195};
11196
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011197/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011198static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11199{
11200 struct alc_spec *spec = codec->spec;
11201 unsigned int mute;
11202
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011203 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011204 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11205 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011206 spec->sense_updated = 1;
11207 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011208 /* unmute internal speaker only if both HPs are unplugged and
11209 * master switch is on
11210 */
11211 if (spec->jack_present)
11212 mute = HDA_AMP_MUTE;
11213 else
Takashi Iwai834be882006-03-01 14:16:17 +010011214 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011215 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11216 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011217}
11218
11219/* unsolicited event for HP jack sensing */
11220static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11221 unsigned int res)
11222{
11223 if ((res >> 26) != ALC_HP_EVENT)
11224 return;
11225 alc262_fujitsu_automute(codec, 1);
11226}
11227
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011228static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11229{
11230 alc262_fujitsu_automute(codec, 1);
11231}
11232
Takashi Iwai834be882006-03-01 14:16:17 +010011233/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011234static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11235 .ops = &snd_hda_bind_vol,
11236 .values = {
11237 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11238 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11239 0
11240 },
11241};
Takashi Iwai834be882006-03-01 14:16:17 +010011242
Jiang zhe0e31daf2008-03-20 12:12:39 +010011243/* mute/unmute internal speaker according to the hp jack and mute state */
11244static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11245{
11246 struct alc_spec *spec = codec->spec;
11247 unsigned int mute;
11248
11249 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011250 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011251 spec->sense_updated = 1;
11252 }
11253 if (spec->jack_present) {
11254 /* mute internal speaker */
11255 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11256 HDA_AMP_MUTE, HDA_AMP_MUTE);
11257 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11258 HDA_AMP_MUTE, HDA_AMP_MUTE);
11259 } else {
11260 /* unmute internal speaker if necessary */
11261 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11262 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11263 HDA_AMP_MUTE, mute);
11264 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11265 HDA_AMP_MUTE, mute);
11266 }
11267}
11268
11269/* unsolicited event for HP jack sensing */
11270static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11271 unsigned int res)
11272{
11273 if ((res >> 26) != ALC_HP_EVENT)
11274 return;
11275 alc262_lenovo_3000_automute(codec, 1);
11276}
11277
Takashi Iwai8de56b72009-07-24 16:51:47 +020011278static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11279 int dir, int idx, long *valp)
11280{
11281 int i, change = 0;
11282
11283 for (i = 0; i < 2; i++, valp++)
11284 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11285 HDA_AMP_MUTE,
11286 *valp ? 0 : HDA_AMP_MUTE);
11287 return change;
11288}
11289
Takashi Iwai834be882006-03-01 14:16:17 +010011290/* bind hp and internal speaker mute (with plug check) */
11291static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11292 struct snd_ctl_elem_value *ucontrol)
11293{
11294 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11295 long *valp = ucontrol->value.integer.value;
11296 int change;
11297
Takashi Iwai8de56b72009-07-24 16:51:47 +020011298 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11299 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011300 if (change)
11301 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011302 return change;
11303}
11304
11305static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011306 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011307 {
11308 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11309 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011310 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011311 .info = snd_hda_mixer_amp_switch_info,
11312 .get = snd_hda_mixer_amp_switch_get,
11313 .put = alc262_fujitsu_master_sw_put,
11314 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11315 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011316 {
11317 .iface = NID_MAPPING,
11318 .name = "Master Playback Switch",
11319 .private_value = 0x1b,
11320 },
Takashi Iwai834be882006-03-01 14:16:17 +010011321 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),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011326 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),
Takashi Iwai834be882006-03-01 14:16:17 +010011329 { } /* end */
11330};
11331
Jiang zhe0e31daf2008-03-20 12:12:39 +010011332/* bind hp and internal speaker mute (with plug check) */
11333static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11334 struct snd_ctl_elem_value *ucontrol)
11335{
11336 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11337 long *valp = ucontrol->value.integer.value;
11338 int change;
11339
Takashi Iwai8de56b72009-07-24 16:51:47 +020011340 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011341 if (change)
11342 alc262_lenovo_3000_automute(codec, 0);
11343 return change;
11344}
11345
11346static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11347 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11348 {
11349 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11350 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011351 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011352 .info = snd_hda_mixer_amp_switch_info,
11353 .get = snd_hda_mixer_amp_switch_get,
11354 .put = alc262_lenovo_3000_master_sw_put,
11355 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11356 },
11357 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11358 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11359 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11360 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11361 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11362 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11363 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11364 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11365 { } /* end */
11366};
11367
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011368static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11369 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011370 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011371 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11372 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11373 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11374 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11375 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11376 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11377 { } /* end */
11378};
11379
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011380/* additional init verbs for Benq laptops */
11381static struct hda_verb alc262_EAPD_verbs[] = {
11382 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11383 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11384 {}
11385};
11386
Kailang Yang83c34212007-07-05 11:43:05 +020011387static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11388 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11389 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11390
11391 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11392 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11393 {}
11394};
11395
Tobin Davisf651b502007-10-26 12:40:47 +020011396/* Samsung Q1 Ultra Vista model setup */
11397static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011398 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11399 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011400 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11401 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11402 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011403 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011404 { } /* end */
11405};
11406
11407static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011408 /* output mixer */
11409 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11410 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11411 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11412 /* speaker */
11413 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11414 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11415 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11416 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11417 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011418 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011419 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11420 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11421 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11422 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11423 /* internal mic */
11424 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11425 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11426 /* ADC, choose mic */
11427 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11428 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11429 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11430 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11431 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11432 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11433 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11434 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11435 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11436 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011437 {}
11438};
11439
Tobin Davisf651b502007-10-26 12:40:47 +020011440/* mute/unmute internal speaker according to the hp jack and mute state */
11441static void alc262_ultra_automute(struct hda_codec *codec)
11442{
11443 struct alc_spec *spec = codec->spec;
11444 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011445
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011446 mute = 0;
11447 /* auto-mute only when HP is used as HP */
11448 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011449 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011450 if (spec->jack_present)
11451 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011452 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011453 /* mute/unmute internal speaker */
11454 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11455 HDA_AMP_MUTE, mute);
11456 /* mute/unmute HP */
11457 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11458 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011459}
11460
11461/* unsolicited event for HP jack sensing */
11462static void alc262_ultra_unsol_event(struct hda_codec *codec,
11463 unsigned int res)
11464{
11465 if ((res >> 26) != ALC880_HP_EVENT)
11466 return;
11467 alc262_ultra_automute(codec);
11468}
11469
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011470static struct hda_input_mux alc262_ultra_capture_source = {
11471 .num_items = 2,
11472 .items = {
11473 { "Mic", 0x1 },
11474 { "Headphone", 0x7 },
11475 },
11476};
11477
11478static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11479 struct snd_ctl_elem_value *ucontrol)
11480{
11481 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11482 struct alc_spec *spec = codec->spec;
11483 int ret;
11484
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011485 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011486 if (!ret)
11487 return 0;
11488 /* reprogram the HP pin as mic or HP according to the input source */
11489 snd_hda_codec_write_cache(codec, 0x15, 0,
11490 AC_VERB_SET_PIN_WIDGET_CONTROL,
11491 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11492 alc262_ultra_automute(codec); /* mute/unmute HP */
11493 return ret;
11494}
11495
11496static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11497 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11498 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11499 {
11500 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11501 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011502 .info = alc_mux_enum_info,
11503 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011504 .put = alc262_ultra_mux_enum_put,
11505 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011506 {
11507 .iface = NID_MAPPING,
11508 .name = "Capture Source",
11509 .private_value = 0x15,
11510 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011511 { } /* end */
11512};
11513
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011514/* We use two mixers depending on the output pin; 0x16 is a mono output
11515 * and thus it's bound with a different mixer.
11516 * This function returns which mixer amp should be used.
11517 */
11518static int alc262_check_volbit(hda_nid_t nid)
11519{
11520 if (!nid)
11521 return 0;
11522 else if (nid == 0x16)
11523 return 2;
11524 else
11525 return 1;
11526}
11527
11528static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11529 const char *pfx, int *vbits)
11530{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011531 unsigned long val;
11532 int vbit;
11533
11534 vbit = alc262_check_volbit(nid);
11535 if (!vbit)
11536 return 0;
11537 if (*vbits & vbit) /* a volume control for this mixer already there */
11538 return 0;
11539 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011540 if (vbit == 2)
11541 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11542 else
11543 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011544 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011545}
11546
11547static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11548 const char *pfx)
11549{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011550 unsigned long val;
11551
11552 if (!nid)
11553 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011554 if (nid == 0x16)
11555 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11556 else
11557 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011558 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011559}
11560
Kailang Yangdf694da2005-12-05 19:42:22 +010011561/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011562static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11563 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011564{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011565 const char *pfx;
11566 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011567 int err;
11568
11569 spec->multiout.num_dacs = 1; /* only use one dac */
11570 spec->multiout.dac_nids = spec->private_dac_nids;
11571 spec->multiout.dac_nids[0] = 2;
11572
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011573 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11574 pfx = "Master";
11575 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11576 pfx = "Speaker";
11577 else
11578 pfx = "Front";
11579 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11580 if (err < 0)
11581 return err;
11582 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11583 if (err < 0)
11584 return err;
11585 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11586 if (err < 0)
11587 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011588
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011589 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11590 alc262_check_volbit(cfg->speaker_pins[0]) |
11591 alc262_check_volbit(cfg->hp_pins[0]);
11592 if (vbits == 1 || vbits == 2)
11593 pfx = "Master"; /* only one mixer is used */
11594 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11595 pfx = "Speaker";
11596 else
11597 pfx = "Front";
11598 vbits = 0;
11599 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11600 if (err < 0)
11601 return err;
11602 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11603 &vbits);
11604 if (err < 0)
11605 return err;
11606 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11607 &vbits);
11608 if (err < 0)
11609 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011610 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011611}
11612
Takashi Iwai05f5f472009-08-25 13:10:18 +020011613#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011614 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011615
11616/*
11617 * generic initialization of ADC, input mixers and output mixers
11618 */
11619static struct hda_verb alc262_volume_init_verbs[] = {
11620 /*
11621 * Unmute ADC0-2 and set the default input to mic-in
11622 */
11623 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11624 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11625 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11626 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11627 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11628 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11629
Takashi Iwaicb53c622007-08-10 17:21:45 +020011630 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011631 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011632 * Note: PASD motherboards uses the Line In 2 as the input for
11633 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011634 */
11635 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011636 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11637 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11638 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011641
11642 /*
11643 * Set up output mixers (0x0c - 0x0f)
11644 */
11645 /* set vol=0 to output mixers */
11646 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11647 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11648 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011649
Kailang Yangdf694da2005-12-05 19:42:22 +010011650 /* set up input amps for analog loopback */
11651 /* Amp Indices: DAC = 0, mixer = 1 */
11652 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11653 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11654 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11655 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11656 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11657 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11658
11659 /* FIXME: use matrix-type input source selection */
11660 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11661 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11662 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11663 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11664 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11665 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11666 /* Input mixer2 */
11667 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11668 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11669 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11670 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11671 /* Input mixer3 */
11672 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11673 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11674 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11675 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11676
11677 { }
11678};
11679
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011680static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11681 /*
11682 * Unmute ADC0-2 and set the default input to mic-in
11683 */
11684 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11685 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11686 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11687 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11688 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11689 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11690
Takashi Iwaicb53c622007-08-10 17:21:45 +020011691 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011692 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011693 * Note: PASD motherboards uses the Line In 2 as the input for
11694 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011695 */
11696 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011697 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11698 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11699 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11700 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11701 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11702 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11703 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011704
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011705 /*
11706 * Set up output mixers (0x0c - 0x0e)
11707 */
11708 /* set vol=0 to output mixers */
11709 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11710 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11711 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11712
11713 /* set up input amps for analog loopback */
11714 /* Amp Indices: DAC = 0, mixer = 1 */
11715 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11716 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11717 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11718 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11719 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11720 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11721
Takashi Iwaice875f02008-01-28 18:17:43 +010011722 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011723 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11724 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11725
11726 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11727 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11728
11729 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11730 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11731
11732 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11733 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11734 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11735 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11736 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11737
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011738 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011739 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11740 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011741 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011742 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11743 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11744
11745
11746 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011747 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11748 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011749 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011750 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11751 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11752 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11753 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11754 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11755 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11756 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11757 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011758 /* Input mixer2 */
11759 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011760 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11761 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11762 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11763 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11764 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11765 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11766 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11767 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011768 /* Input mixer3 */
11769 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011770 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11771 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11772 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11773 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11774 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11775 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11776 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011778
Takashi Iwaice875f02008-01-28 18:17:43 +010011779 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11780
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011781 { }
11782};
11783
Kailang Yangcd7509a2007-01-26 18:33:17 +010011784static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11785 /*
11786 * Unmute ADC0-2 and set the default input to mic-in
11787 */
11788 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11789 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11790 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11791 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11792 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11793 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11794
Takashi Iwaicb53c622007-08-10 17:21:45 +020011795 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011796 * mixer widget
11797 * Note: PASD motherboards uses the Line In 2 as the input for front
11798 * panel mic (mic 2)
11799 */
11800 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011801 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11802 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11803 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11804 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11805 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11806 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11807 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11808 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011809 /*
11810 * Set up output mixers (0x0c - 0x0e)
11811 */
11812 /* set vol=0 to output mixers */
11813 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11814 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11815 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11816
11817 /* set up input amps for analog loopback */
11818 /* Amp Indices: DAC = 0, mixer = 1 */
11819 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11820 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11821 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11822 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11823 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11824 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11825
11826
11827 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11828 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11829 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11830 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11831 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11832 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11833 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11834
11835 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11836 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11837
11838 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11839 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11840
11841 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11842 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11843 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11844 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11845 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11846 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11847
11848 /* FIXME: use matrix-type input source selection */
11849 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11850 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11851 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11852 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11853 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11854 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11855 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11856 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11857 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11858 /* Input mixer2 */
11859 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11860 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11861 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11862 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11863 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11864 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11865 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11866 /* Input mixer3 */
11867 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11868 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11869 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11870 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11871 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11872 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11873 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11874
Takashi Iwaice875f02008-01-28 18:17:43 +010011875 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11876
Kailang Yangcd7509a2007-01-26 18:33:17 +010011877 { }
11878};
11879
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011880static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11881
11882 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11883 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11884 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11885
11886 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11887 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11888 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11889 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11890
11891 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11892 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11893 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11894 {}
11895};
11896
11897
Takashi Iwaicb53c622007-08-10 17:21:45 +020011898#ifdef CONFIG_SND_HDA_POWER_SAVE
11899#define alc262_loopbacks alc880_loopbacks
11900#endif
11901
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011902/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011903#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11904#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11905#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11906#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11907
11908/*
11909 * BIOS auto configuration
11910 */
11911static int alc262_parse_auto_config(struct hda_codec *codec)
11912{
11913 struct alc_spec *spec = codec->spec;
11914 int err;
11915 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11916
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011917 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11918 alc262_ignore);
11919 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011920 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011921 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011922 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011923 spec->multiout.max_channels = 2;
11924 spec->no_analog = 1;
11925 goto dig_only;
11926 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011927 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011928 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011929 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11930 if (err < 0)
11931 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011932 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011933 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011934 return err;
11935
11936 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11937
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011938 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011939 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011940 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011941 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011942 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011943 if (spec->autocfg.dig_in_pin)
11944 spec->dig_in_nid = ALC262_DIGIN_NID;
11945
Takashi Iwai603c4012008-07-30 15:01:44 +020011946 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011947 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011948
Takashi Iwaid88897e2008-10-31 15:01:37 +010011949 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011950 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011951 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011952
Takashi Iwai776e1842007-08-29 15:07:11 +020011953 err = alc_auto_add_mic_boost(codec);
11954 if (err < 0)
11955 return err;
11956
Kailang Yang6227cdc2010-02-25 08:36:52 +010011957 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011958
Kailang Yangdf694da2005-12-05 19:42:22 +010011959 return 1;
11960}
11961
11962#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11963#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11964#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011965#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011966
11967
11968/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011969static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011970{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011971 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011972 alc262_auto_init_multi_out(codec);
11973 alc262_auto_init_hp_out(codec);
11974 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011975 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011976 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011977 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011978}
11979
11980/*
11981 * configuration and preset
11982 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011983static const char *alc262_models[ALC262_MODEL_LAST] = {
11984 [ALC262_BASIC] = "basic",
11985 [ALC262_HIPPO] = "hippo",
11986 [ALC262_HIPPO_1] = "hippo_1",
11987 [ALC262_FUJITSU] = "fujitsu",
11988 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011989 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011990 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011991 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011992 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011993 [ALC262_BENQ_T31] = "benq-t31",
11994 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011995 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011996 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011997 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011998 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011999 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012000 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012001 [ALC262_AUTO] = "auto",
12002};
12003
12004static struct snd_pci_quirk alc262_cfg_tbl[] = {
12005 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012006 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012007 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12008 ALC262_HP_BPC),
12009 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12010 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012011 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12012 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012013 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012014 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012015 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012016 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012017 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012018 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012019 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012020 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012021 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12022 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12023 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012024 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12025 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012026 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012027 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012028 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012029 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012030 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012031 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012032 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012033 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012034#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012035 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12036 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012037#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012038 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012039 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012040 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012041 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012042 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012043 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012044 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12045 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012046 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012047 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012048 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012049 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012050 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012051 {}
12052};
12053
12054static struct alc_config_preset alc262_presets[] = {
12055 [ALC262_BASIC] = {
12056 .mixers = { alc262_base_mixer },
12057 .init_verbs = { alc262_init_verbs },
12058 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12059 .dac_nids = alc262_dac_nids,
12060 .hp_nid = 0x03,
12061 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12062 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012063 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012064 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012065 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012066 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012067 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012068 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12069 .dac_nids = alc262_dac_nids,
12070 .hp_nid = 0x03,
12071 .dig_out_nid = ALC262_DIGOUT_NID,
12072 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12073 .channel_mode = alc262_modes,
12074 .input_mux = &alc262_capture_source,
12075 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012076 .setup = alc262_hippo_setup,
12077 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012078 },
12079 [ALC262_HIPPO_1] = {
12080 .mixers = { alc262_hippo1_mixer },
12081 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12082 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12083 .dac_nids = alc262_dac_nids,
12084 .hp_nid = 0x02,
12085 .dig_out_nid = ALC262_DIGOUT_NID,
12086 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12087 .channel_mode = alc262_modes,
12088 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012089 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012090 .setup = alc262_hippo1_setup,
12091 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012092 },
Takashi Iwai834be882006-03-01 14:16:17 +010012093 [ALC262_FUJITSU] = {
12094 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012095 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12096 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012097 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12098 .dac_nids = alc262_dac_nids,
12099 .hp_nid = 0x03,
12100 .dig_out_nid = ALC262_DIGOUT_NID,
12101 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12102 .channel_mode = alc262_modes,
12103 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012104 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012105 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012106 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012107 [ALC262_HP_BPC] = {
12108 .mixers = { alc262_HP_BPC_mixer },
12109 .init_verbs = { alc262_HP_BPC_init_verbs },
12110 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12111 .dac_nids = alc262_dac_nids,
12112 .hp_nid = 0x03,
12113 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12114 .channel_mode = alc262_modes,
12115 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012116 .unsol_event = alc262_hp_bpc_unsol_event,
12117 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012118 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012119 [ALC262_HP_BPC_D7000_WF] = {
12120 .mixers = { alc262_HP_BPC_WildWest_mixer },
12121 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12122 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12123 .dac_nids = alc262_dac_nids,
12124 .hp_nid = 0x03,
12125 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12126 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012127 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012128 .unsol_event = alc262_hp_wildwest_unsol_event,
12129 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012130 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012131 [ALC262_HP_BPC_D7000_WL] = {
12132 .mixers = { alc262_HP_BPC_WildWest_mixer,
12133 alc262_HP_BPC_WildWest_option_mixer },
12134 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12135 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12136 .dac_nids = alc262_dac_nids,
12137 .hp_nid = 0x03,
12138 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12139 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012140 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012141 .unsol_event = alc262_hp_wildwest_unsol_event,
12142 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012143 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012144 [ALC262_HP_TC_T5735] = {
12145 .mixers = { alc262_hp_t5735_mixer },
12146 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12147 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12148 .dac_nids = alc262_dac_nids,
12149 .hp_nid = 0x03,
12150 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12151 .channel_mode = alc262_modes,
12152 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012153 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012154 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012155 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012156 },
12157 [ALC262_HP_RP5700] = {
12158 .mixers = { alc262_hp_rp5700_mixer },
12159 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12160 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12161 .dac_nids = alc262_dac_nids,
12162 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12163 .channel_mode = alc262_modes,
12164 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012165 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012166 [ALC262_BENQ_ED8] = {
12167 .mixers = { alc262_base_mixer },
12168 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12169 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12170 .dac_nids = alc262_dac_nids,
12171 .hp_nid = 0x03,
12172 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12173 .channel_mode = alc262_modes,
12174 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012175 },
Kailang Yang272a5272007-05-14 11:00:38 +020012176 [ALC262_SONY_ASSAMD] = {
12177 .mixers = { alc262_sony_mixer },
12178 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12179 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12180 .dac_nids = alc262_dac_nids,
12181 .hp_nid = 0x02,
12182 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12183 .channel_mode = alc262_modes,
12184 .input_mux = &alc262_capture_source,
12185 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012186 .setup = alc262_hippo_setup,
12187 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012188 },
12189 [ALC262_BENQ_T31] = {
12190 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012191 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12192 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012193 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12194 .dac_nids = alc262_dac_nids,
12195 .hp_nid = 0x03,
12196 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12197 .channel_mode = alc262_modes,
12198 .input_mux = &alc262_capture_source,
12199 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012200 .setup = alc262_hippo_setup,
12201 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012202 },
Tobin Davisf651b502007-10-26 12:40:47 +020012203 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012204 .mixers = { alc262_ultra_mixer },
12205 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012206 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012207 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12208 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012209 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12210 .channel_mode = alc262_modes,
12211 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012212 .adc_nids = alc262_adc_nids, /* ADC0 */
12213 .capsrc_nids = alc262_capsrc_nids,
12214 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012215 .unsol_event = alc262_ultra_unsol_event,
12216 .init_hook = alc262_ultra_automute,
12217 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012218 [ALC262_LENOVO_3000] = {
12219 .mixers = { alc262_lenovo_3000_mixer },
12220 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012221 alc262_lenovo_3000_unsol_verbs,
12222 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012223 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12224 .dac_nids = alc262_dac_nids,
12225 .hp_nid = 0x03,
12226 .dig_out_nid = ALC262_DIGOUT_NID,
12227 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12228 .channel_mode = alc262_modes,
12229 .input_mux = &alc262_fujitsu_capture_source,
12230 .unsol_event = alc262_lenovo_3000_unsol_event,
12231 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012232 [ALC262_NEC] = {
12233 .mixers = { alc262_nec_mixer },
12234 .init_verbs = { alc262_nec_verbs },
12235 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12236 .dac_nids = alc262_dac_nids,
12237 .hp_nid = 0x03,
12238 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12239 .channel_mode = alc262_modes,
12240 .input_mux = &alc262_capture_source,
12241 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012242 [ALC262_TOSHIBA_S06] = {
12243 .mixers = { alc262_toshiba_s06_mixer },
12244 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12245 alc262_eapd_verbs },
12246 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12247 .capsrc_nids = alc262_dmic_capsrc_nids,
12248 .dac_nids = alc262_dac_nids,
12249 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012250 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012251 .dig_out_nid = ALC262_DIGOUT_NID,
12252 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12253 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012254 .unsol_event = alc_sku_unsol_event,
12255 .setup = alc262_toshiba_s06_setup,
12256 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012257 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012258 [ALC262_TOSHIBA_RX1] = {
12259 .mixers = { alc262_toshiba_rx1_mixer },
12260 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12261 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12262 .dac_nids = alc262_dac_nids,
12263 .hp_nid = 0x03,
12264 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12265 .channel_mode = alc262_modes,
12266 .input_mux = &alc262_capture_source,
12267 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012268 .setup = alc262_hippo_setup,
12269 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012270 },
Tony Vroonba340e82009-02-02 19:01:30 +000012271 [ALC262_TYAN] = {
12272 .mixers = { alc262_tyan_mixer },
12273 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12274 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12275 .dac_nids = alc262_dac_nids,
12276 .hp_nid = 0x02,
12277 .dig_out_nid = ALC262_DIGOUT_NID,
12278 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12279 .channel_mode = alc262_modes,
12280 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012281 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012282 .setup = alc262_tyan_setup,
12283 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012284 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012285};
12286
12287static int patch_alc262(struct hda_codec *codec)
12288{
12289 struct alc_spec *spec;
12290 int board_config;
12291 int err;
12292
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012293 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012294 if (spec == NULL)
12295 return -ENOMEM;
12296
12297 codec->spec = spec;
12298#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012299 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12300 * under-run
12301 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012302 {
12303 int tmp;
12304 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12305 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12306 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12307 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12308 }
12309#endif
12310
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012311 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12312
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012313 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12314 alc262_models,
12315 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012316
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012317 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012318 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12319 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012320 board_config = ALC262_AUTO;
12321 }
12322
12323 if (board_config == ALC262_AUTO) {
12324 /* automatic parse from the BIOS config */
12325 err = alc262_parse_auto_config(codec);
12326 if (err < 0) {
12327 alc_free(codec);
12328 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012329 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012330 printk(KERN_INFO
12331 "hda_codec: Cannot set up configuration "
12332 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012333 board_config = ALC262_BASIC;
12334 }
12335 }
12336
Takashi Iwai07eba612009-02-19 08:06:35 +010012337 if (!spec->no_analog) {
12338 err = snd_hda_attach_beep_device(codec, 0x1);
12339 if (err < 0) {
12340 alc_free(codec);
12341 return err;
12342 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012343 }
12344
Kailang Yangdf694da2005-12-05 19:42:22 +010012345 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012346 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012347
Kailang Yangdf694da2005-12-05 19:42:22 +010012348 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12349 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012350
Kailang Yangdf694da2005-12-05 19:42:22 +010012351 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12352 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12353
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012354 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012355 int i;
12356 /* check whether the digital-mic has to be supported */
12357 for (i = 0; i < spec->input_mux->num_items; i++) {
12358 if (spec->input_mux->items[i].index >= 9)
12359 break;
12360 }
12361 if (i < spec->input_mux->num_items) {
12362 /* use only ADC0 */
12363 spec->adc_nids = alc262_dmic_adc_nids;
12364 spec->num_adc_nids = 1;
12365 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012366 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012367 /* all analog inputs */
12368 /* check whether NID 0x07 is valid */
12369 unsigned int wcap = get_wcaps(codec, 0x07);
12370
12371 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012372 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012373 if (wcap != AC_WID_AUD_IN) {
12374 spec->adc_nids = alc262_adc_nids_alt;
12375 spec->num_adc_nids =
12376 ARRAY_SIZE(alc262_adc_nids_alt);
12377 spec->capsrc_nids = alc262_capsrc_nids_alt;
12378 } else {
12379 spec->adc_nids = alc262_adc_nids;
12380 spec->num_adc_nids =
12381 ARRAY_SIZE(alc262_adc_nids);
12382 spec->capsrc_nids = alc262_capsrc_nids;
12383 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012384 }
12385 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012386 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012387 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010012388 if (!spec->no_analog)
12389 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012390
Takashi Iwai2134ea42008-01-10 16:53:55 +010012391 spec->vmaster_nid = 0x0c;
12392
Kailang Yangdf694da2005-12-05 19:42:22 +010012393 codec->patch_ops = alc_patch_ops;
12394 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012395 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012396#ifdef CONFIG_SND_HDA_POWER_SAVE
12397 if (!spec->loopback.amplist)
12398 spec->loopback.amplist = alc262_loopbacks;
12399#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012400
Kailang Yangdf694da2005-12-05 19:42:22 +010012401 return 0;
12402}
12403
Kailang Yangdf694da2005-12-05 19:42:22 +010012404/*
Kailang Yanga361d842007-06-05 12:30:55 +020012405 * ALC268 channel source setting (2 channel)
12406 */
12407#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12408#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012409
Kailang Yanga361d842007-06-05 12:30:55 +020012410static hda_nid_t alc268_dac_nids[2] = {
12411 /* front, hp */
12412 0x02, 0x03
12413};
12414
12415static hda_nid_t alc268_adc_nids[2] = {
12416 /* ADC0-1 */
12417 0x08, 0x07
12418};
12419
12420static hda_nid_t alc268_adc_nids_alt[1] = {
12421 /* ADC0 */
12422 0x08
12423};
12424
Takashi Iwaie1406342008-02-11 18:32:32 +010012425static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12426
Kailang Yanga361d842007-06-05 12:30:55 +020012427static struct snd_kcontrol_new alc268_base_mixer[] = {
12428 /* output mixer control */
12429 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12430 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12431 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12432 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012433 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12434 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12435 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012436 { }
12437};
12438
Takashi Iwai42171c12009-05-08 14:11:43 +020012439static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12440 /* output mixer control */
12441 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12442 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12443 ALC262_HIPPO_MASTER_SWITCH,
12444 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12445 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12446 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12447 { }
12448};
12449
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012450/* bind Beep switches of both NID 0x0f and 0x10 */
12451static struct hda_bind_ctls alc268_bind_beep_sw = {
12452 .ops = &snd_hda_bind_sw,
12453 .values = {
12454 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12455 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12456 0
12457 },
12458};
12459
12460static struct snd_kcontrol_new alc268_beep_mixer[] = {
12461 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12462 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12463 { }
12464};
12465
Kailang Yangd1a991a2007-08-15 16:21:59 +020012466static struct hda_verb alc268_eapd_verbs[] = {
12467 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12468 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12469 { }
12470};
12471
Takashi Iwaid2738092007-08-16 14:59:45 +020012472/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012473static struct hda_verb alc268_toshiba_verbs[] = {
12474 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12475 { } /* end */
12476};
12477
12478/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012479/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012480static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12481 .ops = &snd_hda_bind_vol,
12482 .values = {
12483 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12484 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12485 0
12486 },
12487};
12488
Takashi Iwai889c4392007-08-23 18:56:52 +020012489/* mute/unmute internal speaker according to the hp jack and mute state */
12490static void alc268_acer_automute(struct hda_codec *codec, int force)
12491{
12492 struct alc_spec *spec = codec->spec;
12493 unsigned int mute;
12494
12495 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012496 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012497 spec->sense_updated = 1;
12498 }
12499 if (spec->jack_present)
12500 mute = HDA_AMP_MUTE; /* mute internal speaker */
12501 else /* unmute internal speaker if necessary */
12502 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12503 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12504 HDA_AMP_MUTE, mute);
12505}
12506
12507
12508/* bind hp and internal speaker mute (with plug check) */
12509static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12510 struct snd_ctl_elem_value *ucontrol)
12511{
12512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12513 long *valp = ucontrol->value.integer.value;
12514 int change;
12515
Takashi Iwai8de56b72009-07-24 16:51:47 +020012516 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012517 if (change)
12518 alc268_acer_automute(codec, 0);
12519 return change;
12520}
Takashi Iwaid2738092007-08-16 14:59:45 +020012521
Kailang Yang8ef355d2008-08-26 13:10:22 +020012522static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12523 /* output mixer control */
12524 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12525 {
12526 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12527 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012528 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012529 .info = snd_hda_mixer_amp_switch_info,
12530 .get = snd_hda_mixer_amp_switch_get,
12531 .put = alc268_acer_master_sw_put,
12532 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12533 },
12534 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12535 { }
12536};
12537
Takashi Iwaid2738092007-08-16 14:59:45 +020012538static struct snd_kcontrol_new alc268_acer_mixer[] = {
12539 /* output mixer control */
12540 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12541 {
12542 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12543 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012544 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012545 .info = snd_hda_mixer_amp_switch_info,
12546 .get = snd_hda_mixer_amp_switch_get,
12547 .put = alc268_acer_master_sw_put,
12548 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12549 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012550 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12551 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12552 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012553 { }
12554};
12555
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012556static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12557 /* output mixer control */
12558 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12559 {
12560 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12561 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012562 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012563 .info = snd_hda_mixer_amp_switch_info,
12564 .get = snd_hda_mixer_amp_switch_get,
12565 .put = alc268_acer_master_sw_put,
12566 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12567 },
12568 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12569 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12570 { }
12571};
12572
Kailang Yang8ef355d2008-08-26 13:10:22 +020012573static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12574 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12575 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12576 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12577 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12578 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12579 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12580 { }
12581};
12582
Takashi Iwaid2738092007-08-16 14:59:45 +020012583static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012584 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12585 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012586 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12587 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012588 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12589 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012590 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12591 { }
12592};
12593
12594/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012595#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012596#define alc268_toshiba_setup alc262_hippo_setup
12597#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012598
12599static void alc268_acer_unsol_event(struct hda_codec *codec,
12600 unsigned int res)
12601{
Takashi Iwai889c4392007-08-23 18:56:52 +020012602 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012603 return;
12604 alc268_acer_automute(codec, 1);
12605}
12606
Takashi Iwai889c4392007-08-23 18:56:52 +020012607static void alc268_acer_init_hook(struct hda_codec *codec)
12608{
12609 alc268_acer_automute(codec, 1);
12610}
12611
Kailang Yang8ef355d2008-08-26 13:10:22 +020012612/* toggle speaker-output according to the hp-jack state */
12613static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12614{
12615 unsigned int present;
12616 unsigned char bits;
12617
Wu Fengguang864f92b2009-11-18 12:38:02 +080012618 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012619 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012620 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012621 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012622 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012623 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012624}
12625
Kailang Yang8ef355d2008-08-26 13:10:22 +020012626static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12627 unsigned int res)
12628{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012629 switch (res >> 26) {
12630 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012631 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012632 break;
12633 case ALC880_MIC_EVENT:
12634 alc_mic_automute(codec);
12635 break;
12636 }
12637}
12638
12639static void alc268_acer_lc_setup(struct hda_codec *codec)
12640{
12641 struct alc_spec *spec = codec->spec;
12642 spec->ext_mic.pin = 0x18;
12643 spec->ext_mic.mux_idx = 0;
12644 spec->int_mic.pin = 0x12;
12645 spec->int_mic.mux_idx = 6;
12646 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012647}
12648
12649static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12650{
12651 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012652 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012653}
12654
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012655static struct snd_kcontrol_new alc268_dell_mixer[] = {
12656 /* output mixer control */
12657 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12658 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12659 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12660 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12661 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12662 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12663 { }
12664};
12665
12666static struct hda_verb alc268_dell_verbs[] = {
12667 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12668 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12669 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012670 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012671 { }
12672};
12673
12674/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012675static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012676{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012677 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012678
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012679 spec->autocfg.hp_pins[0] = 0x15;
12680 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012681 spec->ext_mic.pin = 0x18;
12682 spec->ext_mic.mux_idx = 0;
12683 spec->int_mic.pin = 0x19;
12684 spec->int_mic.mux_idx = 1;
12685 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012686}
12687
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012688static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12689 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12690 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12691 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12692 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12693 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12694 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12695 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12696 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12697 { }
12698};
12699
12700static struct hda_verb alc267_quanta_il1_verbs[] = {
12701 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12702 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12703 { }
12704};
12705
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012706static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012707{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012708 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012709 spec->autocfg.hp_pins[0] = 0x15;
12710 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012711 spec->ext_mic.pin = 0x18;
12712 spec->ext_mic.mux_idx = 0;
12713 spec->int_mic.pin = 0x19;
12714 spec->int_mic.mux_idx = 1;
12715 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012716}
12717
Kailang Yanga361d842007-06-05 12:30:55 +020012718/*
12719 * generic initialization of ADC, input mixers and output mixers
12720 */
12721static struct hda_verb alc268_base_init_verbs[] = {
12722 /* Unmute DAC0-1 and set vol = 0 */
12723 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012724 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012725
12726 /*
12727 * Set up output mixers (0x0c - 0x0e)
12728 */
12729 /* set vol=0 to output mixers */
12730 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012731 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12732
12733 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12734 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12735
12736 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12737 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12738 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12739 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12740 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12741 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12742 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12743 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12744
12745 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12746 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12747 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
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},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012750
12751 /* 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
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012756 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012757
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012758 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12759 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12760 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12761 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012762
Kailang Yanga361d842007-06-05 12:30:55 +020012763 { }
12764};
12765
12766/*
12767 * generic initialization of ADC, input mixers and output mixers
12768 */
12769static struct hda_verb alc268_volume_init_verbs[] = {
12770 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012771 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12772 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012773
12774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12775 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12776 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12777 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12778 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12779
Kailang Yanga361d842007-06-05 12:30:55 +020012780 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012781 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12782 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12783
12784 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012785 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012786
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012787 /* set PCBEEP vol = 0, mute connections */
12788 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12789 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12790 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012791
12792 { }
12793};
12794
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012795static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12796 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12797 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12798 { } /* end */
12799};
12800
Kailang Yanga361d842007-06-05 12:30:55 +020012801static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12802 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12803 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012804 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012805 { } /* end */
12806};
12807
12808static struct snd_kcontrol_new alc268_capture_mixer[] = {
12809 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12810 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12811 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12812 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012813 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012814 { } /* end */
12815};
12816
12817static struct hda_input_mux alc268_capture_source = {
12818 .num_items = 4,
12819 .items = {
12820 { "Mic", 0x0 },
12821 { "Front Mic", 0x1 },
12822 { "Line", 0x2 },
12823 { "CD", 0x3 },
12824 },
12825};
12826
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012827static struct hda_input_mux alc268_acer_capture_source = {
12828 .num_items = 3,
12829 .items = {
12830 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012831 { "Internal Mic", 0x1 },
12832 { "Line", 0x2 },
12833 },
12834};
12835
12836static struct hda_input_mux alc268_acer_dmic_capture_source = {
12837 .num_items = 3,
12838 .items = {
12839 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012840 { "Internal Mic", 0x6 },
12841 { "Line", 0x2 },
12842 },
12843};
12844
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012845#ifdef CONFIG_SND_DEBUG
12846static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012847 /* Volume widgets */
12848 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12849 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12850 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12851 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12852 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12853 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12854 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12855 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12856 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12857 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12858 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12859 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12860 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012861 /* The below appears problematic on some hardwares */
12862 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012863 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12864 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12865 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12866 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12867
12868 /* Modes for retasking pin widgets */
12869 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12870 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12871 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12872 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12873
12874 /* Controls for GPIO pins, assuming they are configured as outputs */
12875 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12876 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12877 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12878 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12879
12880 /* Switches to allow the digital SPDIF output pin to be enabled.
12881 * The ALC268 does not have an SPDIF input.
12882 */
12883 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12884
12885 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12886 * this output to turn on an external amplifier.
12887 */
12888 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12889 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12890
12891 { } /* end */
12892};
12893#endif
12894
Kailang Yanga361d842007-06-05 12:30:55 +020012895/* create input playback/capture controls for the given pin */
12896static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12897 const char *ctlname, int idx)
12898{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012899 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012900 int err;
12901
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012902 switch (nid) {
12903 case 0x14:
12904 case 0x16:
12905 dac = 0x02;
12906 break;
12907 case 0x15:
Kailang Yang531d8792010-04-09 10:57:33 +020012908 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012909 dac = 0x03;
12910 break;
12911 default:
12912 return 0;
12913 }
12914 if (spec->multiout.dac_nids[0] != dac &&
12915 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012916 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012917 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012918 HDA_OUTPUT));
12919 if (err < 0)
12920 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012921 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12922 }
12923
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012924 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012925 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020012926 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012927 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012928 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012929 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012930 if (err < 0)
12931 return err;
12932 return 0;
12933}
12934
12935/* add playback controls from the parsed DAC table */
12936static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12937 const struct auto_pin_cfg *cfg)
12938{
12939 hda_nid_t nid;
12940 int err;
12941
Kailang Yanga361d842007-06-05 12:30:55 +020012942 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012943
12944 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012945 if (nid) {
12946 const char *name;
12947 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12948 name = "Speaker";
12949 else
12950 name = "Front";
12951 err = alc268_new_analog_output(spec, nid, name, 0);
12952 if (err < 0)
12953 return err;
12954 }
Kailang Yanga361d842007-06-05 12:30:55 +020012955
12956 nid = cfg->speaker_pins[0];
12957 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012958 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020012959 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12960 if (err < 0)
12961 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012962 } else {
12963 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12964 if (err < 0)
12965 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012966 }
12967 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012968 if (nid) {
12969 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12970 if (err < 0)
12971 return err;
12972 }
Kailang Yanga361d842007-06-05 12:30:55 +020012973
12974 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12975 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012976 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012977 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012978 if (err < 0)
12979 return err;
12980 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012981 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012982}
12983
12984/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012985static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012986 const struct auto_pin_cfg *cfg)
12987{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012988 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012989}
12990
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012991static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12992 hda_nid_t nid, int pin_type)
12993{
12994 int idx;
12995
12996 alc_set_pin_output(codec, nid, pin_type);
12997 if (nid == 0x14 || nid == 0x16)
12998 idx = 0;
12999 else
13000 idx = 1;
13001 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13002}
13003
13004static void alc268_auto_init_multi_out(struct hda_codec *codec)
13005{
13006 struct alc_spec *spec = codec->spec;
13007 hda_nid_t nid = spec->autocfg.line_out_pins[0];
13008 if (nid) {
13009 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13010 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13011 }
13012}
13013
13014static void alc268_auto_init_hp_out(struct hda_codec *codec)
13015{
13016 struct alc_spec *spec = codec->spec;
13017 hda_nid_t pin;
13018
13019 pin = spec->autocfg.hp_pins[0];
13020 if (pin)
13021 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
13022 pin = spec->autocfg.speaker_pins[0];
13023 if (pin)
13024 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
13025}
13026
Kailang Yanga361d842007-06-05 12:30:55 +020013027static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13028{
13029 struct alc_spec *spec = codec->spec;
13030 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13031 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13032 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13033 unsigned int dac_vol1, dac_vol2;
13034
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013035 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013036 snd_hda_codec_write(codec, speaker_nid, 0,
13037 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013038 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013039 snd_hda_codec_write(codec, 0x0f, 0,
13040 AC_VERB_SET_AMP_GAIN_MUTE,
13041 AMP_IN_UNMUTE(1));
13042 snd_hda_codec_write(codec, 0x10, 0,
13043 AC_VERB_SET_AMP_GAIN_MUTE,
13044 AMP_IN_UNMUTE(1));
13045 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013046 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013047 snd_hda_codec_write(codec, 0x0f, 0,
13048 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13049 snd_hda_codec_write(codec, 0x10, 0,
13050 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13051 }
13052
13053 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013054 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013055 dac_vol2 = AMP_OUT_ZERO;
13056 else if (line_nid == 0x15)
13057 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013058 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013059 dac_vol2 = AMP_OUT_ZERO;
13060 else if (hp_nid == 0x15)
13061 dac_vol1 = AMP_OUT_ZERO;
13062 if (line_nid != 0x16 || hp_nid != 0x16 ||
13063 spec->autocfg.line_out_pins[1] != 0x16 ||
13064 spec->autocfg.line_out_pins[2] != 0x16)
13065 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13066
13067 snd_hda_codec_write(codec, 0x02, 0,
13068 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13069 snd_hda_codec_write(codec, 0x03, 0,
13070 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13071}
13072
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013073/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013074#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13075#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013076#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013077#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13078
13079/*
13080 * BIOS auto configuration
13081 */
13082static int alc268_parse_auto_config(struct hda_codec *codec)
13083{
13084 struct alc_spec *spec = codec->spec;
13085 int err;
13086 static hda_nid_t alc268_ignore[] = { 0 };
13087
13088 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13089 alc268_ignore);
13090 if (err < 0)
13091 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013092 if (!spec->autocfg.line_outs) {
13093 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13094 spec->multiout.max_channels = 2;
13095 spec->no_analog = 1;
13096 goto dig_only;
13097 }
Kailang Yanga361d842007-06-05 12:30:55 +020013098 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013099 }
Kailang Yanga361d842007-06-05 12:30:55 +020013100 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13101 if (err < 0)
13102 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013103 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013104 if (err < 0)
13105 return err;
13106
13107 spec->multiout.max_channels = 2;
13108
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013109 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013110 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013111 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020013112 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013113 spec->dig_out_type = spec->autocfg.dig_out_type[0];
13114 }
Takashi Iwai603c4012008-07-30 15:01:44 +020013115 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013116 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013117
Takashi Iwai892981f2009-03-02 08:04:35 +010013118 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013119 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013120
Takashi Iwaid88897e2008-10-31 15:01:37 +010013121 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013122 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013123 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013124
Takashi Iwai776e1842007-08-29 15:07:11 +020013125 err = alc_auto_add_mic_boost(codec);
13126 if (err < 0)
13127 return err;
13128
Kailang Yang6227cdc2010-02-25 08:36:52 +010013129 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013130
Kailang Yanga361d842007-06-05 12:30:55 +020013131 return 1;
13132}
13133
Kailang Yanga361d842007-06-05 12:30:55 +020013134#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13135
13136/* init callback for auto-configuration model -- overriding the default init */
13137static void alc268_auto_init(struct hda_codec *codec)
13138{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013139 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013140 alc268_auto_init_multi_out(codec);
13141 alc268_auto_init_hp_out(codec);
13142 alc268_auto_init_mono_speaker_out(codec);
13143 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013144 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013145 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013146}
13147
13148/*
13149 * configuration and preset
13150 */
13151static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013152 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013153 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013154 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013155 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013156 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013157 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013158 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013159 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013160#ifdef CONFIG_SND_DEBUG
13161 [ALC268_TEST] = "test",
13162#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013163 [ALC268_AUTO] = "auto",
13164};
13165
13166static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013167 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013168 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013169 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013170 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013171 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013172 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13173 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013174 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013175 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13176 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013177 /* almost compatible with toshiba but with optional digital outs;
13178 * auto-probing seems working fine
13179 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013180 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013181 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013182 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013183 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013184 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013185 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013186 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013187 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020013188 {}
13189};
13190
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013191/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13192static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13193 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13194 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13195 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13196 ALC268_TOSHIBA),
13197 {}
13198};
13199
Kailang Yanga361d842007-06-05 12:30:55 +020013200static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013201 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013202 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13203 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013204 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13205 alc267_quanta_il1_verbs },
13206 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13207 .dac_nids = alc268_dac_nids,
13208 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13209 .adc_nids = alc268_adc_nids_alt,
13210 .hp_nid = 0x03,
13211 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13212 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013213 .unsol_event = alc_sku_unsol_event,
13214 .setup = alc267_quanta_il1_setup,
13215 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013216 },
Kailang Yanga361d842007-06-05 12:30:55 +020013217 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013218 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13219 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013220 .init_verbs = { alc268_base_init_verbs },
13221 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13222 .dac_nids = alc268_dac_nids,
13223 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13224 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013225 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013226 .hp_nid = 0x03,
13227 .dig_out_nid = ALC268_DIGOUT_NID,
13228 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13229 .channel_mode = alc268_modes,
13230 .input_mux = &alc268_capture_source,
13231 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013232 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013233 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013234 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013235 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13236 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013237 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13238 .dac_nids = alc268_dac_nids,
13239 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13240 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013241 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013242 .hp_nid = 0x03,
13243 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13244 .channel_mode = alc268_modes,
13245 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013246 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013247 .setup = alc268_toshiba_setup,
13248 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013249 },
13250 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013251 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013252 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013253 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13254 alc268_acer_verbs },
13255 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13256 .dac_nids = alc268_dac_nids,
13257 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13258 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013259 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013260 .hp_nid = 0x02,
13261 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13262 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013263 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013264 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013265 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013266 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013267 [ALC268_ACER_DMIC] = {
13268 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13269 alc268_beep_mixer },
13270 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13271 alc268_acer_verbs },
13272 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13273 .dac_nids = alc268_dac_nids,
13274 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13275 .adc_nids = alc268_adc_nids_alt,
13276 .capsrc_nids = alc268_capsrc_nids,
13277 .hp_nid = 0x02,
13278 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13279 .channel_mode = alc268_modes,
13280 .input_mux = &alc268_acer_dmic_capture_source,
13281 .unsol_event = alc268_acer_unsol_event,
13282 .init_hook = alc268_acer_init_hook,
13283 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013284 [ALC268_ACER_ASPIRE_ONE] = {
13285 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013286 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013287 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013288 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13289 alc268_acer_aspire_one_verbs },
13290 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13291 .dac_nids = alc268_dac_nids,
13292 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13293 .adc_nids = alc268_adc_nids_alt,
13294 .capsrc_nids = alc268_capsrc_nids,
13295 .hp_nid = 0x03,
13296 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13297 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013298 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013299 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013300 .init_hook = alc268_acer_lc_init_hook,
13301 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013302 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013303 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13304 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013305 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13306 alc268_dell_verbs },
13307 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13308 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013309 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13310 .adc_nids = alc268_adc_nids_alt,
13311 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013312 .hp_nid = 0x02,
13313 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13314 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013315 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013316 .setup = alc268_dell_setup,
13317 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013318 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013319 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013320 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13321 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013322 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13323 alc268_toshiba_verbs },
13324 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13325 .dac_nids = alc268_dac_nids,
13326 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13327 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013328 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013329 .hp_nid = 0x03,
13330 .dig_out_nid = ALC268_DIGOUT_NID,
13331 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13332 .channel_mode = alc268_modes,
13333 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013334 .setup = alc268_toshiba_setup,
13335 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013336 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013337#ifdef CONFIG_SND_DEBUG
13338 [ALC268_TEST] = {
13339 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13340 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13341 alc268_volume_init_verbs },
13342 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13343 .dac_nids = alc268_dac_nids,
13344 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13345 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013346 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013347 .hp_nid = 0x03,
13348 .dig_out_nid = ALC268_DIGOUT_NID,
13349 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13350 .channel_mode = alc268_modes,
13351 .input_mux = &alc268_capture_source,
13352 },
13353#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013354};
13355
13356static int patch_alc268(struct hda_codec *codec)
13357{
13358 struct alc_spec *spec;
13359 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013360 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013361
Julia Lawallef86f582009-12-19 08:18:03 +010013362 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013363 if (spec == NULL)
13364 return -ENOMEM;
13365
13366 codec->spec = spec;
13367
13368 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13369 alc268_models,
13370 alc268_cfg_tbl);
13371
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013372 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13373 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013374 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013375
Kailang Yanga361d842007-06-05 12:30:55 +020013376 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013377 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13378 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013379 board_config = ALC268_AUTO;
13380 }
13381
13382 if (board_config == ALC268_AUTO) {
13383 /* automatic parse from the BIOS config */
13384 err = alc268_parse_auto_config(codec);
13385 if (err < 0) {
13386 alc_free(codec);
13387 return err;
13388 } else if (!err) {
13389 printk(KERN_INFO
13390 "hda_codec: Cannot set up configuration "
13391 "from BIOS. Using base mode...\n");
13392 board_config = ALC268_3ST;
13393 }
13394 }
13395
13396 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013397 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013398
Kailang Yanga361d842007-06-05 12:30:55 +020013399 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13400 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013401 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013402
Kailang Yanga361d842007-06-05 12:30:55 +020013403 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13404
Takashi Iwai22971e32009-02-10 11:56:44 +010013405 has_beep = 0;
13406 for (i = 0; i < spec->num_mixers; i++) {
13407 if (spec->mixers[i] == alc268_beep_mixer) {
13408 has_beep = 1;
13409 break;
13410 }
13411 }
13412
13413 if (has_beep) {
13414 err = snd_hda_attach_beep_device(codec, 0x1);
13415 if (err < 0) {
13416 alc_free(codec);
13417 return err;
13418 }
13419 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13420 /* override the amp caps for beep generator */
13421 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013422 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13423 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13424 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13425 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013426 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013427
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013428 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013429 /* check whether NID 0x07 is valid */
13430 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013431 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013432
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013433 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013434 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013435 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013436 if (spec->auto_mic ||
13437 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013438 spec->adc_nids = alc268_adc_nids_alt;
13439 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013440 if (spec->auto_mic)
13441 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013442 if (spec->auto_mic || spec->input_mux->num_items == 1)
13443 add_mixer(spec, alc268_capture_nosrc_mixer);
13444 else
13445 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013446 } else {
13447 spec->adc_nids = alc268_adc_nids;
13448 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013449 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013450 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013451 /* set default input source */
13452 for (i = 0; i < spec->num_adc_nids; i++)
13453 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13454 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013455 i < spec->num_mux_defs ?
13456 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013457 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013458 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013459
13460 spec->vmaster_nid = 0x02;
13461
Kailang Yanga361d842007-06-05 12:30:55 +020013462 codec->patch_ops = alc_patch_ops;
13463 if (board_config == ALC268_AUTO)
13464 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013465
Kailang Yanga361d842007-06-05 12:30:55 +020013466 return 0;
13467}
13468
13469/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013470 * ALC269 channel source setting (2 channel)
13471 */
13472#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13473
13474#define alc269_dac_nids alc260_dac_nids
13475
13476static hda_nid_t alc269_adc_nids[1] = {
13477 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013478 0x08,
13479};
13480
Takashi Iwaie01bf502008-08-21 16:25:07 +020013481static hda_nid_t alc269_capsrc_nids[1] = {
13482 0x23,
13483};
13484
Kailang Yang84898e82010-02-04 14:16:14 +010013485static hda_nid_t alc269vb_adc_nids[1] = {
13486 /* ADC1 */
13487 0x09,
13488};
13489
13490static hda_nid_t alc269vb_capsrc_nids[1] = {
13491 0x22,
13492};
13493
Takashi Iwai66946352010-03-29 17:21:45 +020013494static hda_nid_t alc269_adc_candidates[] = {
13495 0x08, 0x09, 0x07,
13496};
Takashi Iwaie01bf502008-08-21 16:25:07 +020013497
Kailang Yangf6a92242007-12-13 16:52:54 +010013498#define alc269_modes alc260_modes
13499#define alc269_capture_source alc880_lg_lw_capture_source
13500
13501static struct snd_kcontrol_new alc269_base_mixer[] = {
13502 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13503 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13504 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13505 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13507 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13508 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13509 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13510 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13511 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13512 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13513 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13514 { } /* end */
13515};
13516
Kailang Yang60db6b52008-08-26 13:13:00 +020013517static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13518 /* output mixer control */
13519 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13520 {
13521 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13522 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013523 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013524 .info = snd_hda_mixer_amp_switch_info,
13525 .get = snd_hda_mixer_amp_switch_get,
13526 .put = alc268_acer_master_sw_put,
13527 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13528 },
13529 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13530 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13531 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13532 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13533 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13534 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013535 { }
13536};
13537
Tony Vroon64154832008-11-06 15:08:49 +000013538static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13539 /* output mixer control */
13540 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13541 {
13542 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13543 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013544 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013545 .info = snd_hda_mixer_amp_switch_info,
13546 .get = snd_hda_mixer_amp_switch_get,
13547 .put = alc268_acer_master_sw_put,
13548 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13549 },
13550 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13551 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13552 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13553 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13554 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13555 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13556 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13557 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13558 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013559 { }
13560};
13561
Kailang Yang84898e82010-02-04 14:16:14 +010013562static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013563 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013564 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013565 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013566 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013567 { } /* end */
13568};
13569
Kailang Yang84898e82010-02-04 14:16:14 +010013570static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
13571 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13572 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13573 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13574 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13575 { } /* end */
13576};
13577
Kailang Yangf6a92242007-12-13 16:52:54 +010013578/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010013579static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
13580 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13581 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13582 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13583 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13584 { } /* end */
13585};
13586
13587static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020013588 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13589 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013590 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13591 { } /* end */
13592};
13593
Kailang Yang84898e82010-02-04 14:16:14 +010013594static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
13595 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13596 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13597 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13598 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13599 { } /* end */
13600};
13601
13602static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
13603 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13604 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13605 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13606 { } /* end */
13607};
13608
Takashi Iwai26f5df22008-11-03 17:39:46 +010013609/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010013610#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013611
Kailang Yang60db6b52008-08-26 13:13:00 +020013612static struct hda_verb alc269_quanta_fl1_verbs[] = {
13613 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13614 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13615 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13616 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13617 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13618 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13619 { }
13620};
13621
Tony Vroon64154832008-11-06 15:08:49 +000013622static struct hda_verb alc269_lifebook_verbs[] = {
13623 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13624 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13625 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13626 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13627 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13628 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13629 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13630 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13631 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13632 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13633 { }
13634};
13635
Kailang Yang60db6b52008-08-26 13:13:00 +020013636/* toggle speaker-output according to the hp-jack state */
13637static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13638{
13639 unsigned int present;
13640 unsigned char bits;
13641
Wu Fengguang864f92b2009-11-18 12:38:02 +080013642 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013643 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013644 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013645 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013646 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013647 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013648
13649 snd_hda_codec_write(codec, 0x20, 0,
13650 AC_VERB_SET_COEF_INDEX, 0x0c);
13651 snd_hda_codec_write(codec, 0x20, 0,
13652 AC_VERB_SET_PROC_COEF, 0x680);
13653
13654 snd_hda_codec_write(codec, 0x20, 0,
13655 AC_VERB_SET_COEF_INDEX, 0x0c);
13656 snd_hda_codec_write(codec, 0x20, 0,
13657 AC_VERB_SET_PROC_COEF, 0x480);
13658}
13659
Tony Vroon64154832008-11-06 15:08:49 +000013660/* toggle speaker-output according to the hp-jacks state */
13661static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13662{
13663 unsigned int present;
13664 unsigned char bits;
13665
13666 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013667 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013668
13669 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013670 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013671
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013672 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000013673 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013674 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013675 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013676 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013677
13678 snd_hda_codec_write(codec, 0x20, 0,
13679 AC_VERB_SET_COEF_INDEX, 0x0c);
13680 snd_hda_codec_write(codec, 0x20, 0,
13681 AC_VERB_SET_PROC_COEF, 0x680);
13682
13683 snd_hda_codec_write(codec, 0x20, 0,
13684 AC_VERB_SET_COEF_INDEX, 0x0c);
13685 snd_hda_codec_write(codec, 0x20, 0,
13686 AC_VERB_SET_PROC_COEF, 0x480);
13687}
13688
Tony Vroon64154832008-11-06 15:08:49 +000013689static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13690{
13691 unsigned int present_laptop;
13692 unsigned int present_dock;
13693
Wu Fengguang864f92b2009-11-18 12:38:02 +080013694 present_laptop = snd_hda_jack_detect(codec, 0x18);
13695 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013696
13697 /* Laptop mic port overrides dock mic port, design decision */
13698 if (present_dock)
13699 snd_hda_codec_write(codec, 0x23, 0,
13700 AC_VERB_SET_CONNECT_SEL, 0x3);
13701 if (present_laptop)
13702 snd_hda_codec_write(codec, 0x23, 0,
13703 AC_VERB_SET_CONNECT_SEL, 0x0);
13704 if (!present_dock && !present_laptop)
13705 snd_hda_codec_write(codec, 0x23, 0,
13706 AC_VERB_SET_CONNECT_SEL, 0x1);
13707}
13708
Kailang Yang60db6b52008-08-26 13:13:00 +020013709static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13710 unsigned int res)
13711{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013712 switch (res >> 26) {
13713 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013714 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013715 break;
13716 case ALC880_MIC_EVENT:
13717 alc_mic_automute(codec);
13718 break;
13719 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013720}
13721
Tony Vroon64154832008-11-06 15:08:49 +000013722static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13723 unsigned int res)
13724{
13725 if ((res >> 26) == ALC880_HP_EVENT)
13726 alc269_lifebook_speaker_automute(codec);
13727 if ((res >> 26) == ALC880_MIC_EVENT)
13728 alc269_lifebook_mic_autoswitch(codec);
13729}
13730
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013731static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13732{
13733 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013734 spec->autocfg.hp_pins[0] = 0x15;
13735 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013736 spec->ext_mic.pin = 0x18;
13737 spec->ext_mic.mux_idx = 0;
13738 spec->int_mic.pin = 0x19;
13739 spec->int_mic.mux_idx = 1;
13740 spec->auto_mic = 1;
13741}
13742
Kailang Yang60db6b52008-08-26 13:13:00 +020013743static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13744{
13745 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013746 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013747}
13748
Tony Vroon64154832008-11-06 15:08:49 +000013749static void alc269_lifebook_init_hook(struct hda_codec *codec)
13750{
13751 alc269_lifebook_speaker_automute(codec);
13752 alc269_lifebook_mic_autoswitch(codec);
13753}
13754
Kailang Yang84898e82010-02-04 14:16:14 +010013755static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013756 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13757 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13758 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13759 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13760 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13761 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13762 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13763 {}
13764};
13765
Kailang Yang84898e82010-02-04 14:16:14 +010013766static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013767 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13768 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13769 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13770 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13771 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13772 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13773 {}
13774};
13775
Kailang Yang84898e82010-02-04 14:16:14 +010013776static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
13777 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13778 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
13779 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13780 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13781 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13782 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13783 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13784 {}
13785};
13786
13787static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
13788 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13789 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
13790 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13791 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13792 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13793 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13794 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13795 {}
13796};
13797
Kailang Yang60db6b52008-08-26 13:13:00 +020013798/* toggle speaker-output according to the hp-jack state */
13799static void alc269_speaker_automute(struct hda_codec *codec)
13800{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013801 struct alc_spec *spec = codec->spec;
13802 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013803 unsigned int present;
13804 unsigned char bits;
13805
Kailang Yangebb83ee2009-12-17 12:23:00 +010013806 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013807 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013808 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013809 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013810 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013811 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013812}
13813
Kailang Yang60db6b52008-08-26 13:13:00 +020013814/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010013815static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013816 unsigned int res)
13817{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013818 switch (res >> 26) {
13819 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013820 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013821 break;
13822 case ALC880_MIC_EVENT:
13823 alc_mic_automute(codec);
13824 break;
13825 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013826}
13827
Kailang Yang226b1ec2010-04-09 11:01:20 +020013828static void alc269_laptop_amic_setup(struct hda_codec *codec)
13829{
13830 struct alc_spec *spec = codec->spec;
13831 spec->autocfg.hp_pins[0] = 0x15;
13832 spec->autocfg.speaker_pins[0] = 0x14;
13833 spec->ext_mic.pin = 0x18;
13834 spec->ext_mic.mux_idx = 0;
13835 spec->int_mic.pin = 0x19;
13836 spec->int_mic.mux_idx = 1;
13837 spec->auto_mic = 1;
13838}
13839
Kailang Yang84898e82010-02-04 14:16:14 +010013840static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013841{
13842 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013843 spec->autocfg.hp_pins[0] = 0x15;
13844 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013845 spec->ext_mic.pin = 0x18;
13846 spec->ext_mic.mux_idx = 0;
13847 spec->int_mic.pin = 0x12;
13848 spec->int_mic.mux_idx = 5;
13849 spec->auto_mic = 1;
13850}
13851
Kailang Yang226b1ec2010-04-09 11:01:20 +020013852static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010013853{
13854 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020013855 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010013856 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013857 spec->ext_mic.pin = 0x18;
13858 spec->ext_mic.mux_idx = 0;
13859 spec->int_mic.pin = 0x19;
13860 spec->int_mic.mux_idx = 1;
13861 spec->auto_mic = 1;
13862}
13863
Kailang Yang226b1ec2010-04-09 11:01:20 +020013864static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
13865{
13866 struct alc_spec *spec = codec->spec;
13867 spec->autocfg.hp_pins[0] = 0x21;
13868 spec->autocfg.speaker_pins[0] = 0x14;
13869 spec->ext_mic.pin = 0x18;
13870 spec->ext_mic.mux_idx = 0;
13871 spec->int_mic.pin = 0x12;
13872 spec->int_mic.mux_idx = 6;
13873 spec->auto_mic = 1;
13874}
13875
Kailang Yang84898e82010-02-04 14:16:14 +010013876static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013877{
13878 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013879 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013880}
13881
Kailang Yangf6a92242007-12-13 16:52:54 +010013882/*
13883 * generic initialization of ADC, input mixers and output mixers
13884 */
13885static struct hda_verb alc269_init_verbs[] = {
13886 /*
13887 * Unmute ADC0 and set the default input to mic-in
13888 */
Kailang Yang84898e82010-02-04 14:16:14 +010013889 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013890
13891 /*
Kailang Yang84898e82010-02-04 14:16:14 +010013892 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010013893 */
13894 /* set vol=0 to output mixers */
13895 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13896 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13897
13898 /* set up input amps for analog loopback */
13899 /* Amp Indices: DAC = 0, mixer = 1 */
13900 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13901 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13902 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13903 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13904 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13905 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13906
13907 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13908 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13909 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13910 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13911 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13912 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13913 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13914
13915 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13916 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010013917
Kailang Yang84898e82010-02-04 14:16:14 +010013918 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010013919 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13920 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010013921 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010013922
13923 /* set EAPD */
13924 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010013925 { }
13926};
13927
13928static struct hda_verb alc269vb_init_verbs[] = {
13929 /*
13930 * Unmute ADC0 and set the default input to mic-in
13931 */
13932 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13933
13934 /*
13935 * Set up output mixers (0x02 - 0x03)
13936 */
13937 /* set vol=0 to output mixers */
13938 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13939 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13940
13941 /* set up input amps for analog loopback */
13942 /* Amp Indices: DAC = 0, mixer = 1 */
13943 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13944 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13945 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13946 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13947 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13948 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13949
13950 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13951 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13952 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13953 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13954 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13955 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13956 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13957
13958 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13959 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13960
13961 /* FIXME: use Mux-type input source selection */
13962 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13963 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
13964 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
13965
13966 /* set EAPD */
13967 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010013968 { }
13969};
13970
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013971#define alc269_auto_create_multi_out_ctls \
13972 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013973#define alc269_auto_create_input_ctls \
13974 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013975
13976#ifdef CONFIG_SND_HDA_POWER_SAVE
13977#define alc269_loopbacks alc880_loopbacks
13978#endif
13979
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013980/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013981#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13982#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13983#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13984#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13985
Takashi Iwaif03d3112009-03-05 14:18:16 +010013986static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13987 .substreams = 1,
13988 .channels_min = 2,
13989 .channels_max = 8,
13990 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13991 /* NID is set in alc_build_pcms */
13992 .ops = {
13993 .open = alc880_playback_pcm_open,
13994 .prepare = alc880_playback_pcm_prepare,
13995 .cleanup = alc880_playback_pcm_cleanup
13996 },
13997};
13998
13999static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14000 .substreams = 1,
14001 .channels_min = 2,
14002 .channels_max = 2,
14003 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14004 /* NID is set in alc_build_pcms */
14005};
14006
Kailang Yangf6a92242007-12-13 16:52:54 +010014007/*
14008 * BIOS auto configuration
14009 */
14010static int alc269_parse_auto_config(struct hda_codec *codec)
14011{
14012 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014013 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014014 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14015
14016 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14017 alc269_ignore);
14018 if (err < 0)
14019 return err;
14020
14021 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14022 if (err < 0)
14023 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014024 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010014025 if (err < 0)
14026 return err;
14027
14028 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14029
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014030 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010014031 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
14032
Takashi Iwai603c4012008-07-30 15:01:44 +020014033 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014034 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014035
Kailang Yang84898e82010-02-04 14:16:14 +010014036 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
14037 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014038 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014039 } else {
14040 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014041 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014042 }
14043
Kailang Yangf6a92242007-12-13 16:52:54 +010014044 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014045 spec->input_mux = &spec->private_imux[0];
Takashi Iwai66946352010-03-29 17:21:45 +020014046 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14047 sizeof(alc269_adc_candidates));
14048
Takashi Iwaie01bf502008-08-21 16:25:07 +020014049 /* set default input source */
Takashi Iwai66946352010-03-29 17:21:45 +020014050 snd_hda_codec_write_cache(codec, spec->capsrc_nids[0],
Takashi Iwaie01bf502008-08-21 16:25:07 +020014051 0, AC_VERB_SET_CONNECT_SEL,
14052 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014053
14054 err = alc_auto_add_mic_boost(codec);
14055 if (err < 0)
14056 return err;
14057
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014058 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014059 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014060
Kailang Yangf6a92242007-12-13 16:52:54 +010014061 return 1;
14062}
14063
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014064#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14065#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014066#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14067
14068
14069/* init callback for auto-configuration model -- overriding the default init */
14070static void alc269_auto_init(struct hda_codec *codec)
14071{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014072 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014073 alc269_auto_init_multi_out(codec);
14074 alc269_auto_init_hp_out(codec);
14075 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014076 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014077 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014078}
14079
Takashi Iwaiff818c22010-04-12 08:59:25 +020014080enum {
14081 ALC269_FIXUP_SONY_VAIO,
14082};
14083
14084const static struct hda_verb alc269_sony_vaio_fixup_verbs[] = {
14085 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14086 {}
14087};
14088
14089static const struct alc_fixup alc269_fixups[] = {
14090 [ALC269_FIXUP_SONY_VAIO] = {
14091 .verbs = alc269_sony_vaio_fixup_verbs
14092 },
14093};
14094
14095static struct snd_pci_quirk alc269_fixup_tbl[] = {
14096 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
14097 {}
14098};
14099
14100
Kailang Yangf6a92242007-12-13 16:52:54 +010014101/*
14102 * configuration and preset
14103 */
14104static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014105 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014106 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014107 [ALC269_AMIC] = "laptop-amic",
14108 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014109 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014110 [ALC269_LIFEBOOK] = "lifebook",
14111 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014112};
14113
14114static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014115 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020014116 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014117 ALC269_AMIC),
14118 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14119 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14120 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14121 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14122 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14123 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14124 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14125 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14126 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14127 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14128 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14129 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14130 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14131 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14132 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14133 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14134 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14135 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14136 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14137 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14138 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14139 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14140 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14141 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14142 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14143 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14144 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14145 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14146 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14147 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14148 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14149 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14150 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14151 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14152 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14153 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014154 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014155 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014156 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014157 ALC269_DMIC),
14158 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14159 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014160 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014161 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014162 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14163 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14164 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14165 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14166 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14167 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014168 {}
14169};
14170
14171static struct alc_config_preset alc269_presets[] = {
14172 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014173 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014174 .init_verbs = { alc269_init_verbs },
14175 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14176 .dac_nids = alc269_dac_nids,
14177 .hp_nid = 0x03,
14178 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14179 .channel_mode = alc269_modes,
14180 .input_mux = &alc269_capture_source,
14181 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014182 [ALC269_QUANTA_FL1] = {
14183 .mixers = { alc269_quanta_fl1_mixer },
14184 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14185 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14186 .dac_nids = alc269_dac_nids,
14187 .hp_nid = 0x03,
14188 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14189 .channel_mode = alc269_modes,
14190 .input_mux = &alc269_capture_source,
14191 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014192 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014193 .init_hook = alc269_quanta_fl1_init_hook,
14194 },
Kailang Yang84898e82010-02-04 14:16:14 +010014195 [ALC269_AMIC] = {
14196 .mixers = { alc269_laptop_mixer },
14197 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014198 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014199 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014200 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14201 .dac_nids = alc269_dac_nids,
14202 .hp_nid = 0x03,
14203 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14204 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014205 .unsol_event = alc269_laptop_unsol_event,
14206 .setup = alc269_laptop_amic_setup,
14207 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014208 },
Kailang Yang84898e82010-02-04 14:16:14 +010014209 [ALC269_DMIC] = {
14210 .mixers = { alc269_laptop_mixer },
14211 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014212 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014213 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014214 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14215 .dac_nids = alc269_dac_nids,
14216 .hp_nid = 0x03,
14217 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14218 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014219 .unsol_event = alc269_laptop_unsol_event,
14220 .setup = alc269_laptop_dmic_setup,
14221 .init_hook = alc269_laptop_inithook,
14222 },
14223 [ALC269VB_AMIC] = {
14224 .mixers = { alc269vb_laptop_mixer },
14225 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14226 .init_verbs = { alc269vb_init_verbs,
14227 alc269vb_laptop_amic_init_verbs },
14228 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14229 .dac_nids = alc269_dac_nids,
14230 .hp_nid = 0x03,
14231 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14232 .channel_mode = alc269_modes,
14233 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014234 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014235 .init_hook = alc269_laptop_inithook,
14236 },
14237 [ALC269VB_DMIC] = {
14238 .mixers = { alc269vb_laptop_mixer },
14239 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14240 .init_verbs = { alc269vb_init_verbs,
14241 alc269vb_laptop_dmic_init_verbs },
14242 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14243 .dac_nids = alc269_dac_nids,
14244 .hp_nid = 0x03,
14245 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14246 .channel_mode = alc269_modes,
14247 .unsol_event = alc269_laptop_unsol_event,
14248 .setup = alc269vb_laptop_dmic_setup,
14249 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014250 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014251 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014252 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014253 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014254 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014255 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014256 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14257 .dac_nids = alc269_dac_nids,
14258 .hp_nid = 0x03,
14259 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14260 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014261 .unsol_event = alc269_laptop_unsol_event,
14262 .setup = alc269_laptop_dmic_setup,
14263 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014264 },
Tony Vroon64154832008-11-06 15:08:49 +000014265 [ALC269_LIFEBOOK] = {
14266 .mixers = { alc269_lifebook_mixer },
14267 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14268 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14269 .dac_nids = alc269_dac_nids,
14270 .hp_nid = 0x03,
14271 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14272 .channel_mode = alc269_modes,
14273 .input_mux = &alc269_capture_source,
14274 .unsol_event = alc269_lifebook_unsol_event,
14275 .init_hook = alc269_lifebook_init_hook,
14276 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014277};
14278
14279static int patch_alc269(struct hda_codec *codec)
14280{
14281 struct alc_spec *spec;
14282 int board_config;
14283 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014284 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014285
14286 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14287 if (spec == NULL)
14288 return -ENOMEM;
14289
14290 codec->spec = spec;
14291
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020014292 alc_fix_pll_init(codec, 0x20, 0x04, 15);
14293
Kailang Yang274693f2009-12-03 10:07:50 +010014294 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
14295 kfree(codec->chip_name);
14296 codec->chip_name = kstrdup("ALC259", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010014297 if (!codec->chip_name) {
14298 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010014299 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010014300 }
Kailang Yang84898e82010-02-04 14:16:14 +010014301 is_alc269vb = 1;
Kailang Yang274693f2009-12-03 10:07:50 +010014302 }
14303
Kailang Yangf6a92242007-12-13 16:52:54 +010014304 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14305 alc269_models,
14306 alc269_cfg_tbl);
14307
14308 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014309 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14310 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014311 board_config = ALC269_AUTO;
14312 }
14313
Takashi Iwaiff818c22010-04-12 08:59:25 +020014314 if (board_config == ALC269_AUTO)
14315 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
14316
Kailang Yangf6a92242007-12-13 16:52:54 +010014317 if (board_config == ALC269_AUTO) {
14318 /* automatic parse from the BIOS config */
14319 err = alc269_parse_auto_config(codec);
14320 if (err < 0) {
14321 alc_free(codec);
14322 return err;
14323 } else if (!err) {
14324 printk(KERN_INFO
14325 "hda_codec: Cannot set up configuration "
14326 "from BIOS. Using base mode...\n");
14327 board_config = ALC269_BASIC;
14328 }
14329 }
14330
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014331 err = snd_hda_attach_beep_device(codec, 0x1);
14332 if (err < 0) {
14333 alc_free(codec);
14334 return err;
14335 }
14336
Kailang Yangf6a92242007-12-13 16:52:54 +010014337 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014338 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014339
Kailang Yang84898e82010-02-04 14:16:14 +010014340 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014341 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14342 * fix the sample rate of analog I/O to 44.1kHz
14343 */
14344 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14345 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
14346 } else {
14347 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14348 spec->stream_analog_capture = &alc269_pcm_analog_capture;
14349 }
Kailang Yangf6a92242007-12-13 16:52:54 +010014350 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14351 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14352
Takashi Iwai66946352010-03-29 17:21:45 +020014353 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
14354 if (!is_alc269vb) {
14355 spec->adc_nids = alc269_adc_nids;
14356 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14357 spec->capsrc_nids = alc269_capsrc_nids;
14358 } else {
14359 spec->adc_nids = alc269vb_adc_nids;
14360 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14361 spec->capsrc_nids = alc269vb_capsrc_nids;
14362 }
Kailang Yang84898e82010-02-04 14:16:14 +010014363 }
14364
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014365 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014366 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014367 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010014368
Takashi Iwaiff818c22010-04-12 08:59:25 +020014369 if (board_config == ALC269_AUTO)
14370 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
14371
Takashi Iwai100d5eb2009-08-10 11:55:51 +020014372 spec->vmaster_nid = 0x02;
14373
Kailang Yangf6a92242007-12-13 16:52:54 +010014374 codec->patch_ops = alc_patch_ops;
14375 if (board_config == ALC269_AUTO)
14376 spec->init_hook = alc269_auto_init;
14377#ifdef CONFIG_SND_HDA_POWER_SAVE
14378 if (!spec->loopback.amplist)
14379 spec->loopback.amplist = alc269_loopbacks;
14380#endif
14381
14382 return 0;
14383}
14384
14385/*
Kailang Yangdf694da2005-12-05 19:42:22 +010014386 * ALC861 channel source setting (2/6 channel selection for 3-stack)
14387 */
14388
14389/*
14390 * set the path ways for 2 channel output
14391 * need to set the codec line out and mic 1 pin widgets to inputs
14392 */
14393static struct hda_verb alc861_threestack_ch2_init[] = {
14394 /* set pin widget 1Ah (line in) for input */
14395 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014396 /* set pin widget 18h (mic1/2) for input, for mic also enable
14397 * the vref
14398 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014399 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14400
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014401 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14402#if 0
14403 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14404 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14405#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014406 { } /* end */
14407};
14408/*
14409 * 6ch mode
14410 * need to set the codec line out and mic 1 pin widgets to outputs
14411 */
14412static struct hda_verb alc861_threestack_ch6_init[] = {
14413 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14414 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14415 /* set pin widget 18h (mic1) for output (CLFE)*/
14416 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14417
14418 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014419 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014420
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014421 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14422#if 0
14423 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14424 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14425#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014426 { } /* end */
14427};
14428
14429static struct hda_channel_mode alc861_threestack_modes[2] = {
14430 { 2, alc861_threestack_ch2_init },
14431 { 6, alc861_threestack_ch6_init },
14432};
Takashi Iwai22309c32006-08-09 16:57:28 +020014433/* Set mic1 as input and unmute the mixer */
14434static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
14435 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14436 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14437 { } /* end */
14438};
14439/* Set mic1 as output and mute mixer */
14440static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
14441 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14442 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14443 { } /* end */
14444};
14445
14446static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
14447 { 2, alc861_uniwill_m31_ch2_init },
14448 { 4, alc861_uniwill_m31_ch4_init },
14449};
Kailang Yangdf694da2005-12-05 19:42:22 +010014450
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014451/* Set mic1 and line-in as input and unmute the mixer */
14452static struct hda_verb alc861_asus_ch2_init[] = {
14453 /* set pin widget 1Ah (line in) for input */
14454 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014455 /* set pin widget 18h (mic1/2) for input, for mic also enable
14456 * the vref
14457 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014458 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14459
14460 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14461#if 0
14462 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14463 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14464#endif
14465 { } /* end */
14466};
14467/* Set mic1 nad line-in as output and mute mixer */
14468static struct hda_verb alc861_asus_ch6_init[] = {
14469 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14470 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14471 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14472 /* set pin widget 18h (mic1) for output (CLFE)*/
14473 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14474 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14475 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
14476 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
14477
14478 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14479#if 0
14480 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14481 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14482#endif
14483 { } /* end */
14484};
14485
14486static struct hda_channel_mode alc861_asus_modes[2] = {
14487 { 2, alc861_asus_ch2_init },
14488 { 6, alc861_asus_ch6_init },
14489};
14490
Kailang Yangdf694da2005-12-05 19:42:22 +010014491/* patch-ALC861 */
14492
14493static struct snd_kcontrol_new alc861_base_mixer[] = {
14494 /* output mixer control */
14495 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14496 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14497 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14498 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14499 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14500
14501 /*Input mixer control */
14502 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14503 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14504 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14505 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14506 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14507 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14508 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14509 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14510 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14511 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014512
Kailang Yangdf694da2005-12-05 19:42:22 +010014513 { } /* end */
14514};
14515
14516static struct snd_kcontrol_new alc861_3ST_mixer[] = {
14517 /* output mixer control */
14518 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14519 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14520 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14521 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14522 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14523
14524 /* Input mixer control */
14525 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14526 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14527 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14528 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14529 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14530 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14531 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14532 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14533 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14534 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014535
Kailang Yangdf694da2005-12-05 19:42:22 +010014536 {
14537 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14538 .name = "Channel Mode",
14539 .info = alc_ch_mode_info,
14540 .get = alc_ch_mode_get,
14541 .put = alc_ch_mode_put,
14542 .private_value = ARRAY_SIZE(alc861_threestack_modes),
14543 },
14544 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014545};
14546
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014547static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014548 /* output mixer control */
14549 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14550 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14551 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014552
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014553 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014554};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014555
Takashi Iwai22309c32006-08-09 16:57:28 +020014556static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
14557 /* output mixer control */
14558 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14559 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14560 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14561 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14562 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14563
14564 /* Input mixer control */
14565 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14566 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14567 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14568 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14569 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14570 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14571 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14572 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14573 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14574 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014575
Takashi Iwai22309c32006-08-09 16:57:28 +020014576 {
14577 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14578 .name = "Channel Mode",
14579 .info = alc_ch_mode_info,
14580 .get = alc_ch_mode_get,
14581 .put = alc_ch_mode_put,
14582 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
14583 },
14584 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014585};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014586
14587static struct snd_kcontrol_new alc861_asus_mixer[] = {
14588 /* output mixer control */
14589 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14590 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14591 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14592 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14593 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14594
14595 /* Input mixer control */
14596 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14597 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14598 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14599 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14600 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14601 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14602 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14603 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14604 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014605 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
14606
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014607 {
14608 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14609 .name = "Channel Mode",
14610 .info = alc_ch_mode_info,
14611 .get = alc_ch_mode_get,
14612 .put = alc_ch_mode_put,
14613 .private_value = ARRAY_SIZE(alc861_asus_modes),
14614 },
14615 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014616};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014617
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014618/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014619static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014620 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14621 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014622 { }
14623};
14624
Kailang Yangdf694da2005-12-05 19:42:22 +010014625/*
14626 * generic initialization of ADC, input mixers and output mixers
14627 */
14628static struct hda_verb alc861_base_init_verbs[] = {
14629 /*
14630 * Unmute ADC0 and set the default input to mic-in
14631 */
14632 /* port-A for surround (rear panel) */
14633 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14634 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
14635 /* port-B for mic-in (rear panel) with vref */
14636 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14637 /* port-C for line-in (rear panel) */
14638 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14639 /* port-D for Front */
14640 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14641 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14642 /* port-E for HP out (front panel) */
14643 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14644 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014645 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014646 /* port-F for mic-in (front panel) with vref */
14647 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14648 /* port-G for CLFE (rear panel) */
14649 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14650 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14651 /* port-H for side (rear panel) */
14652 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14653 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
14654 /* CD-in */
14655 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14656 /* route front mic to ADC1*/
14657 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14658 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014659
Kailang Yangdf694da2005-12-05 19:42:22 +010014660 /* Unmute DAC0~3 & spdif out*/
14661 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14662 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14663 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14664 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14665 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014666
Kailang Yangdf694da2005-12-05 19:42:22 +010014667 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14668 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14669 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14670 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14671 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014672
Kailang Yangdf694da2005-12-05 19:42:22 +010014673 /* Unmute Stereo Mixer 15 */
14674 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14675 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14676 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014677 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014678
14679 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14680 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14681 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14682 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14683 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14684 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14685 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14686 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014687 /* hp used DAC 3 (Front) */
14688 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014689 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14690
14691 { }
14692};
14693
14694static struct hda_verb alc861_threestack_init_verbs[] = {
14695 /*
14696 * Unmute ADC0 and set the default input to mic-in
14697 */
14698 /* port-A for surround (rear panel) */
14699 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14700 /* port-B for mic-in (rear panel) with vref */
14701 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14702 /* port-C for line-in (rear panel) */
14703 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14704 /* port-D for Front */
14705 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14706 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14707 /* port-E for HP out (front panel) */
14708 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14709 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014710 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014711 /* port-F for mic-in (front panel) with vref */
14712 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14713 /* port-G for CLFE (rear panel) */
14714 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14715 /* port-H for side (rear panel) */
14716 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14717 /* CD-in */
14718 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14719 /* route front mic to ADC1*/
14720 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14721 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14722 /* Unmute DAC0~3 & spdif out*/
14723 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14724 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14725 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14726 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14727 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014728
Kailang Yangdf694da2005-12-05 19:42:22 +010014729 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14730 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14731 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14732 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14733 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014734
Kailang Yangdf694da2005-12-05 19:42:22 +010014735 /* Unmute Stereo Mixer 15 */
14736 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14737 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14738 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014739 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014740
14741 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14742 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14743 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14744 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14745 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14746 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14747 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14748 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014749 /* hp used DAC 3 (Front) */
14750 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014751 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14752 { }
14753};
Takashi Iwai22309c32006-08-09 16:57:28 +020014754
14755static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14756 /*
14757 * Unmute ADC0 and set the default input to mic-in
14758 */
14759 /* port-A for surround (rear panel) */
14760 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14761 /* port-B for mic-in (rear panel) with vref */
14762 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14763 /* port-C for line-in (rear panel) */
14764 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14765 /* port-D for Front */
14766 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14767 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14768 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014769 /* this has to be set to VREF80 */
14770 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014771 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014772 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014773 /* port-F for mic-in (front panel) with vref */
14774 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14775 /* port-G for CLFE (rear panel) */
14776 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14777 /* port-H for side (rear panel) */
14778 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14779 /* CD-in */
14780 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14781 /* route front mic to ADC1*/
14782 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14783 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14784 /* Unmute DAC0~3 & spdif out*/
14785 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14786 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14787 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14788 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14789 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014790
Takashi Iwai22309c32006-08-09 16:57:28 +020014791 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14792 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14793 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14794 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14795 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014796
Takashi Iwai22309c32006-08-09 16:57:28 +020014797 /* Unmute Stereo Mixer 15 */
14798 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14799 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014801 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014802
14803 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14804 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14805 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14806 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14807 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14808 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14809 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14810 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014811 /* hp used DAC 3 (Front) */
14812 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014813 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14814 { }
14815};
14816
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014817static struct hda_verb alc861_asus_init_verbs[] = {
14818 /*
14819 * Unmute ADC0 and set the default input to mic-in
14820 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014821 /* port-A for surround (rear panel)
14822 * according to codec#0 this is the HP jack
14823 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014824 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14825 /* route front PCM to HP */
14826 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14827 /* port-B for mic-in (rear panel) with vref */
14828 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14829 /* port-C for line-in (rear panel) */
14830 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14831 /* port-D for Front */
14832 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14833 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14834 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014835 /* this has to be set to VREF80 */
14836 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014837 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014838 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014839 /* port-F for mic-in (front panel) with vref */
14840 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14841 /* port-G for CLFE (rear panel) */
14842 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14843 /* port-H for side (rear panel) */
14844 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14845 /* CD-in */
14846 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14847 /* route front mic to ADC1*/
14848 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14849 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14850 /* Unmute DAC0~3 & spdif out*/
14851 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14852 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14853 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14854 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14855 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14856 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14857 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14858 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14859 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14860 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014861
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014862 /* Unmute Stereo Mixer 15 */
14863 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14865 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014866 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014867
14868 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14869 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14870 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14871 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14872 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14873 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14874 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14875 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014876 /* hp used DAC 3 (Front) */
14877 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014878 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14879 { }
14880};
14881
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014882/* additional init verbs for ASUS laptops */
14883static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14884 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14885 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14886 { }
14887};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014888
Kailang Yangdf694da2005-12-05 19:42:22 +010014889/*
14890 * generic initialization of ADC, input mixers and output mixers
14891 */
14892static struct hda_verb alc861_auto_init_verbs[] = {
14893 /*
14894 * Unmute ADC0 and set the default input to mic-in
14895 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014896 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014897 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014898
Kailang Yangdf694da2005-12-05 19:42:22 +010014899 /* Unmute DAC0~3 & spdif out*/
14900 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14901 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14902 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14903 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14904 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014905
Kailang Yangdf694da2005-12-05 19:42:22 +010014906 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14907 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14908 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14909 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14910 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014911
Kailang Yangdf694da2005-12-05 19:42:22 +010014912 /* Unmute Stereo Mixer 15 */
14913 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14914 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14915 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14916 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14917
Takashi Iwai1c209302009-07-22 15:17:45 +020014918 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14919 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14920 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14921 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14922 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14923 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14924 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14925 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014926
14927 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14928 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014929 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14930 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014931 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14932 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014933 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14934 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014935
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014936 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014937
14938 { }
14939};
14940
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014941static struct hda_verb alc861_toshiba_init_verbs[] = {
14942 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014943
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014944 { }
14945};
14946
14947/* toggle speaker-output according to the hp-jack state */
14948static void alc861_toshiba_automute(struct hda_codec *codec)
14949{
Wu Fengguang864f92b2009-11-18 12:38:02 +080014950 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014951
Takashi Iwai47fd8302007-08-10 17:11:07 +020014952 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14953 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14954 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14955 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014956}
14957
14958static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14959 unsigned int res)
14960{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014961 if ((res >> 26) == ALC880_HP_EVENT)
14962 alc861_toshiba_automute(codec);
14963}
14964
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014965/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014966#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14967#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14968#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14969#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14970
14971
14972#define ALC861_DIGOUT_NID 0x07
14973
14974static struct hda_channel_mode alc861_8ch_modes[1] = {
14975 { 8, NULL }
14976};
14977
14978static hda_nid_t alc861_dac_nids[4] = {
14979 /* front, surround, clfe, side */
14980 0x03, 0x06, 0x05, 0x04
14981};
14982
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014983static hda_nid_t alc660_dac_nids[3] = {
14984 /* front, clfe, surround */
14985 0x03, 0x05, 0x06
14986};
14987
Kailang Yangdf694da2005-12-05 19:42:22 +010014988static hda_nid_t alc861_adc_nids[1] = {
14989 /* ADC0-2 */
14990 0x08,
14991};
14992
14993static struct hda_input_mux alc861_capture_source = {
14994 .num_items = 5,
14995 .items = {
14996 { "Mic", 0x0 },
14997 { "Front Mic", 0x3 },
14998 { "Line", 0x1 },
14999 { "CD", 0x4 },
15000 { "Mixer", 0x5 },
15001 },
15002};
15003
Takashi Iwai1c209302009-07-22 15:17:45 +020015004static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15005{
15006 struct alc_spec *spec = codec->spec;
15007 hda_nid_t mix, srcs[5];
15008 int i, j, num;
15009
15010 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15011 return 0;
15012 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15013 if (num < 0)
15014 return 0;
15015 for (i = 0; i < num; i++) {
15016 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015017 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015018 if (type != AC_WID_AUD_OUT)
15019 continue;
15020 for (j = 0; j < spec->multiout.num_dacs; j++)
15021 if (spec->multiout.dac_nids[j] == srcs[i])
15022 break;
15023 if (j >= spec->multiout.num_dacs)
15024 return srcs[i];
15025 }
15026 return 0;
15027}
15028
Kailang Yangdf694da2005-12-05 19:42:22 +010015029/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015030static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015031 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015032{
Takashi Iwai1c209302009-07-22 15:17:45 +020015033 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015034 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015035 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015036
15037 spec->multiout.dac_nids = spec->private_dac_nids;
15038 for (i = 0; i < cfg->line_outs; i++) {
15039 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015040 dac = alc861_look_for_dac(codec, nid);
15041 if (!dac)
15042 continue;
15043 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015044 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015045 return 0;
15046}
15047
Takashi Iwai1c209302009-07-22 15:17:45 +020015048static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15049 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015050{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015051 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015052 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15053}
15054
15055/* add playback controls from the parsed DAC table */
15056static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15057 const struct auto_pin_cfg *cfg)
15058{
15059 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015060 static const char *chname[4] = {
15061 "Front", "Surround", NULL /*CLFE*/, "Side"
15062 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015063 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015064 int i, err;
15065
15066 if (cfg->line_outs == 1) {
15067 const char *pfx = NULL;
15068 if (!cfg->hp_outs)
15069 pfx = "Master";
15070 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15071 pfx = "Speaker";
15072 if (pfx) {
15073 nid = spec->multiout.dac_nids[0];
15074 return alc861_create_out_sw(codec, pfx, nid, 3);
15075 }
15076 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015077
15078 for (i = 0; i < cfg->line_outs; i++) {
15079 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015080 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015081 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015082 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015083 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015084 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015085 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015086 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015087 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015088 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015089 return err;
15090 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015091 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015092 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015093 return err;
15094 }
15095 }
15096 return 0;
15097}
15098
Takashi Iwai1c209302009-07-22 15:17:45 +020015099static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015100{
Takashi Iwai1c209302009-07-22 15:17:45 +020015101 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015102 int err;
15103 hda_nid_t nid;
15104
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015105 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015106 return 0;
15107
15108 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015109 nid = alc861_look_for_dac(codec, pin);
15110 if (nid) {
15111 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15112 if (err < 0)
15113 return err;
15114 spec->multiout.hp_nid = nid;
15115 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015116 }
15117 return 0;
15118}
15119
15120/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015121static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015122 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015123{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015124 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015125}
15126
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015127static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15128 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015129 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015130{
Takashi Iwai1c209302009-07-22 15:17:45 +020015131 hda_nid_t mix, srcs[5];
15132 int i, num;
15133
Jacek Luczak564c5be2008-05-03 18:41:23 +020015134 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15135 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015136 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015137 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015138 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15139 return;
15140 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15141 if (num < 0)
15142 return;
15143 for (i = 0; i < num; i++) {
15144 unsigned int mute;
15145 if (srcs[i] == dac || srcs[i] == 0x15)
15146 mute = AMP_IN_UNMUTE(i);
15147 else
15148 mute = AMP_IN_MUTE(i);
15149 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15150 mute);
15151 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015152}
15153
15154static void alc861_auto_init_multi_out(struct hda_codec *codec)
15155{
15156 struct alc_spec *spec = codec->spec;
15157 int i;
15158
15159 for (i = 0; i < spec->autocfg.line_outs; i++) {
15160 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015161 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015162 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015163 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015164 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015165 }
15166}
15167
15168static void alc861_auto_init_hp_out(struct hda_codec *codec)
15169{
15170 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015171
Takashi Iwai15870f02009-10-05 08:25:13 +020015172 if (spec->autocfg.hp_outs)
15173 alc861_auto_set_output_and_unmute(codec,
15174 spec->autocfg.hp_pins[0],
15175 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015176 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015177 if (spec->autocfg.speaker_outs)
15178 alc861_auto_set_output_and_unmute(codec,
15179 spec->autocfg.speaker_pins[0],
15180 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015181 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015182}
15183
15184static void alc861_auto_init_analog_input(struct hda_codec *codec)
15185{
15186 struct alc_spec *spec = codec->spec;
15187 int i;
15188
15189 for (i = 0; i < AUTO_PIN_LAST; i++) {
15190 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010015191 if (nid >= 0x0c && nid <= 0x11)
15192 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010015193 }
15194}
15195
15196/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015197/* return 1 if successful, 0 if the proper config is not found,
15198 * or a negative error code
15199 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015200static int alc861_parse_auto_config(struct hda_codec *codec)
15201{
15202 struct alc_spec *spec = codec->spec;
15203 int err;
15204 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15205
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015206 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15207 alc861_ignore);
15208 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015209 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015210 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015211 return 0; /* can't find valid BIOS pin config */
15212
Takashi Iwai1c209302009-07-22 15:17:45 +020015213 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015214 if (err < 0)
15215 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015216 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015217 if (err < 0)
15218 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015219 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015220 if (err < 0)
15221 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015222 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015223 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015224 return err;
15225
15226 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15227
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015228 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015229 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
15230
Takashi Iwai603c4012008-07-30 15:01:44 +020015231 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015232 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015233
Takashi Iwaid88897e2008-10-31 15:01:37 +010015234 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015235
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015236 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015237 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015238
15239 spec->adc_nids = alc861_adc_nids;
15240 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015241 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015242
Kailang Yang6227cdc2010-02-25 08:36:52 +010015243 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015244
Kailang Yangdf694da2005-12-05 19:42:22 +010015245 return 1;
15246}
15247
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015248/* additional initialization for auto-configuration model */
15249static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015250{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015251 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015252 alc861_auto_init_multi_out(codec);
15253 alc861_auto_init_hp_out(codec);
15254 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015255 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015256 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015257}
15258
Takashi Iwaicb53c622007-08-10 17:21:45 +020015259#ifdef CONFIG_SND_HDA_POWER_SAVE
15260static struct hda_amp_list alc861_loopbacks[] = {
15261 { 0x15, HDA_INPUT, 0 },
15262 { 0x15, HDA_INPUT, 1 },
15263 { 0x15, HDA_INPUT, 2 },
15264 { 0x15, HDA_INPUT, 3 },
15265 { } /* end */
15266};
15267#endif
15268
Kailang Yangdf694da2005-12-05 19:42:22 +010015269
15270/*
15271 * configuration and preset
15272 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015273static const char *alc861_models[ALC861_MODEL_LAST] = {
15274 [ALC861_3ST] = "3stack",
15275 [ALC660_3ST] = "3stack-660",
15276 [ALC861_3ST_DIG] = "3stack-dig",
15277 [ALC861_6ST_DIG] = "6stack-dig",
15278 [ALC861_UNIWILL_M31] = "uniwill-m31",
15279 [ALC861_TOSHIBA] = "toshiba",
15280 [ALC861_ASUS] = "asus",
15281 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15282 [ALC861_AUTO] = "auto",
15283};
15284
15285static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015286 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015287 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15288 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15289 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015290 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015291 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015292 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015293 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15294 * Any other models that need this preset?
15295 */
15296 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015297 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15298 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015299 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15300 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15301 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15302 /* FIXME: the below seems conflict */
15303 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15304 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15305 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015306 {}
15307};
15308
15309static struct alc_config_preset alc861_presets[] = {
15310 [ALC861_3ST] = {
15311 .mixers = { alc861_3ST_mixer },
15312 .init_verbs = { alc861_threestack_init_verbs },
15313 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15314 .dac_nids = alc861_dac_nids,
15315 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15316 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015317 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015318 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15319 .adc_nids = alc861_adc_nids,
15320 .input_mux = &alc861_capture_source,
15321 },
15322 [ALC861_3ST_DIG] = {
15323 .mixers = { alc861_base_mixer },
15324 .init_verbs = { alc861_threestack_init_verbs },
15325 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15326 .dac_nids = alc861_dac_nids,
15327 .dig_out_nid = ALC861_DIGOUT_NID,
15328 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15329 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015330 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015331 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15332 .adc_nids = alc861_adc_nids,
15333 .input_mux = &alc861_capture_source,
15334 },
15335 [ALC861_6ST_DIG] = {
15336 .mixers = { alc861_base_mixer },
15337 .init_verbs = { alc861_base_init_verbs },
15338 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15339 .dac_nids = alc861_dac_nids,
15340 .dig_out_nid = ALC861_DIGOUT_NID,
15341 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
15342 .channel_mode = alc861_8ch_modes,
15343 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15344 .adc_nids = alc861_adc_nids,
15345 .input_mux = &alc861_capture_source,
15346 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015347 [ALC660_3ST] = {
15348 .mixers = { alc861_3ST_mixer },
15349 .init_verbs = { alc861_threestack_init_verbs },
15350 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
15351 .dac_nids = alc660_dac_nids,
15352 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15353 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015354 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015355 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15356 .adc_nids = alc861_adc_nids,
15357 .input_mux = &alc861_capture_source,
15358 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015359 [ALC861_UNIWILL_M31] = {
15360 .mixers = { alc861_uniwill_m31_mixer },
15361 .init_verbs = { alc861_uniwill_m31_init_verbs },
15362 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15363 .dac_nids = alc861_dac_nids,
15364 .dig_out_nid = ALC861_DIGOUT_NID,
15365 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
15366 .channel_mode = alc861_uniwill_m31_modes,
15367 .need_dac_fix = 1,
15368 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15369 .adc_nids = alc861_adc_nids,
15370 .input_mux = &alc861_capture_source,
15371 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015372 [ALC861_TOSHIBA] = {
15373 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015374 .init_verbs = { alc861_base_init_verbs,
15375 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015376 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15377 .dac_nids = alc861_dac_nids,
15378 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15379 .channel_mode = alc883_3ST_2ch_modes,
15380 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15381 .adc_nids = alc861_adc_nids,
15382 .input_mux = &alc861_capture_source,
15383 .unsol_event = alc861_toshiba_unsol_event,
15384 .init_hook = alc861_toshiba_automute,
15385 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015386 [ALC861_ASUS] = {
15387 .mixers = { alc861_asus_mixer },
15388 .init_verbs = { alc861_asus_init_verbs },
15389 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15390 .dac_nids = alc861_dac_nids,
15391 .dig_out_nid = ALC861_DIGOUT_NID,
15392 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
15393 .channel_mode = alc861_asus_modes,
15394 .need_dac_fix = 1,
15395 .hp_nid = 0x06,
15396 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15397 .adc_nids = alc861_adc_nids,
15398 .input_mux = &alc861_capture_source,
15399 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015400 [ALC861_ASUS_LAPTOP] = {
15401 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
15402 .init_verbs = { alc861_asus_init_verbs,
15403 alc861_asus_laptop_init_verbs },
15404 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15405 .dac_nids = alc861_dac_nids,
15406 .dig_out_nid = ALC861_DIGOUT_NID,
15407 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15408 .channel_mode = alc883_3ST_2ch_modes,
15409 .need_dac_fix = 1,
15410 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15411 .adc_nids = alc861_adc_nids,
15412 .input_mux = &alc861_capture_source,
15413 },
15414};
Kailang Yangdf694da2005-12-05 19:42:22 +010015415
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015416/* Pin config fixes */
15417enum {
15418 PINFIX_FSC_AMILO_PI1505,
15419};
15420
15421static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
15422 { 0x0b, 0x0221101f }, /* HP */
15423 { 0x0f, 0x90170310 }, /* speaker */
15424 { }
15425};
15426
15427static const struct alc_fixup alc861_fixups[] = {
15428 [PINFIX_FSC_AMILO_PI1505] = {
15429 .pins = alc861_fsc_amilo_pi1505_pinfix
15430 },
15431};
15432
15433static struct snd_pci_quirk alc861_fixup_tbl[] = {
15434 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
15435 {}
15436};
Kailang Yangdf694da2005-12-05 19:42:22 +010015437
15438static int patch_alc861(struct hda_codec *codec)
15439{
15440 struct alc_spec *spec;
15441 int board_config;
15442 int err;
15443
Robert P. J. Daydc041e02006-12-19 14:44:15 +010015444 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010015445 if (spec == NULL)
15446 return -ENOMEM;
15447
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015448 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015449
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015450 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
15451 alc861_models,
15452 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015453
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015454 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015455 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15456 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010015457 board_config = ALC861_AUTO;
15458 }
15459
Takashi Iwai7fa90e82010-04-12 08:49:00 +020015460 if (board_config == ALC861_AUTO)
15461 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015462
Kailang Yangdf694da2005-12-05 19:42:22 +010015463 if (board_config == ALC861_AUTO) {
15464 /* automatic parse from the BIOS config */
15465 err = alc861_parse_auto_config(codec);
15466 if (err < 0) {
15467 alc_free(codec);
15468 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015469 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015470 printk(KERN_INFO
15471 "hda_codec: Cannot set up configuration "
15472 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010015473 board_config = ALC861_3ST_DIG;
15474 }
15475 }
15476
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015477 err = snd_hda_attach_beep_device(codec, 0x23);
15478 if (err < 0) {
15479 alc_free(codec);
15480 return err;
15481 }
15482
Kailang Yangdf694da2005-12-05 19:42:22 +010015483 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015484 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015485
Kailang Yangdf694da2005-12-05 19:42:22 +010015486 spec->stream_analog_playback = &alc861_pcm_analog_playback;
15487 spec->stream_analog_capture = &alc861_pcm_analog_capture;
15488
Kailang Yangdf694da2005-12-05 19:42:22 +010015489 spec->stream_digital_playback = &alc861_pcm_digital_playback;
15490 spec->stream_digital_capture = &alc861_pcm_digital_capture;
15491
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010015492 if (!spec->cap_mixer)
15493 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015494 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
15495
Takashi Iwai2134ea42008-01-10 16:53:55 +010015496 spec->vmaster_nid = 0x03;
15497
Takashi Iwai7fa90e82010-04-12 08:49:00 +020015498 if (board_config == ALC861_AUTO)
15499 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
15500
Kailang Yangdf694da2005-12-05 19:42:22 +010015501 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050015502 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015503 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015504#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015505 spec->power_hook = alc_power_eapd;
15506#endif
15507 }
15508#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015509 if (!spec->loopback.amplist)
15510 spec->loopback.amplist = alc861_loopbacks;
15511#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015512
Kailang Yangdf694da2005-12-05 19:42:22 +010015513 return 0;
15514}
15515
15516/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015517 * ALC861-VD support
15518 *
15519 * Based on ALC882
15520 *
15521 * In addition, an independent DAC
15522 */
15523#define ALC861VD_DIGOUT_NID 0x06
15524
15525static hda_nid_t alc861vd_dac_nids[4] = {
15526 /* front, surr, clfe, side surr */
15527 0x02, 0x03, 0x04, 0x05
15528};
15529
15530/* dac_nids for ALC660vd are in a different order - according to
15531 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015532 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015533 * of ALC660vd codecs, but for now there is only 3stack mixer
15534 * - and it is the same as in 861vd.
15535 * adc_nids in ALC660vd are (is) the same as in 861vd
15536 */
15537static hda_nid_t alc660vd_dac_nids[3] = {
15538 /* front, rear, clfe, rear_surr */
15539 0x02, 0x04, 0x03
15540};
15541
15542static hda_nid_t alc861vd_adc_nids[1] = {
15543 /* ADC0 */
15544 0x09,
15545};
15546
Takashi Iwaie1406342008-02-11 18:32:32 +010015547static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
15548
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015549/* input MUX */
15550/* FIXME: should be a matrix-type input source selection */
15551static struct hda_input_mux alc861vd_capture_source = {
15552 .num_items = 4,
15553 .items = {
15554 { "Mic", 0x0 },
15555 { "Front Mic", 0x1 },
15556 { "Line", 0x2 },
15557 { "CD", 0x4 },
15558 },
15559};
15560
Kailang Yang272a5272007-05-14 11:00:38 +020015561static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010015562 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020015563 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010015564 { "Ext Mic", 0x0 },
15565 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020015566 },
15567};
15568
Kailang Yangd1a991a2007-08-15 16:21:59 +020015569static struct hda_input_mux alc861vd_hp_capture_source = {
15570 .num_items = 2,
15571 .items = {
15572 { "Front Mic", 0x0 },
15573 { "ATAPI Mic", 0x1 },
15574 },
15575};
15576
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015577/*
15578 * 2ch mode
15579 */
15580static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
15581 { 2, NULL }
15582};
15583
15584/*
15585 * 6ch mode
15586 */
15587static struct hda_verb alc861vd_6stack_ch6_init[] = {
15588 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15589 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15590 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15591 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15592 { } /* end */
15593};
15594
15595/*
15596 * 8ch mode
15597 */
15598static struct hda_verb alc861vd_6stack_ch8_init[] = {
15599 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15600 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15601 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15602 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15603 { } /* end */
15604};
15605
15606static struct hda_channel_mode alc861vd_6stack_modes[2] = {
15607 { 6, alc861vd_6stack_ch6_init },
15608 { 8, alc861vd_6stack_ch8_init },
15609};
15610
15611static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
15612 {
15613 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15614 .name = "Channel Mode",
15615 .info = alc_ch_mode_info,
15616 .get = alc_ch_mode_get,
15617 .put = alc_ch_mode_put,
15618 },
15619 { } /* end */
15620};
15621
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015622/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15623 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15624 */
15625static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
15626 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15627 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15628
15629 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15630 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
15631
15632 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
15633 HDA_OUTPUT),
15634 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
15635 HDA_OUTPUT),
15636 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
15637 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
15638
15639 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
15640 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
15641
15642 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15643
15644 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15645 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15646 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15647
15648 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15649 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15650 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15651
15652 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15653 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15654
15655 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15656 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15657
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015658 { } /* end */
15659};
15660
15661static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
15662 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15663 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15664
15665 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15666
15667 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15668 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15669 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15670
15671 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15672 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15673 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15674
15675 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15676 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15677
15678 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15679 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15680
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015681 { } /* end */
15682};
15683
Kailang Yangbdd148a2007-05-08 15:19:08 +020015684static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
15685 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15686 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
15687 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15688
15689 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15690
15691 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15692 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15693 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15694
15695 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15696 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15697 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15698
15699 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15700 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15701
15702 { } /* end */
15703};
15704
Tobin Davisb419f342008-03-07 11:57:51 +010015705/* Pin assignment: Speaker=0x14, HP = 0x15,
15706 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015707 */
15708static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015709 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15710 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015711 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15712 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015713 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15714 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15715 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15716 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15717 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15718 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015719 { } /* end */
15720};
15721
Kailang Yangd1a991a2007-08-15 16:21:59 +020015722/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15723 * Front Mic=0x18, ATAPI Mic = 0x19,
15724 */
15725static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15726 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15727 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15728 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15729 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15730 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15731 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15732 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15733 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015734
Kailang Yangd1a991a2007-08-15 16:21:59 +020015735 { } /* end */
15736};
15737
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015738/*
15739 * generic initialization of ADC, input mixers and output mixers
15740 */
15741static struct hda_verb alc861vd_volume_init_verbs[] = {
15742 /*
15743 * Unmute ADC0 and set the default input to mic-in
15744 */
15745 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15746 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15747
15748 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15749 * the analog-loopback mixer widget
15750 */
15751 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015752 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15753 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15754 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15755 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15756 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015757
15758 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015759 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15760 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15761 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015762 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015763
15764 /*
15765 * Set up output mixers (0x02 - 0x05)
15766 */
15767 /* set vol=0 to output mixers */
15768 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15769 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15770 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15771 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15772
15773 /* set up input amps for analog loopback */
15774 /* Amp Indices: DAC = 0, mixer = 1 */
15775 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15776 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15777 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15778 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15779 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15780 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15781 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15782 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15783
15784 { }
15785};
15786
15787/*
15788 * 3-stack pin configuration:
15789 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15790 */
15791static struct hda_verb alc861vd_3stack_init_verbs[] = {
15792 /*
15793 * Set pin mode and muting
15794 */
15795 /* set front pin widgets 0x14 for output */
15796 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15797 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15798 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15799
15800 /* Mic (rear) pin: input vref at 80% */
15801 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15802 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15803 /* Front Mic pin: input vref at 80% */
15804 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15805 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15806 /* Line In pin: input */
15807 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15808 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15809 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15810 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15811 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15812 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15813 /* CD pin widget for input */
15814 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15815
15816 { }
15817};
15818
15819/*
15820 * 6-stack pin configuration:
15821 */
15822static struct hda_verb alc861vd_6stack_init_verbs[] = {
15823 /*
15824 * Set pin mode and muting
15825 */
15826 /* set front pin widgets 0x14 for output */
15827 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15828 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15829 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15830
15831 /* Rear Pin: output 1 (0x0d) */
15832 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15833 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15834 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15835 /* CLFE Pin: output 2 (0x0e) */
15836 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15837 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15838 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15839 /* Side Pin: output 3 (0x0f) */
15840 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15841 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15842 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15843
15844 /* Mic (rear) pin: input vref at 80% */
15845 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15846 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15847 /* Front Mic pin: input vref at 80% */
15848 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15849 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15850 /* Line In pin: input */
15851 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15852 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15853 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15854 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15855 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15856 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15857 /* CD pin widget for input */
15858 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15859
15860 { }
15861};
15862
Kailang Yangbdd148a2007-05-08 15:19:08 +020015863static struct hda_verb alc861vd_eapd_verbs[] = {
15864 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15865 { }
15866};
15867
Kailang Yangf9423e72008-05-27 12:32:25 +020015868static struct hda_verb alc660vd_eapd_verbs[] = {
15869 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15870 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15871 { }
15872};
15873
Kailang Yangbdd148a2007-05-08 15:19:08 +020015874static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15875 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15876 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15877 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15878 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015879 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015880 {}
15881};
15882
Kailang Yangbdd148a2007-05-08 15:19:08 +020015883static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15884{
15885 unsigned int present;
15886 unsigned char bits;
15887
Wu Fengguang864f92b2009-11-18 12:38:02 +080015888 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020015889 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080015890
Takashi Iwai47fd8302007-08-10 17:11:07 +020015891 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15892 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015893}
15894
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015895static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015896{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015897 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015898 spec->autocfg.hp_pins[0] = 0x1b;
15899 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015900}
15901
15902static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15903{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015904 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015905 alc861vd_lenovo_mic_automute(codec);
15906}
15907
15908static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15909 unsigned int res)
15910{
15911 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015912 case ALC880_MIC_EVENT:
15913 alc861vd_lenovo_mic_automute(codec);
15914 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015915 default:
15916 alc_automute_amp_unsol_event(codec, res);
15917 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015918 }
15919}
15920
Kailang Yang272a5272007-05-14 11:00:38 +020015921static struct hda_verb alc861vd_dallas_verbs[] = {
15922 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15923 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15924 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15925 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15926
15927 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15928 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15929 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15930 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15931 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15932 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15933 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15934 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015935
Kailang Yang272a5272007-05-14 11:00:38 +020015936 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15937 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15938 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15939 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15940 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15941 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15942 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15943 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15944
15945 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15946 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15947 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15948 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15949 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15950 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15951 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15952 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15953
15954 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15955 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15956 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15957 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15958
15959 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015960 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015961 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15962
15963 { } /* end */
15964};
15965
15966/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015967static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015968{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015969 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015970
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015971 spec->autocfg.hp_pins[0] = 0x15;
15972 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015973}
15974
Takashi Iwaicb53c622007-08-10 17:21:45 +020015975#ifdef CONFIG_SND_HDA_POWER_SAVE
15976#define alc861vd_loopbacks alc880_loopbacks
15977#endif
15978
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015979/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015980#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15981#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15982#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15983#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15984
15985/*
15986 * configuration and preset
15987 */
15988static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15989 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015990 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015991 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015992 [ALC861VD_3ST] = "3stack",
15993 [ALC861VD_3ST_DIG] = "3stack-digout",
15994 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015995 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015996 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015997 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015998 [ALC861VD_AUTO] = "auto",
15999};
16000
16001static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016002 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16003 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016004 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016005 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016006 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016007 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016008 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016009 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016010 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016011 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016012 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016013 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016014 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016015 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016016 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016017 {}
16018};
16019
16020static struct alc_config_preset alc861vd_presets[] = {
16021 [ALC660VD_3ST] = {
16022 .mixers = { alc861vd_3st_mixer },
16023 .init_verbs = { alc861vd_volume_init_verbs,
16024 alc861vd_3stack_init_verbs },
16025 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16026 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016027 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16028 .channel_mode = alc861vd_3stack_2ch_modes,
16029 .input_mux = &alc861vd_capture_source,
16030 },
Mike Crash6963f842007-06-25 12:12:51 +020016031 [ALC660VD_3ST_DIG] = {
16032 .mixers = { alc861vd_3st_mixer },
16033 .init_verbs = { alc861vd_volume_init_verbs,
16034 alc861vd_3stack_init_verbs },
16035 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16036 .dac_nids = alc660vd_dac_nids,
16037 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016038 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16039 .channel_mode = alc861vd_3stack_2ch_modes,
16040 .input_mux = &alc861vd_capture_source,
16041 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016042 [ALC861VD_3ST] = {
16043 .mixers = { alc861vd_3st_mixer },
16044 .init_verbs = { alc861vd_volume_init_verbs,
16045 alc861vd_3stack_init_verbs },
16046 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16047 .dac_nids = alc861vd_dac_nids,
16048 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16049 .channel_mode = alc861vd_3stack_2ch_modes,
16050 .input_mux = &alc861vd_capture_source,
16051 },
16052 [ALC861VD_3ST_DIG] = {
16053 .mixers = { alc861vd_3st_mixer },
16054 .init_verbs = { alc861vd_volume_init_verbs,
16055 alc861vd_3stack_init_verbs },
16056 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16057 .dac_nids = alc861vd_dac_nids,
16058 .dig_out_nid = ALC861VD_DIGOUT_NID,
16059 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16060 .channel_mode = alc861vd_3stack_2ch_modes,
16061 .input_mux = &alc861vd_capture_source,
16062 },
16063 [ALC861VD_6ST_DIG] = {
16064 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16065 .init_verbs = { alc861vd_volume_init_verbs,
16066 alc861vd_6stack_init_verbs },
16067 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16068 .dac_nids = alc861vd_dac_nids,
16069 .dig_out_nid = ALC861VD_DIGOUT_NID,
16070 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16071 .channel_mode = alc861vd_6stack_modes,
16072 .input_mux = &alc861vd_capture_source,
16073 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016074 [ALC861VD_LENOVO] = {
16075 .mixers = { alc861vd_lenovo_mixer },
16076 .init_verbs = { alc861vd_volume_init_verbs,
16077 alc861vd_3stack_init_verbs,
16078 alc861vd_eapd_verbs,
16079 alc861vd_lenovo_unsol_verbs },
16080 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16081 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016082 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16083 .channel_mode = alc861vd_3stack_2ch_modes,
16084 .input_mux = &alc861vd_capture_source,
16085 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016086 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016087 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016088 },
Kailang Yang272a5272007-05-14 11:00:38 +020016089 [ALC861VD_DALLAS] = {
16090 .mixers = { alc861vd_dallas_mixer },
16091 .init_verbs = { alc861vd_dallas_verbs },
16092 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16093 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016094 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16095 .channel_mode = alc861vd_3stack_2ch_modes,
16096 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016097 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016098 .setup = alc861vd_dallas_setup,
16099 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016100 },
16101 [ALC861VD_HP] = {
16102 .mixers = { alc861vd_hp_mixer },
16103 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16104 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16105 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016106 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016107 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16108 .channel_mode = alc861vd_3stack_2ch_modes,
16109 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016110 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016111 .setup = alc861vd_dallas_setup,
16112 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016113 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016114 [ALC660VD_ASUS_V1S] = {
16115 .mixers = { alc861vd_lenovo_mixer },
16116 .init_verbs = { alc861vd_volume_init_verbs,
16117 alc861vd_3stack_init_verbs,
16118 alc861vd_eapd_verbs,
16119 alc861vd_lenovo_unsol_verbs },
16120 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16121 .dac_nids = alc660vd_dac_nids,
16122 .dig_out_nid = ALC861VD_DIGOUT_NID,
16123 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16124 .channel_mode = alc861vd_3stack_2ch_modes,
16125 .input_mux = &alc861vd_capture_source,
16126 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016127 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016128 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016129 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016130};
16131
16132/*
16133 * BIOS auto configuration
16134 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016135static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16136 const struct auto_pin_cfg *cfg)
16137{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016138 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016139}
16140
16141
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016142static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16143 hda_nid_t nid, int pin_type, int dac_idx)
16144{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016145 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016146}
16147
16148static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16149{
16150 struct alc_spec *spec = codec->spec;
16151 int i;
16152
16153 for (i = 0; i <= HDA_SIDE; i++) {
16154 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016155 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016156 if (nid)
16157 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016158 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016159 }
16160}
16161
16162
16163static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16164{
16165 struct alc_spec *spec = codec->spec;
16166 hda_nid_t pin;
16167
16168 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016169 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016170 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016171 pin = spec->autocfg.speaker_pins[0];
16172 if (pin)
16173 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016174}
16175
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016176#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16177
16178static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16179{
16180 struct alc_spec *spec = codec->spec;
16181 int i;
16182
16183 for (i = 0; i < AUTO_PIN_LAST; i++) {
16184 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020016185 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016186 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016187 if (nid != ALC861VD_PIN_CD_NID &&
16188 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016189 snd_hda_codec_write(codec, nid, 0,
16190 AC_VERB_SET_AMP_GAIN_MUTE,
16191 AMP_OUT_MUTE);
16192 }
16193 }
16194}
16195
Takashi Iwaif511b012008-08-15 16:46:42 +020016196#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16197
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016198#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16199#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16200
16201/* add playback controls from the parsed DAC table */
16202/* Based on ALC880 version. But ALC861VD has separate,
16203 * different NIDs for mute/unmute switch and volume control */
16204static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16205 const struct auto_pin_cfg *cfg)
16206{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016207 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16208 hda_nid_t nid_v, nid_s;
16209 int i, err;
16210
16211 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016212 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016213 continue;
16214 nid_v = alc861vd_idx_to_mixer_vol(
16215 alc880_dac_to_idx(
16216 spec->multiout.dac_nids[i]));
16217 nid_s = alc861vd_idx_to_mixer_switch(
16218 alc880_dac_to_idx(
16219 spec->multiout.dac_nids[i]));
16220
16221 if (i == 2) {
16222 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016223 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16224 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016225 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16226 HDA_OUTPUT));
16227 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016228 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016229 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16230 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016231 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16232 HDA_OUTPUT));
16233 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016234 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016235 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16236 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016237 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16238 HDA_INPUT));
16239 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016240 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016241 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16242 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016243 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16244 HDA_INPUT));
16245 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016246 return err;
16247 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016248 const char *pfx;
16249 if (cfg->line_outs == 1 &&
16250 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16251 if (!cfg->hp_pins)
16252 pfx = "Speaker";
16253 else
16254 pfx = "PCM";
16255 } else
16256 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016257 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016258 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16259 HDA_OUTPUT));
16260 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016261 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016262 if (cfg->line_outs == 1 &&
16263 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16264 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016265 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016266 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016267 HDA_INPUT));
16268 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016269 return err;
16270 }
16271 }
16272 return 0;
16273}
16274
16275/* add playback controls for speaker and HP outputs */
16276/* Based on ALC880 version. But ALC861VD has separate,
16277 * different NIDs for mute/unmute switch and volume control */
16278static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16279 hda_nid_t pin, const char *pfx)
16280{
16281 hda_nid_t nid_v, nid_s;
16282 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016283
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016284 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016285 return 0;
16286
16287 if (alc880_is_fixed_pin(pin)) {
16288 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16289 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016290 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016291 spec->multiout.hp_nid = nid_v;
16292 else
16293 spec->multiout.extra_out_nid[0] = nid_v;
16294 /* control HP volume/switch on the output mixer amp */
16295 nid_v = alc861vd_idx_to_mixer_vol(
16296 alc880_fixed_pin_idx(pin));
16297 nid_s = alc861vd_idx_to_mixer_switch(
16298 alc880_fixed_pin_idx(pin));
16299
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016300 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016301 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16302 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016303 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016304 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016305 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16306 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016307 return err;
16308 } else if (alc880_is_multi_pin(pin)) {
16309 /* set manual connection */
16310 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016311 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016312 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16313 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016314 return err;
16315 }
16316 return 0;
16317}
16318
16319/* parse the BIOS configuration and set up the alc_spec
16320 * return 1 if successful, 0 if the proper config is not found,
16321 * or a negative error code
16322 * Based on ALC880 version - had to change it to override
16323 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16324static int alc861vd_parse_auto_config(struct hda_codec *codec)
16325{
16326 struct alc_spec *spec = codec->spec;
16327 int err;
16328 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16329
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016330 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16331 alc861vd_ignore);
16332 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016333 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016334 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016335 return 0; /* can't find valid BIOS pin config */
16336
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016337 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16338 if (err < 0)
16339 return err;
16340 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
16341 if (err < 0)
16342 return err;
16343 err = alc861vd_auto_create_extra_out(spec,
16344 spec->autocfg.speaker_pins[0],
16345 "Speaker");
16346 if (err < 0)
16347 return err;
16348 err = alc861vd_auto_create_extra_out(spec,
16349 spec->autocfg.hp_pins[0],
16350 "Headphone");
16351 if (err < 0)
16352 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016353 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016354 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016355 return err;
16356
16357 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16358
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016359 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016360 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
16361
Takashi Iwai603c4012008-07-30 15:01:44 +020016362 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016363 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016364
Takashi Iwaid88897e2008-10-31 15:01:37 +010016365 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016366
16367 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016368 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016369
Takashi Iwai776e1842007-08-29 15:07:11 +020016370 err = alc_auto_add_mic_boost(codec);
16371 if (err < 0)
16372 return err;
16373
Kailang Yang6227cdc2010-02-25 08:36:52 +010016374 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016375
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016376 return 1;
16377}
16378
16379/* additional initialization for auto-configuration model */
16380static void alc861vd_auto_init(struct hda_codec *codec)
16381{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016382 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016383 alc861vd_auto_init_multi_out(codec);
16384 alc861vd_auto_init_hp_out(codec);
16385 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016386 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016387 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016388 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016389}
16390
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016391enum {
16392 ALC660VD_FIX_ASUS_GPIO1
16393};
16394
16395/* reset GPIO1 */
16396static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
16397 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
16398 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
16399 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
16400 { }
16401};
16402
16403static const struct alc_fixup alc861vd_fixups[] = {
16404 [ALC660VD_FIX_ASUS_GPIO1] = {
16405 .verbs = alc660vd_fix_asus_gpio1_verbs,
16406 },
16407};
16408
16409static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
16410 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
16411 {}
16412};
16413
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016414static int patch_alc861vd(struct hda_codec *codec)
16415{
16416 struct alc_spec *spec;
16417 int err, board_config;
16418
16419 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16420 if (spec == NULL)
16421 return -ENOMEM;
16422
16423 codec->spec = spec;
16424
16425 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
16426 alc861vd_models,
16427 alc861vd_cfg_tbl);
16428
16429 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016430 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16431 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016432 board_config = ALC861VD_AUTO;
16433 }
16434
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016435 if (board_config == ALC861VD_AUTO)
16436 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016437
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016438 if (board_config == ALC861VD_AUTO) {
16439 /* automatic parse from the BIOS config */
16440 err = alc861vd_parse_auto_config(codec);
16441 if (err < 0) {
16442 alc_free(codec);
16443 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016444 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016445 printk(KERN_INFO
16446 "hda_codec: Cannot set up configuration "
16447 "from BIOS. Using base mode...\n");
16448 board_config = ALC861VD_3ST;
16449 }
16450 }
16451
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016452 err = snd_hda_attach_beep_device(codec, 0x23);
16453 if (err < 0) {
16454 alc_free(codec);
16455 return err;
16456 }
16457
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016458 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016459 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016460
Kailang Yang2f893282008-05-27 12:14:47 +020016461 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020016462 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010016463 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020016464 }
16465
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016466 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
16467 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
16468
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016469 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
16470 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16471
Takashi Iwaidd704692009-08-11 08:45:11 +020016472 if (!spec->adc_nids) {
16473 spec->adc_nids = alc861vd_adc_nids;
16474 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
16475 }
16476 if (!spec->capsrc_nids)
16477 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016478
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016479 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016480 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016481
Takashi Iwai2134ea42008-01-10 16:53:55 +010016482 spec->vmaster_nid = 0x02;
16483
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016484 if (board_config == ALC861VD_AUTO)
16485 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
16486
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016487 codec->patch_ops = alc_patch_ops;
16488
16489 if (board_config == ALC861VD_AUTO)
16490 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016491#ifdef CONFIG_SND_HDA_POWER_SAVE
16492 if (!spec->loopback.amplist)
16493 spec->loopback.amplist = alc861vd_loopbacks;
16494#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016495
16496 return 0;
16497}
16498
16499/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016500 * ALC662 support
16501 *
16502 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
16503 * configuration. Each pin widget can choose any input DACs and a mixer.
16504 * Each ADC is connected from a mixer of all inputs. This makes possible
16505 * 6-channel independent captures.
16506 *
16507 * In addition, an independent DAC for the multi-playback (not used in this
16508 * driver yet).
16509 */
16510#define ALC662_DIGOUT_NID 0x06
16511#define ALC662_DIGIN_NID 0x0a
16512
16513static hda_nid_t alc662_dac_nids[4] = {
16514 /* front, rear, clfe, rear_surr */
16515 0x02, 0x03, 0x04
16516};
16517
Kailang Yang622e84c2009-04-21 07:39:04 +020016518static hda_nid_t alc272_dac_nids[2] = {
16519 0x02, 0x03
16520};
16521
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016522static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016523 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016524 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016525};
Takashi Iwaie1406342008-02-11 18:32:32 +010016526
Kailang Yang622e84c2009-04-21 07:39:04 +020016527static hda_nid_t alc272_adc_nids[1] = {
16528 /* ADC1-2 */
16529 0x08,
16530};
16531
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016532static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016533static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
16534
Takashi Iwaie1406342008-02-11 18:32:32 +010016535
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016536/* input MUX */
16537/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016538static struct hda_input_mux alc662_capture_source = {
16539 .num_items = 4,
16540 .items = {
16541 { "Mic", 0x0 },
16542 { "Front Mic", 0x1 },
16543 { "Line", 0x2 },
16544 { "CD", 0x4 },
16545 },
16546};
16547
16548static struct hda_input_mux alc662_lenovo_101e_capture_source = {
16549 .num_items = 2,
16550 .items = {
16551 { "Mic", 0x1 },
16552 { "Line", 0x2 },
16553 },
16554};
Kailang Yang291702f2007-10-16 14:28:03 +020016555
Kailang Yang6dda9f42008-05-27 12:05:31 +020016556static struct hda_input_mux alc663_capture_source = {
16557 .num_items = 3,
16558 .items = {
16559 { "Mic", 0x0 },
16560 { "Front Mic", 0x1 },
16561 { "Line", 0x2 },
16562 },
16563};
16564
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016565#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020016566static struct hda_input_mux alc272_nc10_capture_source = {
16567 .num_items = 16,
16568 .items = {
16569 { "Autoselect Mic", 0x0 },
16570 { "Internal Mic", 0x1 },
16571 { "In-0x02", 0x2 },
16572 { "In-0x03", 0x3 },
16573 { "In-0x04", 0x4 },
16574 { "In-0x05", 0x5 },
16575 { "In-0x06", 0x6 },
16576 { "In-0x07", 0x7 },
16577 { "In-0x08", 0x8 },
16578 { "In-0x09", 0x9 },
16579 { "In-0x0a", 0x0a },
16580 { "In-0x0b", 0x0b },
16581 { "In-0x0c", 0x0c },
16582 { "In-0x0d", 0x0d },
16583 { "In-0x0e", 0x0e },
16584 { "In-0x0f", 0x0f },
16585 },
16586};
16587#endif
16588
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016589/*
16590 * 2ch mode
16591 */
16592static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
16593 { 2, NULL }
16594};
16595
16596/*
16597 * 2ch mode
16598 */
16599static struct hda_verb alc662_3ST_ch2_init[] = {
16600 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
16601 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16602 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
16603 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16604 { } /* end */
16605};
16606
16607/*
16608 * 6ch mode
16609 */
16610static struct hda_verb alc662_3ST_ch6_init[] = {
16611 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16612 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16613 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
16614 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16615 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16616 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
16617 { } /* end */
16618};
16619
16620static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
16621 { 2, alc662_3ST_ch2_init },
16622 { 6, alc662_3ST_ch6_init },
16623};
16624
16625/*
16626 * 2ch mode
16627 */
16628static struct hda_verb alc662_sixstack_ch6_init[] = {
16629 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16630 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16631 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16632 { } /* end */
16633};
16634
16635/*
16636 * 6ch mode
16637 */
16638static struct hda_verb alc662_sixstack_ch8_init[] = {
16639 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16640 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16641 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16642 { } /* end */
16643};
16644
16645static struct hda_channel_mode alc662_5stack_modes[2] = {
16646 { 2, alc662_sixstack_ch6_init },
16647 { 6, alc662_sixstack_ch8_init },
16648};
16649
16650/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16651 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16652 */
16653
16654static struct snd_kcontrol_new alc662_base_mixer[] = {
16655 /* output mixer control */
16656 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016657 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016658 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016659 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016660 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16661 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016662 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16663 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016664 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16665
16666 /*Input mixer control */
16667 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
16668 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
16669 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
16670 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
16671 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
16672 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
16673 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
16674 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016675 { } /* end */
16676};
16677
16678static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
16679 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016680 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016681 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16682 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16683 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16684 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16685 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16686 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16687 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16688 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16689 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016690 { } /* end */
16691};
16692
16693static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
16694 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016695 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016696 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016697 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016698 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16699 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016700 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16701 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016702 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16703 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16704 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16705 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16706 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16709 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16710 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016711 { } /* end */
16712};
16713
16714static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16715 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16716 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016717 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16718 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016719 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16720 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16721 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16722 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16723 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016724 { } /* end */
16725};
16726
Kailang Yang291702f2007-10-16 14:28:03 +020016727static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016728 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16729 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016730
16731 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16732 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16733 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16734
16735 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16736 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16737 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16738 { } /* end */
16739};
16740
Kailang Yang8c427222008-01-10 13:03:59 +010016741static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016742 ALC262_HIPPO_MASTER_SWITCH,
16743 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016744 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016745 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16746 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016747 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16748 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16749 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16750 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16751 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16752 { } /* end */
16753};
16754
Kailang Yangf1d4e282008-08-26 14:03:29 +020016755static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16756 .ops = &snd_hda_bind_vol,
16757 .values = {
16758 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16759 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16760 0
16761 },
16762};
16763
16764static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16765 .ops = &snd_hda_bind_sw,
16766 .values = {
16767 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16768 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16769 0
16770 },
16771};
16772
Kailang Yang6dda9f42008-05-27 12:05:31 +020016773static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016774 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16775 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16776 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16777 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16778 { } /* end */
16779};
16780
16781static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16782 .ops = &snd_hda_bind_sw,
16783 .values = {
16784 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16785 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16786 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16787 0
16788 },
16789};
16790
16791static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16792 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16793 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16794 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16795 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16796 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16797 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16798
16799 { } /* end */
16800};
16801
16802static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16803 .ops = &snd_hda_bind_sw,
16804 .values = {
16805 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16806 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16807 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16808 0
16809 },
16810};
16811
16812static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16813 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16814 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16815 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16816 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16817 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16818 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16819 { } /* end */
16820};
16821
16822static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016823 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16824 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016825 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16826 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16827 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16828 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16829 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16830 { } /* end */
16831};
16832
16833static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16834 .ops = &snd_hda_bind_vol,
16835 .values = {
16836 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16837 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16838 0
16839 },
16840};
16841
16842static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16843 .ops = &snd_hda_bind_sw,
16844 .values = {
16845 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16846 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16847 0
16848 },
16849};
16850
16851static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16852 HDA_BIND_VOL("Master Playback Volume",
16853 &alc663_asus_two_bind_master_vol),
16854 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16855 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016856 HDA_CODEC_MUTE("Headphone 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),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016859 { } /* end */
16860};
16861
16862static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16863 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16864 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16865 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16866 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16867 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16868 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016869 { } /* end */
16870};
16871
16872static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16873 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16874 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16875 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16876 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16877 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16878
16879 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16880 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16881 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16882 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16883 { } /* end */
16884};
16885
16886static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16887 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16888 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16889 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16890
16891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16893 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16894 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16895 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16896 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16897 { } /* end */
16898};
16899
Kailang Yangebb83ee2009-12-17 12:23:00 +010016900static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
16901 .ops = &snd_hda_bind_sw,
16902 .values = {
16903 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16904 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16905 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16906 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16907 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16908 0
16909 },
16910};
16911
16912static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
16913 .ops = &snd_hda_bind_sw,
16914 .values = {
16915 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16916 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16917 0
16918 },
16919};
16920
16921static struct snd_kcontrol_new alc663_mode7_mixer[] = {
16922 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16923 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16924 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16925 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16926 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16927 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16928 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16929 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16930 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16931 { } /* end */
16932};
16933
16934static struct snd_kcontrol_new alc663_mode8_mixer[] = {
16935 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16936 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16937 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16938 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16939 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16940 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16941 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16942 { } /* end */
16943};
16944
16945
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016946static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16947 {
16948 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16949 .name = "Channel Mode",
16950 .info = alc_ch_mode_info,
16951 .get = alc_ch_mode_get,
16952 .put = alc_ch_mode_put,
16953 },
16954 { } /* end */
16955};
16956
16957static struct hda_verb alc662_init_verbs[] = {
16958 /* ADC: mute amp left and right */
16959 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16960 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016961
Kailang Yangb60dd392007-09-20 12:50:29 +020016962 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16963 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16964 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16965 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16966 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16967 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016968
16969 /* Front Pin: output 0 (0x0c) */
16970 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16971 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16972
16973 /* Rear Pin: output 1 (0x0d) */
16974 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16975 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16976
16977 /* CLFE Pin: output 2 (0x0e) */
16978 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16979 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16980
16981 /* Mic (rear) pin: input vref at 80% */
16982 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16983 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16984 /* Front Mic pin: input vref at 80% */
16985 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16986 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16987 /* Line In pin: input */
16988 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16989 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16990 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16991 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16992 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16993 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16994 /* CD pin widget for input */
16995 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16996
16997 /* FIXME: use matrix-type input source selection */
16998 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16999 /* Input mixer */
17000 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017001 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017002
17003 /* always trun on EAPD */
17004 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17005 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17006
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017007 { }
17008};
17009
Kailang Yangcec27c82010-02-04 14:18:18 +010017010static struct hda_verb alc663_init_verbs[] = {
17011 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17012 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17013 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17014 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17015 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17016 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17017 { }
17018};
17019
17020static struct hda_verb alc272_init_verbs[] = {
17021 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17022 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17023 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17024 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17025 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17026 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17027 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17028 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17029 { }
17030};
17031
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017032static struct hda_verb alc662_sue_init_verbs[] = {
17033 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17034 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017035 {}
17036};
17037
17038static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17039 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17040 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17041 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017042};
17043
Kailang Yang8c427222008-01-10 13:03:59 +010017044/* Set Unsolicited Event*/
17045static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17046 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17047 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17048 {}
17049};
17050
Kailang Yang6dda9f42008-05-27 12:05:31 +020017051static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017052 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17053 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017054 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17055 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017056 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17057 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17058 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017059 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17060 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17061 {}
17062};
17063
Kailang Yangf1d4e282008-08-26 14:03:29 +020017064static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17065 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17066 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17067 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17068 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17069 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17070 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17071 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17072 {}
17073};
17074
17075static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17076 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17077 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17078 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17079 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17080 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17081 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17082 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17083 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17084 {}
17085};
17086
17087static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17088 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17089 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17090 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17091 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17092 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17093 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17094 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17095 {}
17096};
17097
17098static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
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, 0x0}, /* Headphone */
17103 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17104 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17105 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17107 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17108 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17109 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17110 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17111 {}
17112};
17113
17114static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17115 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17116 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17117 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17118 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17119 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17120 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17121 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17122 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17123 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17124 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17125 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17126 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17127 {}
17128};
17129
Kailang Yang6dda9f42008-05-27 12:05:31 +020017130static struct hda_verb alc663_g71v_init_verbs[] = {
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}, */ /* Headphone */
17134
17135 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17136 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17137 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17138
17139 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17140 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17141 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17142 {}
17143};
17144
17145static struct hda_verb alc663_g50v_init_verbs[] = {
17146 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17147 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17148 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17149
17150 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17151 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17152 {}
17153};
17154
Kailang Yangf1d4e282008-08-26 14:03:29 +020017155static struct hda_verb alc662_ecs_init_verbs[] = {
17156 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17157 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17158 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17159 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17160 {}
17161};
17162
Kailang Yang622e84c2009-04-21 07:39:04 +020017163static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17164 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17165 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17166 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17167 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17168 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17169 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17170 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17171 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17172 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17173 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17174 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17175 {}
17176};
17177
17178static struct hda_verb alc272_dell_init_verbs[] = {
17179 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17180 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17181 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17182 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17183 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17184 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17185 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17186 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17187 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17188 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17189 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17190 {}
17191};
17192
Kailang Yangebb83ee2009-12-17 12:23:00 +010017193static struct hda_verb alc663_mode7_init_verbs[] = {
17194 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17195 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17196 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17197 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17198 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17199 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17200 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17201 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17202 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17203 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17204 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17205 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17206 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17207 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17208 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17209 {}
17210};
17211
17212static struct hda_verb alc663_mode8_init_verbs[] = {
17213 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17214 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17215 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17216 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17217 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17218 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17219 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17220 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17221 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17222 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17223 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17224 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17225 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17226 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17227 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17228 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17229 {}
17230};
17231
Kailang Yangf1d4e282008-08-26 14:03:29 +020017232static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17233 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17234 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17235 { } /* end */
17236};
17237
Kailang Yang622e84c2009-04-21 07:39:04 +020017238static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17239 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17240 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17241 { } /* end */
17242};
17243
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017244static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17245{
17246 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017247 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017248
Wu Fengguang864f92b2009-11-18 12:38:02 +080017249 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017250 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017251
Takashi Iwai47fd8302007-08-10 17:11:07 +020017252 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17253 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017254}
17255
17256static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17257{
17258 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017259 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017260
Wu Fengguang864f92b2009-11-18 12:38:02 +080017261 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017262 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017263
Takashi Iwai47fd8302007-08-10 17:11:07 +020017264 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17265 HDA_AMP_MUTE, bits);
17266 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17267 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017268}
17269
17270static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17271 unsigned int res)
17272{
17273 if ((res >> 26) == ALC880_HP_EVENT)
17274 alc662_lenovo_101e_all_automute(codec);
17275 if ((res >> 26) == ALC880_FRONT_EVENT)
17276 alc662_lenovo_101e_ispeaker_automute(codec);
17277}
17278
Kailang Yang291702f2007-10-16 14:28:03 +020017279/* unsolicited event for HP jack sensing */
17280static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17281 unsigned int res)
17282{
Kailang Yang291702f2007-10-16 14:28:03 +020017283 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017284 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017285 else
17286 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017287}
17288
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017289static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017290{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017291 struct alc_spec *spec = codec->spec;
17292
17293 alc262_hippo1_setup(codec);
17294 spec->ext_mic.pin = 0x18;
17295 spec->ext_mic.mux_idx = 0;
17296 spec->int_mic.pin = 0x19;
17297 spec->int_mic.mux_idx = 1;
17298 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017299}
17300
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017301static void alc662_eeepc_inithook(struct hda_codec *codec)
17302{
17303 alc262_hippo_automute(codec);
17304 alc_mic_automute(codec);
17305}
17306
17307static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017308{
Takashi Iwai42171c12009-05-08 14:11:43 +020017309 struct alc_spec *spec = codec->spec;
17310
17311 spec->autocfg.hp_pins[0] = 0x14;
17312 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017313}
17314
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017315#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17316
Kailang Yang6dda9f42008-05-27 12:05:31 +020017317static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17318{
17319 unsigned int present;
17320 unsigned char bits;
17321
Wu Fengguang864f92b2009-11-18 12:38:02 +080017322 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017323 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017324 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017325 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017326 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017327 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017328}
17329
17330static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17331{
17332 unsigned int present;
17333 unsigned char bits;
17334
Wu Fengguang864f92b2009-11-18 12:38:02 +080017335 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017336 bits = present ? HDA_AMP_MUTE : 0;
17337 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017338 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017339 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017340 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017341 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017342 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017343 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017344 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017345}
17346
17347static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
17348{
17349 unsigned int present;
17350 unsigned char bits;
17351
Wu Fengguang864f92b2009-11-18 12:38:02 +080017352 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017353 bits = present ? HDA_AMP_MUTE : 0;
17354 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017355 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017356 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017357 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017358 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017359 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017360 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017361 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017362}
17363
17364static void alc662_f5z_speaker_automute(struct hda_codec *codec)
17365{
17366 unsigned int present;
17367 unsigned char bits;
17368
Wu Fengguang864f92b2009-11-18 12:38:02 +080017369 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017370 bits = present ? 0 : PIN_OUT;
17371 snd_hda_codec_write(codec, 0x14, 0,
17372 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
17373}
17374
17375static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
17376{
17377 unsigned int present1, present2;
17378
Wu Fengguang864f92b2009-11-18 12:38:02 +080017379 present1 = snd_hda_jack_detect(codec, 0x21);
17380 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017381
17382 if (present1 || present2) {
17383 snd_hda_codec_write_cache(codec, 0x14, 0,
17384 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17385 } else {
17386 snd_hda_codec_write_cache(codec, 0x14, 0,
17387 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17388 }
17389}
17390
17391static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
17392{
17393 unsigned int present1, present2;
17394
Wu Fengguang864f92b2009-11-18 12:38:02 +080017395 present1 = snd_hda_jack_detect(codec, 0x1b);
17396 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017397
17398 if (present1 || present2) {
17399 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017400 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017401 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017402 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017403 } else {
17404 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017405 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017406 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017407 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017408 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020017409}
17410
Kailang Yangebb83ee2009-12-17 12:23:00 +010017411static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
17412{
17413 unsigned int present1, present2;
17414
17415 present1 = snd_hda_codec_read(codec, 0x1b, 0,
17416 AC_VERB_GET_PIN_SENSE, 0)
17417 & AC_PINSENSE_PRESENCE;
17418 present2 = snd_hda_codec_read(codec, 0x21, 0,
17419 AC_VERB_GET_PIN_SENSE, 0)
17420 & AC_PINSENSE_PRESENCE;
17421
17422 if (present1 || present2) {
17423 snd_hda_codec_write_cache(codec, 0x14, 0,
17424 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17425 snd_hda_codec_write_cache(codec, 0x17, 0,
17426 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17427 } else {
17428 snd_hda_codec_write_cache(codec, 0x14, 0,
17429 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17430 snd_hda_codec_write_cache(codec, 0x17, 0,
17431 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17432 }
17433}
17434
17435static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
17436{
17437 unsigned int present1, present2;
17438
17439 present1 = snd_hda_codec_read(codec, 0x21, 0,
17440 AC_VERB_GET_PIN_SENSE, 0)
17441 & AC_PINSENSE_PRESENCE;
17442 present2 = snd_hda_codec_read(codec, 0x15, 0,
17443 AC_VERB_GET_PIN_SENSE, 0)
17444 & AC_PINSENSE_PRESENCE;
17445
17446 if (present1 || present2) {
17447 snd_hda_codec_write_cache(codec, 0x14, 0,
17448 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17449 snd_hda_codec_write_cache(codec, 0x17, 0,
17450 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17451 } else {
17452 snd_hda_codec_write_cache(codec, 0x14, 0,
17453 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17454 snd_hda_codec_write_cache(codec, 0x17, 0,
17455 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17456 }
17457}
17458
Kailang Yang6dda9f42008-05-27 12:05:31 +020017459static void alc663_m51va_unsol_event(struct hda_codec *codec,
17460 unsigned int res)
17461{
17462 switch (res >> 26) {
17463 case ALC880_HP_EVENT:
17464 alc663_m51va_speaker_automute(codec);
17465 break;
17466 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017467 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017468 break;
17469 }
17470}
17471
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017472static void alc663_m51va_setup(struct hda_codec *codec)
17473{
17474 struct alc_spec *spec = codec->spec;
17475 spec->ext_mic.pin = 0x18;
17476 spec->ext_mic.mux_idx = 0;
17477 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017478 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017479 spec->auto_mic = 1;
17480}
17481
Kailang Yang6dda9f42008-05-27 12:05:31 +020017482static void alc663_m51va_inithook(struct hda_codec *codec)
17483{
17484 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017485 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017486}
17487
Kailang Yangf1d4e282008-08-26 14:03:29 +020017488/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017489#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010017490
17491static void alc663_mode1_setup(struct hda_codec *codec)
17492{
17493 struct alc_spec *spec = codec->spec;
17494 spec->ext_mic.pin = 0x18;
17495 spec->ext_mic.mux_idx = 0;
17496 spec->int_mic.pin = 0x19;
17497 spec->int_mic.mux_idx = 1;
17498 spec->auto_mic = 1;
17499}
17500
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017501#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020017502
Kailang Yangf1d4e282008-08-26 14:03:29 +020017503/* ***************** Mode2 ******************************/
17504static void alc662_mode2_unsol_event(struct hda_codec *codec,
17505 unsigned int res)
17506{
17507 switch (res >> 26) {
17508 case ALC880_HP_EVENT:
17509 alc662_f5z_speaker_automute(codec);
17510 break;
17511 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017512 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017513 break;
17514 }
17515}
17516
Kailang Yangebb83ee2009-12-17 12:23:00 +010017517#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017518
Kailang Yangf1d4e282008-08-26 14:03:29 +020017519static void alc662_mode2_inithook(struct hda_codec *codec)
17520{
17521 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017522 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017523}
17524/* ***************** Mode3 ******************************/
17525static void alc663_mode3_unsol_event(struct hda_codec *codec,
17526 unsigned int res)
17527{
17528 switch (res >> 26) {
17529 case ALC880_HP_EVENT:
17530 alc663_two_hp_m1_speaker_automute(codec);
17531 break;
17532 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017533 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017534 break;
17535 }
17536}
17537
Kailang Yangebb83ee2009-12-17 12:23:00 +010017538#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017539
Kailang Yangf1d4e282008-08-26 14:03:29 +020017540static void alc663_mode3_inithook(struct hda_codec *codec)
17541{
17542 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017543 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017544}
17545/* ***************** Mode4 ******************************/
17546static void alc663_mode4_unsol_event(struct hda_codec *codec,
17547 unsigned int res)
17548{
17549 switch (res >> 26) {
17550 case ALC880_HP_EVENT:
17551 alc663_21jd_two_speaker_automute(codec);
17552 break;
17553 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017554 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017555 break;
17556 }
17557}
17558
Kailang Yangebb83ee2009-12-17 12:23:00 +010017559#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017560
Kailang Yangf1d4e282008-08-26 14:03:29 +020017561static void alc663_mode4_inithook(struct hda_codec *codec)
17562{
17563 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017564 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017565}
17566/* ***************** Mode5 ******************************/
17567static void alc663_mode5_unsol_event(struct hda_codec *codec,
17568 unsigned int res)
17569{
17570 switch (res >> 26) {
17571 case ALC880_HP_EVENT:
17572 alc663_15jd_two_speaker_automute(codec);
17573 break;
17574 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017575 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017576 break;
17577 }
17578}
17579
Kailang Yangebb83ee2009-12-17 12:23:00 +010017580#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017581
Kailang Yangf1d4e282008-08-26 14:03:29 +020017582static void alc663_mode5_inithook(struct hda_codec *codec)
17583{
17584 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017585 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017586}
17587/* ***************** Mode6 ******************************/
17588static void alc663_mode6_unsol_event(struct hda_codec *codec,
17589 unsigned int res)
17590{
17591 switch (res >> 26) {
17592 case ALC880_HP_EVENT:
17593 alc663_two_hp_m2_speaker_automute(codec);
17594 break;
17595 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017596 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017597 break;
17598 }
17599}
17600
Kailang Yangebb83ee2009-12-17 12:23:00 +010017601#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017602
Kailang Yangf1d4e282008-08-26 14:03:29 +020017603static void alc663_mode6_inithook(struct hda_codec *codec)
17604{
17605 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017606 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017607}
17608
Kailang Yangebb83ee2009-12-17 12:23:00 +010017609/* ***************** Mode7 ******************************/
17610static void alc663_mode7_unsol_event(struct hda_codec *codec,
17611 unsigned int res)
17612{
17613 switch (res >> 26) {
17614 case ALC880_HP_EVENT:
17615 alc663_two_hp_m7_speaker_automute(codec);
17616 break;
17617 case ALC880_MIC_EVENT:
17618 alc_mic_automute(codec);
17619 break;
17620 }
17621}
17622
17623#define alc663_mode7_setup alc663_mode1_setup
17624
17625static void alc663_mode7_inithook(struct hda_codec *codec)
17626{
17627 alc663_two_hp_m7_speaker_automute(codec);
17628 alc_mic_automute(codec);
17629}
17630
17631/* ***************** Mode8 ******************************/
17632static void alc663_mode8_unsol_event(struct hda_codec *codec,
17633 unsigned int res)
17634{
17635 switch (res >> 26) {
17636 case ALC880_HP_EVENT:
17637 alc663_two_hp_m8_speaker_automute(codec);
17638 break;
17639 case ALC880_MIC_EVENT:
17640 alc_mic_automute(codec);
17641 break;
17642 }
17643}
17644
17645#define alc663_mode8_setup alc663_m51va_setup
17646
17647static void alc663_mode8_inithook(struct hda_codec *codec)
17648{
17649 alc663_two_hp_m8_speaker_automute(codec);
17650 alc_mic_automute(codec);
17651}
17652
Kailang Yang6dda9f42008-05-27 12:05:31 +020017653static void alc663_g71v_hp_automute(struct hda_codec *codec)
17654{
17655 unsigned int present;
17656 unsigned char bits;
17657
Wu Fengguang864f92b2009-11-18 12:38:02 +080017658 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017659 bits = present ? HDA_AMP_MUTE : 0;
17660 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17661 HDA_AMP_MUTE, bits);
17662 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17663 HDA_AMP_MUTE, bits);
17664}
17665
17666static void alc663_g71v_front_automute(struct hda_codec *codec)
17667{
17668 unsigned int present;
17669 unsigned char bits;
17670
Wu Fengguang864f92b2009-11-18 12:38:02 +080017671 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017672 bits = present ? HDA_AMP_MUTE : 0;
17673 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17674 HDA_AMP_MUTE, bits);
17675}
17676
17677static void alc663_g71v_unsol_event(struct hda_codec *codec,
17678 unsigned int res)
17679{
17680 switch (res >> 26) {
17681 case ALC880_HP_EVENT:
17682 alc663_g71v_hp_automute(codec);
17683 break;
17684 case ALC880_FRONT_EVENT:
17685 alc663_g71v_front_automute(codec);
17686 break;
17687 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017688 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017689 break;
17690 }
17691}
17692
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017693#define alc663_g71v_setup alc663_m51va_setup
17694
Kailang Yang6dda9f42008-05-27 12:05:31 +020017695static void alc663_g71v_inithook(struct hda_codec *codec)
17696{
17697 alc663_g71v_front_automute(codec);
17698 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017699 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017700}
17701
17702static void alc663_g50v_unsol_event(struct hda_codec *codec,
17703 unsigned int res)
17704{
17705 switch (res >> 26) {
17706 case ALC880_HP_EVENT:
17707 alc663_m51va_speaker_automute(codec);
17708 break;
17709 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017710 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017711 break;
17712 }
17713}
17714
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017715#define alc663_g50v_setup alc663_m51va_setup
17716
Kailang Yang6dda9f42008-05-27 12:05:31 +020017717static void alc663_g50v_inithook(struct hda_codec *codec)
17718{
17719 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017720 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017721}
17722
Kailang Yangf1d4e282008-08-26 14:03:29 +020017723static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17724 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017725 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017726
17727 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17728 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17729 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17730
17731 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17732 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17733 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17734 { } /* end */
17735};
17736
Chris Pockelé9541ba12009-05-12 08:08:53 +020017737static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17738 /* Master Playback automatically created from Speaker and Headphone */
17739 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17740 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17741 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17742 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17743
17744 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17745 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17746 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17747
17748 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17749 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17750 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17751 { } /* end */
17752};
17753
Takashi Iwaicb53c622007-08-10 17:21:45 +020017754#ifdef CONFIG_SND_HDA_POWER_SAVE
17755#define alc662_loopbacks alc880_loopbacks
17756#endif
17757
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017758
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017759/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017760#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17761#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17762#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17763#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17764
17765/*
17766 * configuration and preset
17767 */
17768static const char *alc662_models[ALC662_MODEL_LAST] = {
17769 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17770 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17771 [ALC662_3ST_6ch] = "3stack-6ch",
17772 [ALC662_5ST_DIG] = "6stack-dig",
17773 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017774 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017775 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017776 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017777 [ALC663_ASUS_M51VA] = "m51va",
17778 [ALC663_ASUS_G71V] = "g71v",
17779 [ALC663_ASUS_H13] = "h13",
17780 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017781 [ALC663_ASUS_MODE1] = "asus-mode1",
17782 [ALC662_ASUS_MODE2] = "asus-mode2",
17783 [ALC663_ASUS_MODE3] = "asus-mode3",
17784 [ALC663_ASUS_MODE4] = "asus-mode4",
17785 [ALC663_ASUS_MODE5] = "asus-mode5",
17786 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017787 [ALC663_ASUS_MODE7] = "asus-mode7",
17788 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017789 [ALC272_DELL] = "dell",
17790 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017791 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017792 [ALC662_AUTO] = "auto",
17793};
17794
17795static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017796 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017797 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17798 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017799 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17800 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010017801 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017802 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17803 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17804 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17805 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017806 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17807 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017808 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017809 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17810 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17811 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17812 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17813 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017814 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017815 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17816 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017817 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17818 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17819 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17820 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017821 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017822 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17823 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17824 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017825 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17826 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17827 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17828 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017829 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017830 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17831 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017832 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017833 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17834 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17835 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017836 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010017837 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017838 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17839 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017840 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17841 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17842 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017843 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017844 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17845 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017846 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017847 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017848 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017849 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17850 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17851 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017852 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017853 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17854 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017855 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017856 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017857 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017858 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017859 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17860 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010017861 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017862 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030017863 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17864 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010017865 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017866 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017867 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017868 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020017869 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020017870 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017871 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17872 ALC663_ASUS_H13),
David Santinoli7aee6742009-12-09 12:34:26 +010017873 SND_PCI_QUIRK(0x8086, 0xd604, "Intel mobo", ALC662_3ST_2ch_DIG),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017874 {}
17875};
17876
17877static struct alc_config_preset alc662_presets[] = {
17878 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017879 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017880 .init_verbs = { alc662_init_verbs },
17881 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17882 .dac_nids = alc662_dac_nids,
17883 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017884 .dig_in_nid = ALC662_DIGIN_NID,
17885 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17886 .channel_mode = alc662_3ST_2ch_modes,
17887 .input_mux = &alc662_capture_source,
17888 },
17889 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017890 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017891 .init_verbs = { alc662_init_verbs },
17892 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17893 .dac_nids = alc662_dac_nids,
17894 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017895 .dig_in_nid = ALC662_DIGIN_NID,
17896 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17897 .channel_mode = alc662_3ST_6ch_modes,
17898 .need_dac_fix = 1,
17899 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017900 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017901 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017902 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017903 .init_verbs = { alc662_init_verbs },
17904 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17905 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017906 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17907 .channel_mode = alc662_3ST_6ch_modes,
17908 .need_dac_fix = 1,
17909 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017910 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017911 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017912 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017913 .init_verbs = { alc662_init_verbs },
17914 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17915 .dac_nids = alc662_dac_nids,
17916 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017917 .dig_in_nid = ALC662_DIGIN_NID,
17918 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
17919 .channel_mode = alc662_5stack_modes,
17920 .input_mux = &alc662_capture_source,
17921 },
17922 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017923 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017924 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
17925 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17926 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017927 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17928 .channel_mode = alc662_3ST_2ch_modes,
17929 .input_mux = &alc662_lenovo_101e_capture_source,
17930 .unsol_event = alc662_lenovo_101e_unsol_event,
17931 .init_hook = alc662_lenovo_101e_all_automute,
17932 },
Kailang Yang291702f2007-10-16 14:28:03 +020017933 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017934 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020017935 .init_verbs = { alc662_init_verbs,
17936 alc662_eeepc_sue_init_verbs },
17937 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17938 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020017939 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17940 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020017941 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017942 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020017943 .init_hook = alc662_eeepc_inithook,
17944 },
Kailang Yang8c427222008-01-10 13:03:59 +010017945 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017946 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010017947 alc662_chmode_mixer },
17948 .init_verbs = { alc662_init_verbs,
17949 alc662_eeepc_ep20_sue_init_verbs },
17950 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17951 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010017952 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17953 .channel_mode = alc662_3ST_6ch_modes,
17954 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020017955 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017956 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010017957 .init_hook = alc662_eeepc_ep20_inithook,
17958 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017959 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017960 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017961 .init_verbs = { alc662_init_verbs,
17962 alc662_ecs_init_verbs },
17963 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17964 .dac_nids = alc662_dac_nids,
17965 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17966 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017967 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017968 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017969 .init_hook = alc662_eeepc_inithook,
17970 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017971 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017972 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017973 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17974 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17975 .dac_nids = alc662_dac_nids,
17976 .dig_out_nid = ALC662_DIGOUT_NID,
17977 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17978 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017979 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017980 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017981 .init_hook = alc663_m51va_inithook,
17982 },
17983 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017984 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017985 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17986 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17987 .dac_nids = alc662_dac_nids,
17988 .dig_out_nid = ALC662_DIGOUT_NID,
17989 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17990 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017991 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017992 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017993 .init_hook = alc663_g71v_inithook,
17994 },
17995 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017996 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017997 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17998 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17999 .dac_nids = alc662_dac_nids,
18000 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18001 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018002 .unsol_event = alc663_m51va_unsol_event,
18003 .init_hook = alc663_m51va_inithook,
18004 },
18005 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018006 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018007 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18008 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18009 .dac_nids = alc662_dac_nids,
18010 .dig_out_nid = ALC662_DIGOUT_NID,
18011 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18012 .channel_mode = alc662_3ST_6ch_modes,
18013 .input_mux = &alc663_capture_source,
18014 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018015 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018016 .init_hook = alc663_g50v_inithook,
18017 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018018 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018019 .mixers = { alc663_m51va_mixer },
18020 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018021 .init_verbs = { alc662_init_verbs,
18022 alc663_21jd_amic_init_verbs },
18023 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18024 .hp_nid = 0x03,
18025 .dac_nids = alc662_dac_nids,
18026 .dig_out_nid = ALC662_DIGOUT_NID,
18027 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18028 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018029 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018030 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018031 .init_hook = alc663_mode1_inithook,
18032 },
18033 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018034 .mixers = { alc662_1bjd_mixer },
18035 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018036 .init_verbs = { alc662_init_verbs,
18037 alc662_1bjd_amic_init_verbs },
18038 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18039 .dac_nids = alc662_dac_nids,
18040 .dig_out_nid = ALC662_DIGOUT_NID,
18041 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18042 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018043 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018044 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018045 .init_hook = alc662_mode2_inithook,
18046 },
18047 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018048 .mixers = { alc663_two_hp_m1_mixer },
18049 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018050 .init_verbs = { alc662_init_verbs,
18051 alc663_two_hp_amic_m1_init_verbs },
18052 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18053 .hp_nid = 0x03,
18054 .dac_nids = alc662_dac_nids,
18055 .dig_out_nid = ALC662_DIGOUT_NID,
18056 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18057 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018058 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018059 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018060 .init_hook = alc663_mode3_inithook,
18061 },
18062 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018063 .mixers = { alc663_asus_21jd_clfe_mixer },
18064 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018065 .init_verbs = { alc662_init_verbs,
18066 alc663_21jd_amic_init_verbs},
18067 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18068 .hp_nid = 0x03,
18069 .dac_nids = alc662_dac_nids,
18070 .dig_out_nid = ALC662_DIGOUT_NID,
18071 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18072 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018073 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018074 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018075 .init_hook = alc663_mode4_inithook,
18076 },
18077 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018078 .mixers = { alc663_asus_15jd_clfe_mixer },
18079 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018080 .init_verbs = { alc662_init_verbs,
18081 alc663_15jd_amic_init_verbs },
18082 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18083 .hp_nid = 0x03,
18084 .dac_nids = alc662_dac_nids,
18085 .dig_out_nid = ALC662_DIGOUT_NID,
18086 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18087 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018088 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018089 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018090 .init_hook = alc663_mode5_inithook,
18091 },
18092 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018093 .mixers = { alc663_two_hp_m2_mixer },
18094 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018095 .init_verbs = { alc662_init_verbs,
18096 alc663_two_hp_amic_m2_init_verbs },
18097 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18098 .hp_nid = 0x03,
18099 .dac_nids = alc662_dac_nids,
18100 .dig_out_nid = ALC662_DIGOUT_NID,
18101 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18102 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018103 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018104 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018105 .init_hook = alc663_mode6_inithook,
18106 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018107 [ALC663_ASUS_MODE7] = {
18108 .mixers = { alc663_mode7_mixer },
18109 .cap_mixer = alc662_auto_capture_mixer,
18110 .init_verbs = { alc662_init_verbs,
18111 alc663_mode7_init_verbs },
18112 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18113 .hp_nid = 0x03,
18114 .dac_nids = alc662_dac_nids,
18115 .dig_out_nid = ALC662_DIGOUT_NID,
18116 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18117 .channel_mode = alc662_3ST_2ch_modes,
18118 .unsol_event = alc663_mode7_unsol_event,
18119 .setup = alc663_mode7_setup,
18120 .init_hook = alc663_mode7_inithook,
18121 },
18122 [ALC663_ASUS_MODE8] = {
18123 .mixers = { alc663_mode8_mixer },
18124 .cap_mixer = alc662_auto_capture_mixer,
18125 .init_verbs = { alc662_init_verbs,
18126 alc663_mode8_init_verbs },
18127 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18128 .hp_nid = 0x03,
18129 .dac_nids = alc662_dac_nids,
18130 .dig_out_nid = ALC662_DIGOUT_NID,
18131 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18132 .channel_mode = alc662_3ST_2ch_modes,
18133 .unsol_event = alc663_mode8_unsol_event,
18134 .setup = alc663_mode8_setup,
18135 .init_hook = alc663_mode8_inithook,
18136 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018137 [ALC272_DELL] = {
18138 .mixers = { alc663_m51va_mixer },
18139 .cap_mixer = alc272_auto_capture_mixer,
18140 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18141 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18142 .dac_nids = alc662_dac_nids,
18143 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18144 .adc_nids = alc272_adc_nids,
18145 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18146 .capsrc_nids = alc272_capsrc_nids,
18147 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018148 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018149 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018150 .init_hook = alc663_m51va_inithook,
18151 },
18152 [ALC272_DELL_ZM1] = {
18153 .mixers = { alc663_m51va_mixer },
18154 .cap_mixer = alc662_auto_capture_mixer,
18155 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18156 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18157 .dac_nids = alc662_dac_nids,
18158 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18159 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018160 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018161 .capsrc_nids = alc662_capsrc_nids,
18162 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018163 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018164 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018165 .init_hook = alc663_m51va_inithook,
18166 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018167 [ALC272_SAMSUNG_NC10] = {
18168 .mixers = { alc272_nc10_mixer },
18169 .init_verbs = { alc662_init_verbs,
18170 alc663_21jd_amic_init_verbs },
18171 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18172 .dac_nids = alc272_dac_nids,
18173 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18174 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018175 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018176 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018177 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018178 .init_hook = alc663_mode4_inithook,
18179 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018180};
18181
18182
18183/*
18184 * BIOS auto configuration
18185 */
18186
Takashi Iwai7085ec12009-10-02 09:03:58 +020018187/* convert from MIX nid to DAC */
18188static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18189{
18190 if (nid == 0x0f)
18191 return 0x02;
18192 else if (nid >= 0x0c && nid <= 0x0e)
18193 return nid - 0x0c + 0x02;
18194 else
18195 return 0;
18196}
18197
18198/* get MIX nid connected to the given pin targeted to DAC */
18199static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18200 hda_nid_t dac)
18201{
18202 hda_nid_t mix[4];
18203 int i, num;
18204
18205 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18206 for (i = 0; i < num; i++) {
18207 if (alc662_mix_to_dac(mix[i]) == dac)
18208 return mix[i];
18209 }
18210 return 0;
18211}
18212
18213/* look for an empty DAC slot */
18214static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18215{
18216 struct alc_spec *spec = codec->spec;
18217 hda_nid_t srcs[5];
18218 int i, j, num;
18219
18220 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18221 if (num < 0)
18222 return 0;
18223 for (i = 0; i < num; i++) {
18224 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18225 if (!nid)
18226 continue;
18227 for (j = 0; j < spec->multiout.num_dacs; j++)
18228 if (spec->multiout.dac_nids[j] == nid)
18229 break;
18230 if (j >= spec->multiout.num_dacs)
18231 return nid;
18232 }
18233 return 0;
18234}
18235
18236/* fill in the dac_nids table from the parsed pin configuration */
18237static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18238 const struct auto_pin_cfg *cfg)
18239{
18240 struct alc_spec *spec = codec->spec;
18241 int i;
18242 hda_nid_t dac;
18243
18244 spec->multiout.dac_nids = spec->private_dac_nids;
18245 for (i = 0; i < cfg->line_outs; i++) {
18246 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18247 if (!dac)
18248 continue;
18249 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18250 }
18251 return 0;
18252}
18253
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018254static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018255 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018256{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018257 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018258 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18259}
18260
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018261static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018262 hda_nid_t nid, unsigned int chs)
18263{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018264 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018265 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18266}
18267
18268#define alc662_add_stereo_vol(spec, pfx, nid) \
18269 alc662_add_vol_ctl(spec, pfx, nid, 3)
18270#define alc662_add_stereo_sw(spec, pfx, nid) \
18271 alc662_add_sw_ctl(spec, pfx, nid, 3)
18272
18273/* add playback controls from the parsed DAC table */
18274static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18275 const struct auto_pin_cfg *cfg)
18276{
18277 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018278 static const char *chname[4] = {
18279 "Front", "Surround", NULL /*CLFE*/, "Side"
18280 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018281 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018282 int i, err;
18283
18284 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018285 nid = spec->multiout.dac_nids[i];
18286 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018287 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018288 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18289 if (!mix)
18290 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018291 if (i == 2) {
18292 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018293 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018294 if (err < 0)
18295 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018296 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018297 if (err < 0)
18298 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018299 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018300 if (err < 0)
18301 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018302 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018303 if (err < 0)
18304 return err;
18305 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018306 const char *pfx;
18307 if (cfg->line_outs == 1 &&
18308 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018309 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018310 pfx = "Speaker";
18311 else
18312 pfx = "PCM";
18313 } else
18314 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018315 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018316 if (err < 0)
18317 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018318 if (cfg->line_outs == 1 &&
18319 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18320 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018321 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018322 if (err < 0)
18323 return err;
18324 }
18325 }
18326 return 0;
18327}
18328
18329/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018330/* return DAC nid if any new DAC is assigned */
18331static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018332 const char *pfx)
18333{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018334 struct alc_spec *spec = codec->spec;
18335 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018336 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018337
18338 if (!pin)
18339 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018340 nid = alc662_look_for_dac(codec, pin);
18341 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018342 /* the corresponding DAC is already occupied */
18343 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
18344 return 0; /* no way */
18345 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018346 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018347 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
18348 }
18349
18350 mix = alc662_dac_to_mix(codec, pin, nid);
18351 if (!mix)
18352 return 0;
18353 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
18354 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020018355 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018356 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
18357 if (err < 0)
18358 return err;
18359 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018360}
18361
18362/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020018363#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020018364 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018365
18366static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
18367 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018368 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018369{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018370 int i, num;
18371 hda_nid_t srcs[4];
18372
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018373 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018374 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018375 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
18376 if (num <= 1)
18377 return;
18378 for (i = 0; i < num; i++) {
18379 if (alc662_mix_to_dac(srcs[i]) != dac)
18380 continue;
18381 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
18382 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018383 }
18384}
18385
18386static void alc662_auto_init_multi_out(struct hda_codec *codec)
18387{
18388 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018389 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018390 int i;
18391
18392 for (i = 0; i <= HDA_SIDE; i++) {
18393 hda_nid_t nid = spec->autocfg.line_out_pins[i];
18394 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020018395 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018396 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018397 }
18398}
18399
18400static void alc662_auto_init_hp_out(struct hda_codec *codec)
18401{
18402 struct alc_spec *spec = codec->spec;
18403 hda_nid_t pin;
18404
18405 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018406 if (pin)
18407 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
18408 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018409 pin = spec->autocfg.speaker_pins[0];
18410 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018411 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
18412 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018413}
18414
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018415#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
18416
18417static void alc662_auto_init_analog_input(struct hda_codec *codec)
18418{
18419 struct alc_spec *spec = codec->spec;
18420 int i;
18421
18422 for (i = 0; i < AUTO_PIN_LAST; i++) {
18423 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020018424 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010018425 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010018426 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010018427 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018428 snd_hda_codec_write(codec, nid, 0,
18429 AC_VERB_SET_AMP_GAIN_MUTE,
18430 AMP_OUT_MUTE);
18431 }
18432 }
18433}
18434
Takashi Iwaif511b012008-08-15 16:46:42 +020018435#define alc662_auto_init_input_src alc882_auto_init_input_src
18436
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018437static int alc662_parse_auto_config(struct hda_codec *codec)
18438{
18439 struct alc_spec *spec = codec->spec;
18440 int err;
18441 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
18442
18443 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
18444 alc662_ignore);
18445 if (err < 0)
18446 return err;
18447 if (!spec->autocfg.line_outs)
18448 return 0; /* can't find valid BIOS pin config */
18449
Takashi Iwai7085ec12009-10-02 09:03:58 +020018450 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018451 if (err < 0)
18452 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018453 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018454 if (err < 0)
18455 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018456 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018457 spec->autocfg.speaker_pins[0],
18458 "Speaker");
18459 if (err < 0)
18460 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018461 if (err)
18462 spec->multiout.extra_out_nid[0] = err;
18463 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018464 "Headphone");
18465 if (err < 0)
18466 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018467 if (err)
18468 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018469 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018470 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018471 return err;
18472
18473 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18474
Takashi Iwai0852d7a2009-02-11 11:35:15 +010018475 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018476 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
18477
Takashi Iwai603c4012008-07-30 15:01:44 +020018478 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018479 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018480
18481 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018482 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018483
Kailang Yangcec27c82010-02-04 14:18:18 +010018484 add_verb(spec, alc662_init_verbs);
18485 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18486 codec->vendor_id == 0x10ec0665)
18487 add_verb(spec, alc663_init_verbs);
18488
18489 if (codec->vendor_id == 0x10ec0272)
18490 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020018491
18492 err = alc_auto_add_mic_boost(codec);
18493 if (err < 0)
18494 return err;
18495
Kailang Yang6227cdc2010-02-25 08:36:52 +010018496 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18497 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
18498 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
18499 else
18500 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018501
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018502 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018503}
18504
18505/* additional initialization for auto-configuration model */
18506static void alc662_auto_init(struct hda_codec *codec)
18507{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018508 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018509 alc662_auto_init_multi_out(codec);
18510 alc662_auto_init_hp_out(codec);
18511 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020018512 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018513 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018514 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018515}
18516
18517static int patch_alc662(struct hda_codec *codec)
18518{
18519 struct alc_spec *spec;
18520 int err, board_config;
18521
18522 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18523 if (!spec)
18524 return -ENOMEM;
18525
18526 codec->spec = spec;
18527
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018528 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18529
Kailang Yang274693f2009-12-03 10:07:50 +010018530 if (alc_read_coef_idx(codec, 0)==0x8020){
18531 kfree(codec->chip_name);
18532 codec->chip_name = kstrdup("ALC661", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018533 if (!codec->chip_name) {
18534 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018535 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018536 }
Kailang Yang274693f2009-12-03 10:07:50 +010018537 }
18538
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018539 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18540 alc662_models,
18541 alc662_cfg_tbl);
18542 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020018543 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18544 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018545 board_config = ALC662_AUTO;
18546 }
18547
18548 if (board_config == ALC662_AUTO) {
18549 /* automatic parse from the BIOS config */
18550 err = alc662_parse_auto_config(codec);
18551 if (err < 0) {
18552 alc_free(codec);
18553 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018554 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018555 printk(KERN_INFO
18556 "hda_codec: Cannot set up configuration "
18557 "from BIOS. Using base mode...\n");
18558 board_config = ALC662_3ST_2ch_DIG;
18559 }
18560 }
18561
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018562 err = snd_hda_attach_beep_device(codec, 0x1);
18563 if (err < 0) {
18564 alc_free(codec);
18565 return err;
18566 }
18567
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018568 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018569 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018570
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018571 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18572 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18573
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018574 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18575 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18576
Takashi Iwaidd704692009-08-11 08:45:11 +020018577 if (!spec->adc_nids) {
18578 spec->adc_nids = alc662_adc_nids;
18579 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
18580 }
18581 if (!spec->capsrc_nids)
18582 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018583
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018584 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018585 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018586
Kailang Yangcec27c82010-02-04 14:18:18 +010018587 switch (codec->vendor_id) {
18588 case 0x10ec0662:
18589 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18590 break;
18591 case 0x10ec0272:
18592 case 0x10ec0663:
18593 case 0x10ec0665:
18594 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
18595 break;
18596 case 0x10ec0273:
18597 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
18598 break;
18599 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010018600 spec->vmaster_nid = 0x02;
18601
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018602 codec->patch_ops = alc_patch_ops;
18603 if (board_config == ALC662_AUTO)
18604 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020018605#ifdef CONFIG_SND_HDA_POWER_SAVE
18606 if (!spec->loopback.amplist)
18607 spec->loopback.amplist = alc662_loopbacks;
18608#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018609
18610 return 0;
18611}
18612
Kailang Yang274693f2009-12-03 10:07:50 +010018613static int patch_alc888(struct hda_codec *codec)
18614{
18615 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
18616 kfree(codec->chip_name);
18617 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018618 if (!codec->chip_name) {
18619 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018620 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018621 }
18622 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018623 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018624 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018625}
18626
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018627/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070018628 * patch entries
18629 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018630static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070018631 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018632 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018633 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020018634 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018635 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018636 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020018637 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018638 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018639 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018640 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018641 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
18642 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
18643 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018644 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018645 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018646 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
18647 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018648 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010018649 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010018650 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018651 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018652 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018653 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020018654 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018655 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020018656 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018657 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018658 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018659 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020018660 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018661 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018662 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018663 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018664 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018665 {} /* terminator */
18666};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018667
18668MODULE_ALIAS("snd-hda-codec-id:10ec*");
18669
18670MODULE_LICENSE("GPL");
18671MODULE_DESCRIPTION("Realtek HD-audio codec");
18672
18673static struct hda_codec_preset_list realtek_list = {
18674 .preset = snd_hda_preset_realtek,
18675 .owner = THIS_MODULE,
18676};
18677
18678static int __init patch_realtek_init(void)
18679{
18680 return snd_hda_add_codec_preset(&realtek_list);
18681}
18682
18683static void __exit patch_realtek_exit(void)
18684{
18685 snd_hda_delete_codec_preset(&realtek_list);
18686}
18687
18688module_init(patch_realtek_init)
18689module_exit(patch_realtek_exit)