blob: 65a9edeee9ea1cb7f77692efc6283f726a190c9a [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>
Kailang Yang9ad0e492010-09-14 23:22:00 +020031#include <sound/jack.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "hda_codec.h"
33#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090034#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Kailang Yangccc656c2006-10-17 12:32:26 +020036#define ALC880_FRONT_EVENT 0x01
37#define ALC880_DCVOL_EVENT 0x02
38#define ALC880_HP_EVENT 0x04
39#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41/* ALC880 board config type */
42enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 ALC880_3ST,
44 ALC880_3ST_DIG,
45 ALC880_5ST,
46 ALC880_5ST_DIG,
47 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020048 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020049 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020050 ALC880_6ST_DIG,
51 ALC880_F1734,
52 ALC880_ASUS,
53 ALC880_ASUS_DIG,
54 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010055 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010056 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020057 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020058 ALC880_UNIWILL,
59 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010060 ALC880_CLEVO,
61 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010062 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010063 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020064 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020065#ifdef CONFIG_SND_DEBUG
66 ALC880_TEST,
67#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010068 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020069 ALC880_MODEL_LAST /* last tag */
70};
71
72/* ALC260 models */
73enum {
74 ALC260_BASIC,
75 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020076 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010077 ALC260_HP_3013,
78 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010079 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020080 ALC260_WILL,
81 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010082 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010083#ifdef CONFIG_SND_DEBUG
84 ALC260_TEST,
85#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010086 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020087 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088};
89
Kailang Yangdf694da2005-12-05 19:42:22 +010090/* ALC262 models */
91enum {
92 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020093 ALC262_HIPPO,
94 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010095 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020096 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010097 ALC262_HP_BPC_D7000_WL,
98 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010099 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +0100100 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200101 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200102 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200103 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200104 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100105 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200106 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200107 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200108 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000109 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100110 ALC262_AUTO,
111 ALC262_MODEL_LAST /* last tag */
112};
113
Kailang Yanga361d842007-06-05 12:30:55 +0200114/* ALC268 models */
115enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200116 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200117 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200118 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200119 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100120 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200121 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100122 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100123 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100124#ifdef CONFIG_SND_DEBUG
125 ALC268_TEST,
126#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200127 ALC268_AUTO,
128 ALC268_MODEL_LAST /* last tag */
129};
130
Kailang Yangf6a92242007-12-13 16:52:54 +0100131/* ALC269 models */
132enum {
133 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200134 ALC269_QUANTA_FL1,
Kailang Yang84898e82010-02-04 14:16:14 +0100135 ALC269_AMIC,
136 ALC269_DMIC,
137 ALC269VB_AMIC,
138 ALC269VB_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100139 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000140 ALC269_LIFEBOOK,
Kailang Yangfe3eb0a2010-08-06 10:02:57 +0200141 ALC271_ACER,
Kailang Yangf6a92242007-12-13 16:52:54 +0100142 ALC269_AUTO,
143 ALC269_MODEL_LAST /* last tag */
144};
145
Kailang Yangdf694da2005-12-05 19:42:22 +0100146/* ALC861 models */
147enum {
148 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200149 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100150 ALC861_3ST_DIG,
151 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200152 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200153 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200154 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100155 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100156 ALC861_AUTO,
157 ALC861_MODEL_LAST,
158};
159
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100160/* ALC861-VD models */
161enum {
162 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200163 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100164 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100165 ALC861VD_3ST,
166 ALC861VD_3ST_DIG,
167 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200168 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200169 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200170 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100171 ALC861VD_AUTO,
172 ALC861VD_MODEL_LAST,
173};
174
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200175/* ALC662 models */
176enum {
177 ALC662_3ST_2ch_DIG,
178 ALC662_3ST_6ch_DIG,
179 ALC662_3ST_6ch,
180 ALC662_5ST_DIG,
181 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200182 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100183 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200184 ALC663_ASUS_M51VA,
185 ALC663_ASUS_G71V,
186 ALC663_ASUS_H13,
187 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200188 ALC662_ECS,
189 ALC663_ASUS_MODE1,
190 ALC662_ASUS_MODE2,
191 ALC663_ASUS_MODE3,
192 ALC663_ASUS_MODE4,
193 ALC663_ASUS_MODE5,
194 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100195 ALC663_ASUS_MODE7,
196 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200197 ALC272_DELL,
198 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200199 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200200 ALC662_AUTO,
201 ALC662_MODEL_LAST,
202};
203
Kailang Yangdf694da2005-12-05 19:42:22 +0100204/* ALC882 models */
205enum {
206 ALC882_3ST_DIG,
207 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200208 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200209 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200210 ALC882_TARGA,
211 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200212 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100213 ALC885_MACPRO,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -0800214 ALC885_MBA21,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200215 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200216 ALC885_MB5,
Luke Yelaviche458b1f2010-02-12 16:28:29 +1100217 ALC885_MACMINI3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200218 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800219 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200220 ALC883_3ST_2ch_DIG,
221 ALC883_3ST_6ch_DIG,
222 ALC883_3ST_6ch,
223 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200224 ALC883_TARGA_DIG,
225 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200226 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200227 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200228 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800229 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100230 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200231 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200232 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200233 ALC883_MEDION,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200234 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100235 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200236 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200237 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200238 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200239 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200240 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200241 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100242 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100243 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430244 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100245 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100246 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800247 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200248 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200249 ALC889A_INTEL,
250 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200251 ALC888_ASUS_M90V,
252 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200253 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100254 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200255 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200256 ALC882_AUTO,
257 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200258};
259
Takashi Iwaid4a86d82010-06-23 17:51:26 +0200260/* ALC680 models */
261enum {
262 ALC680_BASE,
263 ALC680_AUTO,
264 ALC680_MODEL_LAST,
265};
266
Kailang Yangdf694da2005-12-05 19:42:22 +0100267/* for GPIO Poll */
268#define GPIO_MASK 0x03
269
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200270/* extra amp-initialization sequence types */
271enum {
272 ALC_INIT_NONE,
273 ALC_INIT_DEFAULT,
274 ALC_INIT_GPIO1,
275 ALC_INIT_GPIO2,
276 ALC_INIT_GPIO3,
277};
278
Takashi Iwai6c819492009-08-10 18:47:44 +0200279struct alc_mic_route {
280 hda_nid_t pin;
281 unsigned char mux_idx;
282 unsigned char amix_idx;
283};
284
Kailang Yang9ad0e492010-09-14 23:22:00 +0200285struct alc_jack {
286 hda_nid_t nid;
287 int type;
288 struct snd_jack *jack;
289};
290
Takashi Iwai6c819492009-08-10 18:47:44 +0200291#define MUX_IDX_UNDEF ((unsigned char)-1)
292
Kailang Yangda00c242010-03-19 11:23:45 +0100293struct alc_customize_define {
294 unsigned int sku_cfg;
295 unsigned char port_connectivity;
296 unsigned char check_sum;
297 unsigned char customization;
298 unsigned char external_amp;
299 unsigned int enable_pcbeep:1;
300 unsigned int platform_type:1;
301 unsigned int swap:1;
302 unsigned int override:1;
David Henningsson90622912010-10-14 14:50:18 +0200303 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
Kailang Yangda00c242010-03-19 11:23:45 +0100304};
305
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306struct alc_spec {
307 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100308 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100310 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100311 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200313 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200314 * don't forget NULL
315 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200316 */
317 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200319 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 struct hda_pcm_stream *stream_analog_playback;
321 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100322 struct hda_pcm_stream *stream_analog_alt_playback;
323 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200325 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 struct hda_pcm_stream *stream_digital_playback;
327 struct hda_pcm_stream *stream_digital_capture;
328
329 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200330 struct hda_multi_out multiout; /* playback set-up
331 * max_channels, dacs must be set
332 * dig_out_nid and hp_nid are optional
333 */
Takashi Iwai63300792008-01-24 15:31:36 +0100334 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100335 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100336 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337
338 /* capture */
339 unsigned int num_adc_nids;
340 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100341 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200342 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
Takashi Iwai840b64c2010-07-13 22:49:01 +0200344 /* capture setup for dynamic dual-adc switch */
345 unsigned int cur_adc_idx;
346 hda_nid_t cur_adc;
347 unsigned int cur_adc_stream_tag;
348 unsigned int cur_adc_format;
349
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200351 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 const struct hda_input_mux *input_mux;
353 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200354 struct alc_mic_route ext_mic;
355 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356
357 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100358 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200360 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200361 int const_channel_count;
362 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363
364 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100365 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200366
Kailang Yang9ad0e492010-09-14 23:22:00 +0200367 /* jack detection */
368 struct snd_array jacks;
369
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200370 /* dynamic controls, init_verbs and input_mux */
371 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100372 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200373 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200374 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200375 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200376 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
377 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100378
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100379 /* hooks */
380 void (*init_hook)(struct hda_codec *codec);
381 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100382#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500383 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100384#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100385
Takashi Iwai834be882006-03-01 14:16:17 +0100386 /* for pin sensing */
387 unsigned int sense_updated: 1;
388 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100389 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200390 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200391
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100392 /* other flags */
393 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai840b64c2010-07-13 22:49:01 +0200394 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200395 int init_amp;
Takashi Iwaid433a672010-09-20 15:11:54 +0200396 int codec_variant; /* flag for other variants */
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100397
Takashi Iwai2134ea42008-01-10 16:53:55 +0100398 /* for virtual master */
399 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200400#ifdef CONFIG_SND_HDA_POWER_SAVE
401 struct hda_loopback_check loopback;
402#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200403
404 /* for PLL fix */
405 hda_nid_t pll_nid;
406 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100407};
408
409/*
410 * configuration template - to be copied to the spec instance
411 */
412struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200413 struct snd_kcontrol_new *mixers[5]; /* should be identical size
414 * with spec
415 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100416 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100417 const struct hda_verb *init_verbs[5];
418 unsigned int num_dacs;
419 hda_nid_t *dac_nids;
420 hda_nid_t dig_out_nid; /* optional */
421 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800422 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100423 unsigned int num_adc_nids;
424 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100425 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100426 hda_nid_t dig_in_nid;
427 unsigned int num_channel_mode;
428 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200429 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200430 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200431 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100432 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100433 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200434 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100435 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200436#ifdef CONFIG_SND_HDA_POWER_SAVE
437 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500438 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200439#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440};
441
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442
443/*
444 * input MUX handling
445 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200446static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
447 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448{
449 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
450 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200451 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
452 if (mux_idx >= spec->num_mux_defs)
453 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100454 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
455 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200456 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457}
458
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200459static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
460 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461{
462 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
463 struct alc_spec *spec = codec->spec;
464 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
465
466 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
467 return 0;
468}
469
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200470static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
471 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472{
473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
474 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100475 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100477 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100478 hda_nid_t nid = spec->capsrc_nids ?
479 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200480 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481
Takashi Iwaicd896c32008-11-18 12:36:33 +0100482 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
483 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100484 if (!imux->num_items && mux_idx > 0)
485 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100486
Takashi Iwaia22d5432009-07-27 12:54:26 +0200487 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200488 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100489 /* Matrix-mixer style (e.g. ALC882) */
490 unsigned int *cur_val = &spec->cur_mux[adc_idx];
491 unsigned int i, idx;
492
493 idx = ucontrol->value.enumerated.item[0];
494 if (idx >= imux->num_items)
495 idx = imux->num_items - 1;
496 if (*cur_val == idx)
497 return 0;
498 for (i = 0; i < imux->num_items; i++) {
499 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
500 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
501 imux->items[i].index,
502 HDA_AMP_MUTE, v);
503 }
504 *cur_val = idx;
505 return 1;
506 } else {
507 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100508 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100509 &spec->cur_mux[adc_idx]);
510 }
511}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200512
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513/*
514 * channel mode setting
515 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200516static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
517 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518{
519 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
520 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100521 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
522 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523}
524
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200525static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
526 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527{
528 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
529 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100530 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200531 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200532 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533}
534
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200535static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
536 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537{
538 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
539 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200540 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
541 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200542 &spec->ext_channel_count);
543 if (err >= 0 && !spec->const_channel_count) {
544 spec->multiout.max_channels = spec->ext_channel_count;
545 if (spec->need_dac_fix)
546 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
547 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200548 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549}
550
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100552 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200553 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100554 * being part of a format specifier. Maximum allowed length of a value is
555 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100556 *
557 * Note: some retasking pin complexes seem to ignore requests for input
558 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
559 * are requested. Therefore order this list so that this behaviour will not
560 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200561 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
562 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200563 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100564static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100565 "Mic 50pc bias", "Mic 80pc bias",
566 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100567};
568static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100569 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100570};
571/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200572 * in the pin being assumed to be exclusively an input or an output pin. In
573 * addition, "input" pins may or may not process the mic bias option
574 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
575 * accept requests for bias as of chip versions up to March 2006) and/or
576 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100577 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200578#define ALC_PIN_DIR_IN 0x00
579#define ALC_PIN_DIR_OUT 0x01
580#define ALC_PIN_DIR_INOUT 0x02
581#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
582#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100583
Kailang Yangea1fb292008-08-26 12:58:38 +0200584/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100585 * For each direction the minimum and maximum values are given.
586 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200587static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100588 { 0, 2 }, /* ALC_PIN_DIR_IN */
589 { 3, 4 }, /* ALC_PIN_DIR_OUT */
590 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200591 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
592 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100593};
594#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
595#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
596#define alc_pin_mode_n_items(_dir) \
597 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
598
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200599static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
600 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200601{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100602 unsigned int item_num = uinfo->value.enumerated.item;
603 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
604
605 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200606 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100607 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
608
609 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
610 item_num = alc_pin_mode_min(dir);
611 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200612 return 0;
613}
614
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200615static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
616 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200617{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100618 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200619 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
620 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100621 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200622 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200623 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
624 AC_VERB_GET_PIN_WIDGET_CONTROL,
625 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200626
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100627 /* Find enumerated value for current pinctl setting */
628 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200629 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100630 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200631 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100632 return 0;
633}
634
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200635static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
636 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100637{
638 signed int change;
639 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
640 hda_nid_t nid = kcontrol->private_value & 0xffff;
641 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
642 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200643 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
644 AC_VERB_GET_PIN_WIDGET_CONTROL,
645 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100646
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200647 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100648 val = alc_pin_mode_min(dir);
649
650 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100651 if (change) {
652 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200653 snd_hda_codec_write_cache(codec, nid, 0,
654 AC_VERB_SET_PIN_WIDGET_CONTROL,
655 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100656
Kailang Yangea1fb292008-08-26 12:58:38 +0200657 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100658 * for the requested pin mode. Enum values of 2 or less are
659 * input modes.
660 *
661 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200662 * reduces noise slightly (particularly on input) so we'll
663 * do it. However, having both input and output buffers
664 * enabled simultaneously doesn't seem to be problematic if
665 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100666 */
667 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200668 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
669 HDA_AMP_MUTE, HDA_AMP_MUTE);
670 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
671 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100672 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200673 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
674 HDA_AMP_MUTE, HDA_AMP_MUTE);
675 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
676 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100677 }
678 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200679 return change;
680}
681
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100682#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200683 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100684 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100685 .info = alc_pin_mode_info, \
686 .get = alc_pin_mode_get, \
687 .put = alc_pin_mode_put, \
688 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100689
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100690/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
691 * together using a mask with more than one bit set. This control is
692 * currently used only by the ALC260 test model. At this stage they are not
693 * needed for any "production" models.
694 */
695#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200696#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200697
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200698static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
699 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100700{
701 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
702 hda_nid_t nid = kcontrol->private_value & 0xffff;
703 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
704 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200705 unsigned int val = snd_hda_codec_read(codec, nid, 0,
706 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100707
708 *valp = (val & mask) != 0;
709 return 0;
710}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200711static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
712 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100713{
714 signed int change;
715 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
716 hda_nid_t nid = kcontrol->private_value & 0xffff;
717 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
718 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200719 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
720 AC_VERB_GET_GPIO_DATA,
721 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100722
723 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200724 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
725 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100726 gpio_data &= ~mask;
727 else
728 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200729 snd_hda_codec_write_cache(codec, nid, 0,
730 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100731
732 return change;
733}
734#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
735 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100736 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100737 .info = alc_gpio_data_info, \
738 .get = alc_gpio_data_get, \
739 .put = alc_gpio_data_put, \
740 .private_value = nid | (mask<<16) }
741#endif /* CONFIG_SND_DEBUG */
742
Jonathan Woithe92621f12006-02-28 11:47:47 +0100743/* A switch control to allow the enabling of the digital IO pins on the
744 * ALC260. This is incredibly simplistic; the intention of this control is
745 * to provide something in the test model allowing digital outputs to be
746 * identified if present. If models are found which can utilise these
747 * outputs a more complete mixer control can be devised for those models if
748 * necessary.
749 */
750#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200751#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200752
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200753static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
754 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100755{
756 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
757 hda_nid_t nid = kcontrol->private_value & 0xffff;
758 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
759 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200760 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100761 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100762
763 *valp = (val & mask) != 0;
764 return 0;
765}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200766static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
767 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100768{
769 signed int change;
770 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
771 hda_nid_t nid = kcontrol->private_value & 0xffff;
772 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
773 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200774 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100775 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200776 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100777
778 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200779 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100780 if (val==0)
781 ctrl_data &= ~mask;
782 else
783 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200784 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
785 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100786
787 return change;
788}
789#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
790 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100791 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100792 .info = alc_spdif_ctrl_info, \
793 .get = alc_spdif_ctrl_get, \
794 .put = alc_spdif_ctrl_put, \
795 .private_value = nid | (mask<<16) }
796#endif /* CONFIG_SND_DEBUG */
797
Jonathan Woithef8225f62008-01-08 12:16:54 +0100798/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
799 * Again, this is only used in the ALC26x test models to help identify when
800 * the EAPD line must be asserted for features to work.
801 */
802#ifdef CONFIG_SND_DEBUG
803#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
804
805static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
806 struct snd_ctl_elem_value *ucontrol)
807{
808 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
809 hda_nid_t nid = kcontrol->private_value & 0xffff;
810 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
811 long *valp = ucontrol->value.integer.value;
812 unsigned int val = snd_hda_codec_read(codec, nid, 0,
813 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
814
815 *valp = (val & mask) != 0;
816 return 0;
817}
818
819static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
820 struct snd_ctl_elem_value *ucontrol)
821{
822 int change;
823 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
824 hda_nid_t nid = kcontrol->private_value & 0xffff;
825 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
826 long val = *ucontrol->value.integer.value;
827 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
828 AC_VERB_GET_EAPD_BTLENABLE,
829 0x00);
830
831 /* Set/unset the masked control bit(s) as needed */
832 change = (!val ? 0 : mask) != (ctrl_data & mask);
833 if (!val)
834 ctrl_data &= ~mask;
835 else
836 ctrl_data |= mask;
837 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
838 ctrl_data);
839
840 return change;
841}
842
843#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
844 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100845 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100846 .info = alc_eapd_ctrl_info, \
847 .get = alc_eapd_ctrl_get, \
848 .put = alc_eapd_ctrl_put, \
849 .private_value = nid | (mask<<16) }
850#endif /* CONFIG_SND_DEBUG */
851
Kailang Yangdf694da2005-12-05 19:42:22 +0100852/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100853 * set up the input pin config (depending on the given auto-pin type)
854 */
855static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
856 int auto_pin_type)
857{
858 unsigned int val = PIN_IN;
859
Takashi Iwai86e29592010-09-09 14:50:17 +0200860 if (auto_pin_type == AUTO_PIN_MIC) {
Takashi Iwai23f0c042009-02-26 13:03:58 +0100861 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200862 unsigned int oldval;
863 oldval = snd_hda_codec_read(codec, nid, 0,
864 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100865 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100866 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200867 /* if the default pin setup is vref50, we give it priority */
868 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100869 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200870 else if (pincap & AC_PINCAP_VREF_50)
871 val = PIN_VREF50;
872 else if (pincap & AC_PINCAP_VREF_100)
873 val = PIN_VREF100;
874 else if (pincap & AC_PINCAP_VREF_GRD)
875 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100876 }
877 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
878}
879
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200880static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
881{
882 struct alc_spec *spec = codec->spec;
883 struct auto_pin_cfg *cfg = &spec->autocfg;
884
885 if (!cfg->line_outs) {
886 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
887 cfg->line_out_pins[cfg->line_outs])
888 cfg->line_outs++;
889 }
890 if (!cfg->speaker_outs) {
891 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
892 cfg->speaker_pins[cfg->speaker_outs])
893 cfg->speaker_outs++;
894 }
895 if (!cfg->hp_outs) {
896 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
897 cfg->hp_pins[cfg->hp_outs])
898 cfg->hp_outs++;
899 }
900}
901
Takashi Iwai23f0c042009-02-26 13:03:58 +0100902/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100903 */
904static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
905{
906 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
907 return;
908 spec->mixers[spec->num_mixers++] = mix;
909}
910
911static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
912{
913 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
914 return;
915 spec->init_verbs[spec->num_init_verbs++] = verb;
916}
917
918/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100919 * set up from the preset table
920 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200921static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200922 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100923{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200924 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100925 int i;
926
927 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100928 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100929 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200930 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
931 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100932 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200933
Kailang Yangdf694da2005-12-05 19:42:22 +0100934 spec->channel_mode = preset->channel_mode;
935 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200936 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200937 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100938
Hector Martin3b315d72009-06-02 10:54:19 +0200939 if (preset->const_channel_count)
940 spec->multiout.max_channels = preset->const_channel_count;
941 else
942 spec->multiout.max_channels = spec->channel_mode[0].channels;
943 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100944
945 spec->multiout.num_dacs = preset->num_dacs;
946 spec->multiout.dac_nids = preset->dac_nids;
947 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800948 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100949 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200950
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200951 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200952 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200953 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100954 spec->input_mux = preset->input_mux;
955
956 spec->num_adc_nids = preset->num_adc_nids;
957 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100958 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100959 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100960
961 spec->unsol_event = preset->unsol_event;
962 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200963#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100964 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200965 spec->loopback.amplist = preset->loopbacks;
966#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200967
968 if (preset->setup)
969 preset->setup(codec);
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200970
971 alc_fixup_autocfg_pin_nums(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100972}
973
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200974/* Enable GPIO mask and set output */
975static struct hda_verb alc_gpio1_init_verbs[] = {
976 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
977 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
978 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
979 { }
980};
981
982static struct hda_verb alc_gpio2_init_verbs[] = {
983 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
984 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
985 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
986 { }
987};
988
Kailang Yangbdd148a2007-05-08 15:19:08 +0200989static struct hda_verb alc_gpio3_init_verbs[] = {
990 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
991 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
992 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
993 { }
994};
995
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200996/*
997 * Fix hardware PLL issue
998 * On some codecs, the analog PLL gating control must be off while
999 * the default value is 1.
1000 */
1001static void alc_fix_pll(struct hda_codec *codec)
1002{
1003 struct alc_spec *spec = codec->spec;
1004 unsigned int val;
1005
1006 if (!spec->pll_nid)
1007 return;
1008 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1009 spec->pll_coef_idx);
1010 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1011 AC_VERB_GET_PROC_COEF, 0);
1012 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1013 spec->pll_coef_idx);
1014 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1015 val & ~(1 << spec->pll_coef_bit));
1016}
1017
1018static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1019 unsigned int coef_idx, unsigned int coef_bit)
1020{
1021 struct alc_spec *spec = codec->spec;
1022 spec->pll_nid = nid;
1023 spec->pll_coef_idx = coef_idx;
1024 spec->pll_coef_bit = coef_bit;
1025 alc_fix_pll(codec);
1026}
1027
Kailang Yang9ad0e492010-09-14 23:22:00 +02001028#ifdef CONFIG_SND_HDA_INPUT_JACK
1029static void alc_free_jack_priv(struct snd_jack *jack)
1030{
1031 struct alc_jack *jacks = jack->private_data;
1032 jacks->nid = 0;
1033 jacks->jack = NULL;
1034}
1035
1036static int alc_add_jack(struct hda_codec *codec,
1037 hda_nid_t nid, int type)
1038{
1039 struct alc_spec *spec;
1040 struct alc_jack *jack;
1041 const char *name;
1042 int err;
1043
1044 spec = codec->spec;
1045 snd_array_init(&spec->jacks, sizeof(*jack), 32);
1046 jack = snd_array_new(&spec->jacks);
1047 if (!jack)
1048 return -ENOMEM;
1049
1050 jack->nid = nid;
1051 jack->type = type;
1052 name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
1053
1054 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
1055 if (err < 0)
1056 return err;
1057 jack->jack->private_data = jack;
1058 jack->jack->private_free = alc_free_jack_priv;
1059 return 0;
1060}
1061
1062static void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1063{
1064 struct alc_spec *spec = codec->spec;
1065 struct alc_jack *jacks = spec->jacks.list;
1066
1067 if (jacks) {
1068 int i;
1069 for (i = 0; i < spec->jacks.used; i++) {
1070 if (jacks->nid == nid) {
1071 unsigned int present;
1072 present = snd_hda_jack_detect(codec, nid);
1073
1074 present = (present) ? jacks->type : 0;
1075
1076 snd_jack_report(jacks->jack, present);
1077 }
1078 jacks++;
1079 }
1080 }
1081}
1082
1083static int alc_init_jacks(struct hda_codec *codec)
1084{
1085 struct alc_spec *spec = codec->spec;
1086 int err;
1087 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1088 unsigned int mic_nid = spec->ext_mic.pin;
1089
Takashi Iwai265a0242010-09-21 11:26:21 +02001090 if (hp_nid) {
1091 err = alc_add_jack(codec, hp_nid, SND_JACK_HEADPHONE);
1092 if (err < 0)
1093 return err;
1094 alc_report_jack(codec, hp_nid);
1095 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001096
Takashi Iwai265a0242010-09-21 11:26:21 +02001097 if (mic_nid) {
1098 err = alc_add_jack(codec, mic_nid, SND_JACK_MICROPHONE);
1099 if (err < 0)
1100 return err;
1101 alc_report_jack(codec, mic_nid);
1102 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001103
1104 return 0;
1105}
1106#else
1107static inline void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1108{
1109}
1110
1111static inline int alc_init_jacks(struct hda_codec *codec)
1112{
1113 return 0;
1114}
1115#endif
1116
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001117static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
Kailang Yangc9b58002007-10-16 14:30:01 +02001118{
1119 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001120 unsigned int mute;
1121 hda_nid_t nid;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001122 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +02001123
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001124 spec->jack_present = 0;
1125 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1126 nid = spec->autocfg.hp_pins[i];
1127 if (!nid)
1128 break;
1129 if (snd_hda_jack_detect(codec, nid)) {
1130 spec->jack_present = 1;
1131 break;
1132 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001133 alc_report_jack(codec, spec->autocfg.hp_pins[i]);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001134 }
1135
1136 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1137 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001138 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1139 nid = spec->autocfg.speaker_pins[i];
1140 if (!nid)
1141 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001142 if (pinctl) {
1143 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001144 AC_VERB_SET_PIN_WIDGET_CONTROL,
1145 spec->jack_present ? 0 : PIN_OUT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001146 } else {
1147 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1148 HDA_AMP_MUTE, mute);
1149 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001150 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001151}
1152
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001153static void alc_automute_pin(struct hda_codec *codec)
1154{
1155 alc_automute_speaker(codec, 1);
1156}
1157
Takashi Iwai6c819492009-08-10 18:47:44 +02001158static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1159 hda_nid_t nid)
1160{
1161 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1162 int i, nums;
1163
1164 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1165 for (i = 0; i < nums; i++)
1166 if (conn[i] == nid)
1167 return i;
1168 return -1;
1169}
1170
Takashi Iwai840b64c2010-07-13 22:49:01 +02001171/* switch the current ADC according to the jack state */
1172static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1173{
1174 struct alc_spec *spec = codec->spec;
1175 unsigned int present;
1176 hda_nid_t new_adc;
1177
1178 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1179 if (present)
1180 spec->cur_adc_idx = 1;
1181 else
1182 spec->cur_adc_idx = 0;
1183 new_adc = spec->adc_nids[spec->cur_adc_idx];
1184 if (spec->cur_adc && spec->cur_adc != new_adc) {
1185 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001186 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001187 spec->cur_adc = new_adc;
1188 snd_hda_codec_setup_stream(codec, new_adc,
1189 spec->cur_adc_stream_tag, 0,
1190 spec->cur_adc_format);
1191 }
1192}
1193
Kailang Yang7fb0d782008-10-15 11:12:35 +02001194static void alc_mic_automute(struct hda_codec *codec)
1195{
1196 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001197 struct alc_mic_route *dead, *alive;
1198 unsigned int present, type;
1199 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001200
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001201 if (!spec->auto_mic)
1202 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001203 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1204 return;
1205 if (snd_BUG_ON(!spec->adc_nids))
1206 return;
1207
Takashi Iwai840b64c2010-07-13 22:49:01 +02001208 if (spec->dual_adc_switch) {
1209 alc_dual_mic_adc_auto_switch(codec);
1210 return;
1211 }
1212
Takashi Iwai6c819492009-08-10 18:47:44 +02001213 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1214
Wu Fengguang864f92b2009-11-18 12:38:02 +08001215 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001216 if (present) {
1217 alive = &spec->ext_mic;
1218 dead = &spec->int_mic;
1219 } else {
1220 alive = &spec->int_mic;
1221 dead = &spec->ext_mic;
1222 }
1223
Takashi Iwai6c819492009-08-10 18:47:44 +02001224 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1225 if (type == AC_WID_AUD_MIX) {
1226 /* Matrix-mixer style (e.g. ALC882) */
1227 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1228 alive->mux_idx,
1229 HDA_AMP_MUTE, 0);
1230 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1231 dead->mux_idx,
1232 HDA_AMP_MUTE, HDA_AMP_MUTE);
1233 } else {
1234 /* MUX style (e.g. ALC880) */
1235 snd_hda_codec_write_cache(codec, cap_nid, 0,
1236 AC_VERB_SET_CONNECT_SEL,
1237 alive->mux_idx);
1238 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001239 alc_report_jack(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001240
1241 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001242}
1243
Kailang Yangc9b58002007-10-16 14:30:01 +02001244/* unsolicited event for HP jack sensing */
1245static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1246{
1247 if (codec->vendor_id == 0x10ec0880)
1248 res >>= 28;
1249 else
1250 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001251 switch (res) {
1252 case ALC880_HP_EVENT:
1253 alc_automute_pin(codec);
1254 break;
1255 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001256 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001257 break;
1258 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001259}
1260
1261static void alc_inithook(struct hda_codec *codec)
1262{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001263 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001264 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001265}
1266
Kailang Yangf9423e72008-05-27 12:32:25 +02001267/* additional initialization for ALC888 variants */
1268static void alc888_coef_init(struct hda_codec *codec)
1269{
1270 unsigned int tmp;
1271
1272 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1273 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1274 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001275 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001276 /* alc888S-VC */
1277 snd_hda_codec_read(codec, 0x20, 0,
1278 AC_VERB_SET_PROC_COEF, 0x830);
1279 else
1280 /* alc888-VB */
1281 snd_hda_codec_read(codec, 0x20, 0,
1282 AC_VERB_SET_PROC_COEF, 0x3030);
1283}
1284
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001285static void alc889_coef_init(struct hda_codec *codec)
1286{
1287 unsigned int tmp;
1288
1289 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1290 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1291 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1292 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1293}
1294
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001295/* turn on/off EAPD control (only if available) */
1296static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1297{
1298 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1299 return;
1300 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1301 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1302 on ? 2 : 0);
1303}
1304
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001305static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001306{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001307 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001308
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001309 switch (type) {
1310 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001311 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1312 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001313 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001314 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1315 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001316 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001317 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1318 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001319 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001320 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001321 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001322 set_eapd(codec, 0x0f, 1);
1323 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001324 break;
1325 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001326 case 0x10ec0267:
1327 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001328 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001329 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001330 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001331 case 0x10ec0660:
1332 case 0x10ec0662:
1333 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001334 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001335 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001336 set_eapd(codec, 0x14, 1);
1337 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001338 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001339 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001340 switch (codec->vendor_id) {
1341 case 0x10ec0260:
1342 snd_hda_codec_write(codec, 0x1a, 0,
1343 AC_VERB_SET_COEF_INDEX, 7);
1344 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1345 AC_VERB_GET_PROC_COEF, 0);
1346 snd_hda_codec_write(codec, 0x1a, 0,
1347 AC_VERB_SET_COEF_INDEX, 7);
1348 snd_hda_codec_write(codec, 0x1a, 0,
1349 AC_VERB_SET_PROC_COEF,
1350 tmp | 0x2010);
1351 break;
1352 case 0x10ec0262:
1353 case 0x10ec0880:
1354 case 0x10ec0882:
1355 case 0x10ec0883:
1356 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001357 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001358 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001359 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001360 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001361 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001362 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001363 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001364#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001365 case 0x10ec0267:
1366 case 0x10ec0268:
1367 snd_hda_codec_write(codec, 0x20, 0,
1368 AC_VERB_SET_COEF_INDEX, 7);
1369 tmp = snd_hda_codec_read(codec, 0x20, 0,
1370 AC_VERB_GET_PROC_COEF, 0);
1371 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001372 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001373 snd_hda_codec_write(codec, 0x20, 0,
1374 AC_VERB_SET_PROC_COEF,
1375 tmp | 0x3000);
1376 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001377#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001378 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001379 break;
1380 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001381}
Kailang Yangea1fb292008-08-26 12:58:38 +02001382
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001383static void alc_init_auto_hp(struct hda_codec *codec)
1384{
1385 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001386 struct auto_pin_cfg *cfg = &spec->autocfg;
1387 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001388
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001389 if (!cfg->hp_pins[0]) {
1390 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001391 return;
1392 }
1393
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001394 if (!cfg->speaker_pins[0]) {
1395 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1396 return;
1397 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1398 sizeof(cfg->speaker_pins));
1399 cfg->speaker_outs = cfg->line_outs;
1400 }
1401
1402 if (!cfg->hp_pins[0]) {
1403 memcpy(cfg->hp_pins, cfg->line_out_pins,
1404 sizeof(cfg->hp_pins));
1405 cfg->hp_outs = cfg->line_outs;
1406 }
1407
1408 for (i = 0; i < cfg->hp_outs; i++) {
1409 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1410 cfg->hp_pins[i]);
1411 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001412 AC_VERB_SET_UNSOLICITED_ENABLE,
1413 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001414 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001415 spec->unsol_event = alc_sku_unsol_event;
1416}
1417
Takashi Iwai6c819492009-08-10 18:47:44 +02001418static void alc_init_auto_mic(struct hda_codec *codec)
1419{
1420 struct alc_spec *spec = codec->spec;
1421 struct auto_pin_cfg *cfg = &spec->autocfg;
1422 hda_nid_t fixed, ext;
1423 int i;
1424
1425 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001426 for (i = 0; i < cfg->num_inputs; i++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001427 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
Takashi Iwai6c819492009-08-10 18:47:44 +02001428 return;
1429
1430 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001431 for (i = 0; i < cfg->num_inputs; i++) {
1432 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001433 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001434 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001435 switch (snd_hda_get_input_pin_attr(defcfg)) {
1436 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001437 if (fixed)
1438 return; /* already occupied */
1439 fixed = nid;
1440 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001441 case INPUT_PIN_ATTR_UNUSED:
1442 return; /* invalid entry */
1443 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001444 if (ext)
1445 return; /* already occupied */
1446 ext = nid;
1447 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001448 }
1449 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001450 if (!ext || !fixed)
1451 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001452 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1453 return; /* no unsol support */
1454 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1455 ext, fixed);
1456 spec->ext_mic.pin = ext;
1457 spec->int_mic.pin = fixed;
1458 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1459 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1460 spec->auto_mic = 1;
1461 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1462 AC_VERB_SET_UNSOLICITED_ENABLE,
1463 AC_USRSP_EN | ALC880_MIC_EVENT);
1464 spec->unsol_event = alc_sku_unsol_event;
1465}
1466
David Henningsson90622912010-10-14 14:50:18 +02001467/* Could be any non-zero and even value. When used as fixup, tells
1468 * the driver to ignore any present sku defines.
1469 */
1470#define ALC_FIXUP_SKU_IGNORE (2)
1471
Kailang Yangda00c242010-03-19 11:23:45 +01001472static int alc_auto_parse_customize_define(struct hda_codec *codec)
1473{
1474 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001475 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001476 struct alc_spec *spec = codec->spec;
1477
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001478 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1479
David Henningsson90622912010-10-14 14:50:18 +02001480 if (spec->cdefine.fixup) {
1481 ass = spec->cdefine.sku_cfg;
1482 if (ass == ALC_FIXUP_SKU_IGNORE)
1483 return -1;
1484 goto do_sku;
1485 }
1486
Kailang Yangda00c242010-03-19 11:23:45 +01001487 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001488 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001489 goto do_sku;
1490
1491 nid = 0x1d;
1492 if (codec->vendor_id == 0x10ec0260)
1493 nid = 0x17;
1494 ass = snd_hda_codec_get_pincfg(codec, nid);
1495
1496 if (!(ass & 1)) {
1497 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1498 codec->chip_name, ass);
1499 return -1;
1500 }
1501
1502 /* check sum */
1503 tmp = 0;
1504 for (i = 1; i < 16; i++) {
1505 if ((ass >> i) & 1)
1506 tmp++;
1507 }
1508 if (((ass >> 16) & 0xf) != tmp)
1509 return -1;
1510
1511 spec->cdefine.port_connectivity = ass >> 30;
1512 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1513 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1514 spec->cdefine.customization = ass >> 8;
1515do_sku:
1516 spec->cdefine.sku_cfg = ass;
1517 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1518 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1519 spec->cdefine.swap = (ass & 0x2) >> 1;
1520 spec->cdefine.override = ass & 0x1;
1521
1522 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1523 nid, spec->cdefine.sku_cfg);
1524 snd_printd("SKU: port_connectivity=0x%x\n",
1525 spec->cdefine.port_connectivity);
1526 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1527 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1528 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1529 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1530 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1531 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1532 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1533
1534 return 0;
1535}
1536
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001537/* check subsystem ID and set up device-specific initialization;
1538 * return 1 if initialized, 0 if invalid SSID
1539 */
1540/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1541 * 31 ~ 16 : Manufacture ID
1542 * 15 ~ 8 : SKU ID
1543 * 7 ~ 0 : Assembly ID
1544 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1545 */
1546static int alc_subsystem_id(struct hda_codec *codec,
1547 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001548 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001549{
1550 unsigned int ass, tmp, i;
1551 unsigned nid;
1552 struct alc_spec *spec = codec->spec;
1553
David Henningsson90622912010-10-14 14:50:18 +02001554 if (spec->cdefine.fixup) {
1555 ass = spec->cdefine.sku_cfg;
1556 if (ass == ALC_FIXUP_SKU_IGNORE)
1557 return 0;
1558 goto do_sku;
1559 }
1560
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001561 ass = codec->subsystem_id & 0xffff;
1562 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1563 goto do_sku;
1564
1565 /* invalid SSID, check the special NID pin defcfg instead */
1566 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001567 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001568 * 29~21 : reserve
1569 * 20 : PCBEEP input
1570 * 19~16 : Check sum (15:1)
1571 * 15~1 : Custom
1572 * 0 : override
1573 */
1574 nid = 0x1d;
1575 if (codec->vendor_id == 0x10ec0260)
1576 nid = 0x17;
1577 ass = snd_hda_codec_get_pincfg(codec, nid);
1578 snd_printd("realtek: No valid SSID, "
1579 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001580 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001581 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001582 return 0;
1583 if ((ass >> 30) != 1) /* no physical connection */
1584 return 0;
1585
1586 /* check sum */
1587 tmp = 0;
1588 for (i = 1; i < 16; i++) {
1589 if ((ass >> i) & 1)
1590 tmp++;
1591 }
1592 if (((ass >> 16) & 0xf) != tmp)
1593 return 0;
1594do_sku:
1595 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1596 ass & 0xffff, codec->vendor_id);
1597 /*
1598 * 0 : override
1599 * 1 : Swap Jack
1600 * 2 : 0 --> Desktop, 1 --> Laptop
1601 * 3~5 : External Amplifier control
1602 * 7~6 : Reserved
1603 */
1604 tmp = (ass & 0x38) >> 3; /* external Amp control */
1605 switch (tmp) {
1606 case 1:
1607 spec->init_amp = ALC_INIT_GPIO1;
1608 break;
1609 case 3:
1610 spec->init_amp = ALC_INIT_GPIO2;
1611 break;
1612 case 7:
1613 spec->init_amp = ALC_INIT_GPIO3;
1614 break;
1615 case 5:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +01001616 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001617 spec->init_amp = ALC_INIT_DEFAULT;
1618 break;
1619 }
1620
1621 /* is laptop or Desktop and enable the function "Mute internal speaker
1622 * when the external headphone out jack is plugged"
1623 */
1624 if (!(ass & 0x8000))
1625 return 1;
1626 /*
1627 * 10~8 : Jack location
1628 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1629 * 14~13: Resvered
1630 * 15 : 1 --> enable the function "Mute internal speaker
1631 * when the external headphone out jack is plugged"
1632 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001633 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001634 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001635 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1636 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001637 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001638 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001639 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001640 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001641 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001642 else if (tmp == 3)
1643 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001644 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001645 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001646 for (i = 0; i < spec->autocfg.line_outs; i++)
1647 if (spec->autocfg.line_out_pins[i] == nid)
1648 return 1;
1649 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001650 }
1651
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001652 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001653 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001654 return 1;
1655}
Kailang Yangea1fb292008-08-26 12:58:38 +02001656
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001657static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001658 hda_nid_t porta, hda_nid_t porte,
1659 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001660{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001661 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001662 struct alc_spec *spec = codec->spec;
1663 snd_printd("realtek: "
1664 "Enable default setup for auto mode as fallback\n");
1665 spec->init_amp = ALC_INIT_DEFAULT;
1666 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001667 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001668 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001669}
1670
Takashi Iwai41e41f12005-06-08 14:48:49 +02001671/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001672 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001673 */
1674
1675struct alc_pincfg {
1676 hda_nid_t nid;
1677 u32 val;
1678};
1679
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001680struct alc_fixup {
David Henningsson90622912010-10-14 14:50:18 +02001681 unsigned int sku;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001682 const struct alc_pincfg *pins;
1683 const struct hda_verb *verbs;
Takashi Iwai9d578832010-11-22 13:29:19 +01001684 void (*func)(struct hda_codec *codec, const struct alc_fixup *fix,
1685 int pre_init);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001686};
1687
1688static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001689 const struct snd_pci_quirk *quirk,
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001690 const struct alc_fixup *fix,
1691 int pre_init)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001692{
1693 const struct alc_pincfg *cfg;
David Henningsson90622912010-10-14 14:50:18 +02001694 struct alc_spec *spec;
Takashi Iwaif95474e2007-07-10 00:47:43 +02001695
1696 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1697 if (!quirk)
1698 return;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001699 fix += quirk->value;
1700 cfg = fix->pins;
David Henningsson90622912010-10-14 14:50:18 +02001701 if (pre_init && fix->sku) {
1702#ifdef CONFIG_SND_DEBUG_VERBOSE
1703 snd_printdd(KERN_INFO "hda_codec: %s: Apply sku override for %s\n",
1704 codec->chip_name, quirk->name);
1705#endif
1706 spec = codec->spec;
1707 spec->cdefine.sku_cfg = fix->sku;
1708 spec->cdefine.fixup = 1;
1709 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001710 if (pre_init && cfg) {
1711#ifdef CONFIG_SND_DEBUG_VERBOSE
1712 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1713 codec->chip_name, quirk->name);
1714#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001715 for (; cfg->nid; cfg++)
1716 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1717 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001718 if (!pre_init && fix->verbs) {
1719#ifdef CONFIG_SND_DEBUG_VERBOSE
1720 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1721 codec->chip_name, quirk->name);
1722#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001723 add_verb(codec->spec, fix->verbs);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001724 }
Takashi Iwai9d578832010-11-22 13:29:19 +01001725 if (fix->func) {
1726#ifdef CONFIG_SND_DEBUG_VERBOSE
1727 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-func for %s\n",
1728 codec->chip_name, quirk->name);
1729#endif
1730 fix->func(codec, fix, pre_init);
1731 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001732}
1733
Kailang Yang274693f2009-12-03 10:07:50 +01001734static int alc_read_coef_idx(struct hda_codec *codec,
1735 unsigned int coef_idx)
1736{
1737 unsigned int val;
1738 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1739 coef_idx);
1740 val = snd_hda_codec_read(codec, 0x20, 0,
1741 AC_VERB_GET_PROC_COEF, 0);
1742 return val;
1743}
1744
Kailang Yang977ddd62010-09-15 10:02:29 +02001745static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1746 unsigned int coef_val)
1747{
1748 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1749 coef_idx);
1750 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1751 coef_val);
1752}
1753
Takashi Iwai757899a2010-07-30 10:48:14 +02001754/* set right pin controls for digital I/O */
1755static void alc_auto_init_digital(struct hda_codec *codec)
1756{
1757 struct alc_spec *spec = codec->spec;
1758 int i;
1759 hda_nid_t pin;
1760
1761 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1762 pin = spec->autocfg.dig_out_pins[i];
1763 if (pin) {
1764 snd_hda_codec_write(codec, pin, 0,
1765 AC_VERB_SET_PIN_WIDGET_CONTROL,
1766 PIN_OUT);
1767 }
1768 }
1769 pin = spec->autocfg.dig_in_pin;
1770 if (pin)
1771 snd_hda_codec_write(codec, pin, 0,
1772 AC_VERB_SET_PIN_WIDGET_CONTROL,
1773 PIN_IN);
1774}
1775
1776/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1777static void alc_auto_parse_digital(struct hda_codec *codec)
1778{
1779 struct alc_spec *spec = codec->spec;
1780 int i, err;
1781 hda_nid_t dig_nid;
1782
1783 /* support multiple SPDIFs; the secondary is set up as a slave */
1784 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1785 err = snd_hda_get_connections(codec,
1786 spec->autocfg.dig_out_pins[i],
1787 &dig_nid, 1);
1788 if (err < 0)
1789 continue;
1790 if (!i) {
1791 spec->multiout.dig_out_nid = dig_nid;
1792 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1793 } else {
1794 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1795 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1796 break;
1797 spec->slave_dig_outs[i - 1] = dig_nid;
1798 }
1799 }
1800
1801 if (spec->autocfg.dig_in_pin) {
Takashi Iwai01fdf182010-09-24 09:09:42 +02001802 dig_nid = codec->start_nid;
1803 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1804 unsigned int wcaps = get_wcaps(codec, dig_nid);
1805 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1806 continue;
1807 if (!(wcaps & AC_WCAP_DIGITAL))
1808 continue;
1809 if (!(wcaps & AC_WCAP_CONN_LIST))
1810 continue;
1811 err = get_connection_index(codec, dig_nid,
1812 spec->autocfg.dig_in_pin);
1813 if (err >= 0) {
1814 spec->dig_in_nid = dig_nid;
1815 break;
1816 }
1817 }
Takashi Iwai757899a2010-07-30 10:48:14 +02001818 }
1819}
1820
Takashi Iwaif95474e2007-07-10 00:47:43 +02001821/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001822 * ALC888
1823 */
1824
1825/*
1826 * 2ch mode
1827 */
1828static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1829/* Mic-in jack as mic in */
1830 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1831 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1832/* Line-in jack as Line in */
1833 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1834 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1835/* Line-Out as Front */
1836 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1837 { } /* end */
1838};
1839
1840/*
1841 * 4ch mode
1842 */
1843static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1844/* Mic-in jack as mic in */
1845 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1846 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1847/* Line-in jack as Surround */
1848 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1849 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1850/* Line-Out as Front */
1851 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1852 { } /* end */
1853};
1854
1855/*
1856 * 6ch mode
1857 */
1858static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1859/* Mic-in jack as CLFE */
1860 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1861 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1862/* Line-in jack as Surround */
1863 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1864 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1865/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1866 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1867 { } /* end */
1868};
1869
1870/*
1871 * 8ch mode
1872 */
1873static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1874/* Mic-in jack as CLFE */
1875 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1876 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1877/* Line-in jack as Surround */
1878 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1879 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1880/* Line-Out as Side */
1881 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1882 { } /* end */
1883};
1884
1885static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1886 { 2, alc888_4ST_ch2_intel_init },
1887 { 4, alc888_4ST_ch4_intel_init },
1888 { 6, alc888_4ST_ch6_intel_init },
1889 { 8, alc888_4ST_ch8_intel_init },
1890};
1891
1892/*
1893 * ALC888 Fujitsu Siemens Amillo xa3530
1894 */
1895
1896static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1897/* Front Mic: set to PIN_IN (empty by default) */
1898 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1899/* Connect Internal HP to Front */
1900 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1901 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1902 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1903/* Connect Bass HP to Front */
1904 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1905 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1906 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1907/* Connect Line-Out side jack (SPDIF) to Side */
1908 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1909 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1910 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1911/* Connect Mic jack to CLFE */
1912 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1913 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1914 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1915/* Connect Line-in jack to Surround */
1916 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1917 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1918 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1919/* Connect HP out jack to Front */
1920 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1921 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1922 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1923/* Enable unsolicited event for HP jack and Line-out jack */
1924 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1925 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1926 {}
1927};
1928
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001929static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001930{
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001931 alc_automute_speaker(codec, 0);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001932}
1933
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001934static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1935 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001936{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001937 if (codec->vendor_id == 0x10ec0880)
1938 res >>= 28;
1939 else
1940 res >>= 26;
1941 if (res == ALC880_HP_EVENT)
1942 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001943}
1944
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001945static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001946{
1947 struct alc_spec *spec = codec->spec;
1948
1949 spec->autocfg.hp_pins[0] = 0x15;
1950 spec->autocfg.speaker_pins[0] = 0x14;
1951 spec->autocfg.speaker_pins[1] = 0x16;
1952 spec->autocfg.speaker_pins[2] = 0x17;
1953 spec->autocfg.speaker_pins[3] = 0x19;
1954 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001955}
1956
1957static void alc889_intel_init_hook(struct hda_codec *codec)
1958{
1959 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001960 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001961}
1962
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001963static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001964{
1965 struct alc_spec *spec = codec->spec;
1966
1967 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1968 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1969 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1970 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001971}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001972
1973/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001974 * ALC888 Acer Aspire 4930G model
1975 */
1976
1977static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1978/* Front Mic: set to PIN_IN (empty by default) */
1979 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1980/* Unselect Front Mic by default in input mixer 3 */
1981 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001982/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001983 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1984/* Connect Internal HP to front */
1985 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1986 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1987 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1988/* Connect HP out to front */
1989 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1990 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1991 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1992 { }
1993};
1994
Hector Martin3b315d72009-06-02 10:54:19 +02001995/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001996 * ALC888 Acer Aspire 6530G model
1997 */
1998
1999static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01002000/* Route to built-in subwoofer as well as speakers */
2001 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2002 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2003 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2004 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002005/* Bias voltage on for external mic port */
2006 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02002007/* Front Mic: set to PIN_IN (empty by default) */
2008 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2009/* Unselect Front Mic by default in input mixer 3 */
2010 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002011/* Enable unsolicited event for HP jack */
2012 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2013/* Enable speaker output */
2014 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2015 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01002016 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002017/* Enable headphone output */
2018 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2019 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2020 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01002021 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002022 { }
2023};
2024
2025/*
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002026 *ALC888 Acer Aspire 7730G model
2027 */
2028
2029static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
2030/* Bias voltage on for external mic port */
2031 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2032/* Front Mic: set to PIN_IN (empty by default) */
2033 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2034/* Unselect Front Mic by default in input mixer 3 */
2035 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2036/* Enable unsolicited event for HP jack */
2037 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2038/* Enable speaker output */
2039 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2040 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2041 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
2042/* Enable headphone output */
2043 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2044 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2045 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2046 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2047/*Enable internal subwoofer */
2048 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2049 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2050 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
2051 {0x17, AC_VERB_SET_EAPD_BTLENABLE, 2},
2052 { }
2053};
2054
2055/*
Hector Martin018df412009-06-04 00:13:40 +02002056 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02002057 */
2058
Hector Martin018df412009-06-04 00:13:40 +02002059static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02002060/* Front Mic: set to PIN_IN (empty by default) */
2061 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2062/* Unselect Front Mic by default in input mixer 3 */
2063 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2064/* Enable unsolicited event for HP jack */
2065 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2066/* Connect Internal Front to Front */
2067 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2068 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2069 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2070/* Connect Internal Rear to Rear */
2071 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2072 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2073 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
2074/* Connect Internal CLFE to CLFE */
2075 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2076 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2077 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2078/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02002079 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02002080 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2081 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2082/* Enable all DACs */
2083/* DAC DISABLE/MUTE 1? */
2084/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2085 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2086 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2087/* DAC DISABLE/MUTE 2? */
2088/* some bit here disables the other DACs. Init=0x4900 */
2089 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2090 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002091/* DMIC fix
2092 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2093 * which makes the stereo useless. However, either the mic or the ALC889
2094 * makes the signal become a difference/sum signal instead of standard
2095 * stereo, which is annoying. So instead we flip this bit which makes the
2096 * codec replicate the sum signal to both channels, turning it into a
2097 * normal mono mic.
2098 */
2099/* DMIC_CONTROL? Init value = 0x0001 */
2100 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2101 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002102 { }
2103};
2104
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002105static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002106 /* Front mic only available on one ADC */
2107 {
2108 .num_items = 4,
2109 .items = {
2110 { "Mic", 0x0 },
2111 { "Line", 0x2 },
2112 { "CD", 0x4 },
2113 { "Front Mic", 0xb },
2114 },
2115 },
2116 {
2117 .num_items = 3,
2118 .items = {
2119 { "Mic", 0x0 },
2120 { "Line", 0x2 },
2121 { "CD", 0x4 },
2122 },
2123 }
2124};
2125
Tony Vroond2fd4b02009-06-21 00:40:10 +01002126static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2127 /* Interal mic only available on one ADC */
2128 {
Tony Vroon684a8842009-06-26 09:27:50 +01002129 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002130 .items = {
2131 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002132 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002133 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002134 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002135 { "Int Mic", 0xb },
2136 },
2137 },
2138 {
Tony Vroon684a8842009-06-26 09:27:50 +01002139 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002140 .items = {
2141 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002142 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002143 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002144 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002145 },
2146 }
2147};
2148
Hector Martin018df412009-06-04 00:13:40 +02002149static struct hda_input_mux alc889_capture_sources[3] = {
2150 /* Digital mic only available on first "ADC" */
2151 {
2152 .num_items = 5,
2153 .items = {
2154 { "Mic", 0x0 },
2155 { "Line", 0x2 },
2156 { "CD", 0x4 },
2157 { "Front Mic", 0xb },
2158 { "Input Mix", 0xa },
2159 },
2160 },
2161 {
2162 .num_items = 4,
2163 .items = {
2164 { "Mic", 0x0 },
2165 { "Line", 0x2 },
2166 { "CD", 0x4 },
2167 { "Input Mix", 0xa },
2168 },
2169 },
2170 {
2171 .num_items = 4,
2172 .items = {
2173 { "Mic", 0x0 },
2174 { "Line", 0x2 },
2175 { "CD", 0x4 },
2176 { "Input Mix", 0xa },
2177 },
2178 }
2179};
2180
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002181static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002182 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2183 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2184 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2185 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2186 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2187 HDA_OUTPUT),
2188 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2189 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2190 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2191 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2192 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2193 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2194 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2195 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2196 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2197 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2198 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2199 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002200 { } /* end */
2201};
2202
Hector Martin556eea92009-12-20 22:51:23 +01002203static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2204 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2205 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2206 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2207 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2208 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2209 HDA_OUTPUT),
2210 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2211 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2212 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2213 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2214 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2216 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2217 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2218 { } /* end */
2219};
2220
2221
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002222static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002223{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002224 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002225
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002226 spec->autocfg.hp_pins[0] = 0x15;
2227 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002228 spec->autocfg.speaker_pins[1] = 0x16;
2229 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002230}
2231
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002232static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002233{
2234 struct alc_spec *spec = codec->spec;
2235
2236 spec->autocfg.hp_pins[0] = 0x15;
2237 spec->autocfg.speaker_pins[0] = 0x14;
2238 spec->autocfg.speaker_pins[1] = 0x16;
2239 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002240}
2241
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002242static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
2243{
2244 struct alc_spec *spec = codec->spec;
2245
2246 spec->autocfg.hp_pins[0] = 0x15;
2247 spec->autocfg.speaker_pins[0] = 0x14;
2248 spec->autocfg.speaker_pins[1] = 0x16;
2249 spec->autocfg.speaker_pins[2] = 0x17;
2250}
2251
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002252static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002253{
2254 struct alc_spec *spec = codec->spec;
2255
2256 spec->autocfg.hp_pins[0] = 0x15;
2257 spec->autocfg.speaker_pins[0] = 0x14;
2258 spec->autocfg.speaker_pins[1] = 0x16;
2259 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002260}
2261
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002262/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002263 * ALC880 3-stack model
2264 *
2265 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002266 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2267 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002268 */
2269
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002270static hda_nid_t alc880_dac_nids[4] = {
2271 /* front, rear, clfe, rear_surr */
2272 0x02, 0x05, 0x04, 0x03
2273};
2274
2275static hda_nid_t alc880_adc_nids[3] = {
2276 /* ADC0-2 */
2277 0x07, 0x08, 0x09,
2278};
2279
2280/* The datasheet says the node 0x07 is connected from inputs,
2281 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002282 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002283 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002284static hda_nid_t alc880_adc_nids_alt[2] = {
2285 /* ADC1-2 */
2286 0x08, 0x09,
2287};
2288
2289#define ALC880_DIGOUT_NID 0x06
2290#define ALC880_DIGIN_NID 0x0a
2291
2292static struct hda_input_mux alc880_capture_source = {
2293 .num_items = 4,
2294 .items = {
2295 { "Mic", 0x0 },
2296 { "Front Mic", 0x3 },
2297 { "Line", 0x2 },
2298 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002299 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002300};
2301
2302/* channel source setting (2/6 channel selection for 3-stack) */
2303/* 2ch mode */
2304static struct hda_verb alc880_threestack_ch2_init[] = {
2305 /* set line-in to input, mute it */
2306 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2307 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2308 /* set mic-in to input vref 80%, mute it */
2309 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2310 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002311 { } /* end */
2312};
2313
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002314/* 6ch mode */
2315static struct hda_verb alc880_threestack_ch6_init[] = {
2316 /* set line-in to output, unmute it */
2317 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2318 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2319 /* set mic-in to output, unmute it */
2320 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2321 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2322 { } /* end */
2323};
2324
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002325static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002326 { 2, alc880_threestack_ch2_init },
2327 { 6, alc880_threestack_ch6_init },
2328};
2329
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002330static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002331 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002332 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002333 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002334 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002335 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2336 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002337 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2338 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002339 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2340 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2341 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2342 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2343 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2344 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2345 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2346 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002347 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002348 {
2349 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2350 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002351 .info = alc_ch_mode_info,
2352 .get = alc_ch_mode_get,
2353 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002354 },
2355 { } /* end */
2356};
2357
2358/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002359static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2360 struct snd_ctl_elem_info *uinfo)
2361{
2362 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2363 struct alc_spec *spec = codec->spec;
2364 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002365
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002366 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002367 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2368 HDA_INPUT);
2369 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002370 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002371 return err;
2372}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002373
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002374static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2375 unsigned int size, unsigned int __user *tlv)
2376{
2377 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2378 struct alc_spec *spec = codec->spec;
2379 int err;
2380
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002381 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002382 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2383 HDA_INPUT);
2384 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002385 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002386 return err;
2387}
2388
2389typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2390 struct snd_ctl_elem_value *ucontrol);
2391
2392static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2393 struct snd_ctl_elem_value *ucontrol,
2394 getput_call_t func)
2395{
2396 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2397 struct alc_spec *spec = codec->spec;
2398 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2399 int err;
2400
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002401 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002402 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2403 3, 0, HDA_INPUT);
2404 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002405 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002406 return err;
2407}
2408
2409static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2410 struct snd_ctl_elem_value *ucontrol)
2411{
2412 return alc_cap_getput_caller(kcontrol, ucontrol,
2413 snd_hda_mixer_amp_volume_get);
2414}
2415
2416static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2417 struct snd_ctl_elem_value *ucontrol)
2418{
2419 return alc_cap_getput_caller(kcontrol, ucontrol,
2420 snd_hda_mixer_amp_volume_put);
2421}
2422
2423/* capture mixer elements */
2424#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2425
2426static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2427 struct snd_ctl_elem_value *ucontrol)
2428{
2429 return alc_cap_getput_caller(kcontrol, ucontrol,
2430 snd_hda_mixer_amp_switch_get);
2431}
2432
2433static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2434 struct snd_ctl_elem_value *ucontrol)
2435{
2436 return alc_cap_getput_caller(kcontrol, ucontrol,
2437 snd_hda_mixer_amp_switch_put);
2438}
2439
Takashi Iwaia23b6882009-03-23 15:21:36 +01002440#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002441 { \
2442 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2443 .name = "Capture Switch", \
2444 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2445 .count = num, \
2446 .info = alc_cap_sw_info, \
2447 .get = alc_cap_sw_get, \
2448 .put = alc_cap_sw_put, \
2449 }, \
2450 { \
2451 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2452 .name = "Capture Volume", \
2453 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2454 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2455 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2456 .count = num, \
2457 .info = alc_cap_vol_info, \
2458 .get = alc_cap_vol_get, \
2459 .put = alc_cap_vol_put, \
2460 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002461 }
2462
2463#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002464 { \
2465 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2466 /* .name = "Capture Source", */ \
2467 .name = "Input Source", \
2468 .count = num, \
2469 .info = alc_mux_enum_info, \
2470 .get = alc_mux_enum_get, \
2471 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002472 }
2473
2474#define DEFINE_CAPMIX(num) \
2475static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2476 _DEFINE_CAPMIX(num), \
2477 _DEFINE_CAPSRC(num), \
2478 { } /* end */ \
2479}
2480
2481#define DEFINE_CAPMIX_NOSRC(num) \
2482static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2483 _DEFINE_CAPMIX(num), \
2484 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002485}
2486
2487/* up to three ADCs */
2488DEFINE_CAPMIX(1);
2489DEFINE_CAPMIX(2);
2490DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002491DEFINE_CAPMIX_NOSRC(1);
2492DEFINE_CAPMIX_NOSRC(2);
2493DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002494
2495/*
2496 * ALC880 5-stack model
2497 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002498 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2499 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002500 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2501 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2502 */
2503
2504/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002505static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002506 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002507 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002508 { } /* end */
2509};
2510
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002511/* channel source setting (6/8 channel selection for 5-stack) */
2512/* 6ch mode */
2513static struct hda_verb alc880_fivestack_ch6_init[] = {
2514 /* set line-in to input, mute it */
2515 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2516 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002517 { } /* end */
2518};
2519
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002520/* 8ch mode */
2521static struct hda_verb alc880_fivestack_ch8_init[] = {
2522 /* set line-in to output, unmute it */
2523 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2524 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2525 { } /* end */
2526};
2527
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002528static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002529 { 6, alc880_fivestack_ch6_init },
2530 { 8, alc880_fivestack_ch8_init },
2531};
2532
2533
2534/*
2535 * ALC880 6-stack model
2536 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002537 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2538 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002539 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2540 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2541 */
2542
2543static hda_nid_t alc880_6st_dac_nids[4] = {
2544 /* front, rear, clfe, rear_surr */
2545 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002546};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002547
2548static struct hda_input_mux alc880_6stack_capture_source = {
2549 .num_items = 4,
2550 .items = {
2551 { "Mic", 0x0 },
2552 { "Front Mic", 0x1 },
2553 { "Line", 0x2 },
2554 { "CD", 0x4 },
2555 },
2556};
2557
2558/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002559static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002560 { 8, NULL },
2561};
2562
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002563static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002564 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002565 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002566 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002567 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002568 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2569 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002570 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2571 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002572 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002573 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002574 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2575 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2576 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2577 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2578 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2579 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2580 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2581 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002582 {
2583 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2584 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002585 .info = alc_ch_mode_info,
2586 .get = alc_ch_mode_get,
2587 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002588 },
2589 { } /* end */
2590};
2591
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002592
2593/*
2594 * ALC880 W810 model
2595 *
2596 * W810 has rear IO for:
2597 * Front (DAC 02)
2598 * Surround (DAC 03)
2599 * Center/LFE (DAC 04)
2600 * Digital out (06)
2601 *
2602 * The system also has a pair of internal speakers, and a headphone jack.
2603 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002604 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002605 * There is a variable resistor to control the speaker or headphone
2606 * volume. This is a hardware-only device without a software API.
2607 *
2608 * Plugging headphones in will disable the internal speakers. This is
2609 * implemented in hardware, not via the driver using jack sense. In
2610 * a similar fashion, plugging into the rear socket marked "front" will
2611 * disable both the speakers and headphones.
2612 *
2613 * For input, there's a microphone jack, and an "audio in" jack.
2614 * These may not do anything useful with this driver yet, because I
2615 * haven't setup any initialization verbs for these yet...
2616 */
2617
2618static hda_nid_t alc880_w810_dac_nids[3] = {
2619 /* front, rear/surround, clfe */
2620 0x02, 0x03, 0x04
2621};
2622
2623/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002624static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002625 { 6, NULL }
2626};
2627
2628/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002629static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002630 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002631 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002632 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002633 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002634 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2635 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002636 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2637 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002638 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2639 { } /* end */
2640};
2641
2642
2643/*
2644 * Z710V model
2645 *
2646 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002647 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2648 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002649 */
2650
2651static hda_nid_t alc880_z71v_dac_nids[1] = {
2652 0x02
2653};
2654#define ALC880_Z71V_HP_DAC 0x03
2655
2656/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002657static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002658 { 2, NULL }
2659};
2660
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002661static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002662 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002663 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002664 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002665 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002666 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2667 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2668 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2669 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2670 { } /* end */
2671};
2672
2673
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002674/*
2675 * ALC880 F1734 model
2676 *
2677 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2678 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2679 */
2680
2681static hda_nid_t alc880_f1734_dac_nids[1] = {
2682 0x03
2683};
2684#define ALC880_F1734_HP_DAC 0x02
2685
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002686static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002687 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002688 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002689 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2690 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002691 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2692 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002693 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2694 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002695 { } /* end */
2696};
2697
Takashi Iwai937b4162008-02-11 14:52:36 +01002698static struct hda_input_mux alc880_f1734_capture_source = {
2699 .num_items = 2,
2700 .items = {
2701 { "Mic", 0x1 },
2702 { "CD", 0x4 },
2703 },
2704};
2705
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002706
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002707/*
2708 * ALC880 ASUS model
2709 *
2710 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2711 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2712 * Mic = 0x18, Line = 0x1a
2713 */
2714
2715#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2716#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2717
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002718static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002719 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002720 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002721 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002722 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002723 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2724 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002725 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2726 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002727 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2728 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2729 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2730 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2731 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2732 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002733 {
2734 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2735 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002736 .info = alc_ch_mode_info,
2737 .get = alc_ch_mode_get,
2738 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002739 },
2740 { } /* end */
2741};
2742
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002743/*
2744 * ALC880 ASUS W1V model
2745 *
2746 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2747 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2748 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2749 */
2750
2751/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002752static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002753 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2754 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002755 { } /* end */
2756};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002757
Kailang Yangdf694da2005-12-05 19:42:22 +01002758/* TCL S700 */
2759static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2760 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2761 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2762 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2763 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2764 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2765 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2766 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2767 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2768 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002769 { } /* end */
2770};
2771
Kailang Yangccc656c2006-10-17 12:32:26 +02002772/* Uniwill */
2773static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002774 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2775 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2776 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2777 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002778 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2779 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2780 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2781 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2782 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2783 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2784 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2785 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2786 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2787 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2788 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2789 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002790 {
2791 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2792 .name = "Channel Mode",
2793 .info = alc_ch_mode_info,
2794 .get = alc_ch_mode_get,
2795 .put = alc_ch_mode_put,
2796 },
2797 { } /* end */
2798};
2799
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002800static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2801 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2802 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2803 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2804 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2805 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2806 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2807 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2808 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2809 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2810 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2811 { } /* end */
2812};
2813
Kailang Yangccc656c2006-10-17 12:32:26 +02002814static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002815 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2816 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2817 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2818 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2820 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2821 { } /* end */
2822};
2823
Linus Torvalds1da177e2005-04-16 15:20:36 -07002824/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002825 * virtual master controls
2826 */
2827
2828/*
2829 * slave controls for virtual master
2830 */
2831static const char *alc_slave_vols[] = {
2832 "Front Playback Volume",
2833 "Surround Playback Volume",
2834 "Center Playback Volume",
2835 "LFE Playback Volume",
2836 "Side Playback Volume",
2837 "Headphone Playback Volume",
2838 "Speaker Playback Volume",
2839 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002840 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002841 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002842 NULL,
2843};
2844
2845static const char *alc_slave_sws[] = {
2846 "Front Playback Switch",
2847 "Surround Playback Switch",
2848 "Center Playback Switch",
2849 "LFE Playback Switch",
2850 "Side Playback Switch",
2851 "Headphone Playback Switch",
2852 "Speaker Playback Switch",
2853 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002854 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002855 "Line-Out Playback Switch",
2856 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002857 NULL,
2858};
2859
2860/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002861 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002862 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002863
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002864#define NID_MAPPING (-1)
2865
2866#define SUBDEV_SPEAKER_ (0 << 6)
2867#define SUBDEV_HP_ (1 << 6)
2868#define SUBDEV_LINE_ (2 << 6)
2869#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2870#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2871#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2872
Takashi Iwai603c4012008-07-30 15:01:44 +02002873static void alc_free_kctls(struct hda_codec *codec);
2874
Takashi Iwai67d634c2009-11-16 15:35:59 +01002875#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002876/* additional beep mixers; the actual parameters are overwritten at build */
2877static struct snd_kcontrol_new alc_beep_mixer[] = {
2878 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002879 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002880 { } /* end */
2881};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002882#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002883
Linus Torvalds1da177e2005-04-16 15:20:36 -07002884static int alc_build_controls(struct hda_codec *codec)
2885{
2886 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002887 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002888 struct snd_kcontrol_new *knew;
2889 int i, j, err;
2890 unsigned int u;
2891 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002892
2893 for (i = 0; i < spec->num_mixers; i++) {
2894 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2895 if (err < 0)
2896 return err;
2897 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002898 if (spec->cap_mixer) {
2899 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2900 if (err < 0)
2901 return err;
2902 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002903 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002904 err = snd_hda_create_spdif_out_ctls(codec,
2905 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002906 if (err < 0)
2907 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002908 if (!spec->no_analog) {
2909 err = snd_hda_create_spdif_share_sw(codec,
2910 &spec->multiout);
2911 if (err < 0)
2912 return err;
2913 spec->multiout.share_spdif = 1;
2914 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002915 }
2916 if (spec->dig_in_nid) {
2917 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2918 if (err < 0)
2919 return err;
2920 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002921
Takashi Iwai67d634c2009-11-16 15:35:59 +01002922#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002923 /* create beep controls if needed */
2924 if (spec->beep_amp) {
2925 struct snd_kcontrol_new *knew;
2926 for (knew = alc_beep_mixer; knew->name; knew++) {
2927 struct snd_kcontrol *kctl;
2928 kctl = snd_ctl_new1(knew, codec);
2929 if (!kctl)
2930 return -ENOMEM;
2931 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002932 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002933 if (err < 0)
2934 return err;
2935 }
2936 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002937#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002938
Takashi Iwai2134ea42008-01-10 16:53:55 +01002939 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002940 if (!spec->no_analog &&
2941 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002942 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002943 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002944 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002945 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002946 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002947 if (err < 0)
2948 return err;
2949 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002950 if (!spec->no_analog &&
2951 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002952 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2953 NULL, alc_slave_sws);
2954 if (err < 0)
2955 return err;
2956 }
2957
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002958 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002959 if (spec->capsrc_nids || spec->adc_nids) {
2960 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2961 if (!kctl)
2962 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2963 for (i = 0; kctl && i < kctl->count; i++) {
2964 hda_nid_t *nids = spec->capsrc_nids;
2965 if (!nids)
2966 nids = spec->adc_nids;
2967 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
2968 if (err < 0)
2969 return err;
2970 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002971 }
2972 if (spec->cap_mixer) {
2973 const char *kname = kctl ? kctl->id.name : NULL;
2974 for (knew = spec->cap_mixer; knew->name; knew++) {
2975 if (kname && strcmp(knew->name, kname) == 0)
2976 continue;
2977 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2978 for (i = 0; kctl && i < kctl->count; i++) {
2979 err = snd_hda_add_nid(codec, kctl, i,
2980 spec->adc_nids[i]);
2981 if (err < 0)
2982 return err;
2983 }
2984 }
2985 }
2986
2987 /* other nid->control mapping */
2988 for (i = 0; i < spec->num_mixers; i++) {
2989 for (knew = spec->mixers[i]; knew->name; knew++) {
2990 if (knew->iface != NID_MAPPING)
2991 continue;
2992 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2993 if (kctl == NULL)
2994 continue;
2995 u = knew->subdevice;
2996 for (j = 0; j < 4; j++, u >>= 8) {
2997 nid = u & 0x3f;
2998 if (nid == 0)
2999 continue;
3000 switch (u & 0xc0) {
3001 case SUBDEV_SPEAKER_:
3002 nid = spec->autocfg.speaker_pins[nid];
3003 break;
3004 case SUBDEV_LINE_:
3005 nid = spec->autocfg.line_out_pins[nid];
3006 break;
3007 case SUBDEV_HP_:
3008 nid = spec->autocfg.hp_pins[nid];
3009 break;
3010 default:
3011 continue;
3012 }
3013 err = snd_hda_add_nid(codec, kctl, 0, nid);
3014 if (err < 0)
3015 return err;
3016 }
3017 u = knew->private_value;
3018 for (j = 0; j < 4; j++, u >>= 8) {
3019 nid = u & 0xff;
3020 if (nid == 0)
3021 continue;
3022 err = snd_hda_add_nid(codec, kctl, 0, nid);
3023 if (err < 0)
3024 return err;
3025 }
3026 }
3027 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01003028
3029 alc_free_kctls(codec); /* no longer needed */
3030
Linus Torvalds1da177e2005-04-16 15:20:36 -07003031 return 0;
3032}
3033
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003034
Linus Torvalds1da177e2005-04-16 15:20:36 -07003035/*
3036 * initialize the codec volumes, etc
3037 */
3038
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003039/*
3040 * generic initialization of ADC, input mixers and output mixers
3041 */
3042static struct hda_verb alc880_volume_init_verbs[] = {
3043 /*
3044 * Unmute ADC0-2 and set the default input to mic-in
3045 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003046 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003047 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003048 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003049 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003050 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003051 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003052
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003053 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3054 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003055 * Note: PASD motherboards uses the Line In 2 as the input for front
3056 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003057 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003058 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003059 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3060 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3061 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3062 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3063 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3065 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003066
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003067 /*
3068 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003069 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003070 /* set vol=0 to output mixers */
3071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3072 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3073 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3074 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3075 /* set up input amps for analog loopback */
3076 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003077 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3078 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003079 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3080 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003081 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3082 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003083 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3084 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003085
3086 { }
3087};
3088
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003089/*
3090 * 3-stack pin configuration:
3091 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3092 */
3093static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3094 /*
3095 * preset connection lists of input pins
3096 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3097 */
3098 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3099 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3100 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3101
3102 /*
3103 * Set pin mode and muting
3104 */
3105 /* set front pin widgets 0x14 for output */
3106 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3107 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3108 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3109 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3110 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3111 /* Mic2 (as headphone out) for HP output */
3112 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3113 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3114 /* Line In pin widget for input */
3115 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3116 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3117 /* Line2 (as front mic) pin widget for input and vref at 80% */
3118 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3119 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3120 /* CD pin widget for input */
3121 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3122
3123 { }
3124};
3125
3126/*
3127 * 5-stack pin configuration:
3128 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3129 * line-in/side = 0x1a, f-mic = 0x1b
3130 */
3131static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3132 /*
3133 * preset connection lists of input pins
3134 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3135 */
3136 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3137 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3138
3139 /*
3140 * Set pin mode and muting
3141 */
3142 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003143 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3144 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3145 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3146 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003147 /* unmute pins for output (no gain on this amp) */
3148 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3149 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3150 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3151 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3152
Linus Torvalds1da177e2005-04-16 15:20:36 -07003153 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003154 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003155 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3156 /* Mic2 (as headphone out) for HP output */
3157 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003158 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003159 /* Line In pin widget for input */
3160 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3161 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3162 /* Line2 (as front mic) pin widget for input and vref at 80% */
3163 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3164 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3165 /* CD pin widget for input */
3166 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003167
3168 { }
3169};
3170
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003171/*
3172 * W810 pin configuration:
3173 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3174 */
3175static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003176 /* hphone/speaker input selector: front DAC */
3177 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3178
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003179 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3180 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3181 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3182 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3183 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3184 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3185
3186 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003187 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003188
Linus Torvalds1da177e2005-04-16 15:20:36 -07003189 { }
3190};
3191
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003192/*
3193 * Z71V pin configuration:
3194 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3195 */
3196static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003197 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003198 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003199 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003200 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003201
Takashi Iwai16ded522005-06-10 19:58:24 +02003202 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003203 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003204 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003205 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003206
3207 { }
3208};
3209
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003210/*
3211 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003212 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3213 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003214 */
3215static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3216 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3217
Takashi Iwai16ded522005-06-10 19:58:24 +02003218 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003219 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003220 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003221 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003222 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003223 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003224 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003225 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3226
Takashi Iwai16ded522005-06-10 19:58:24 +02003227 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003228 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003229 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003230 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003231 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003232 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003233 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003234 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003235 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003236
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003237 { }
3238};
Takashi Iwai16ded522005-06-10 19:58:24 +02003239
Kailang Yangccc656c2006-10-17 12:32:26 +02003240/*
3241 * Uniwill pin configuration:
3242 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3243 * line = 0x1a
3244 */
3245static struct hda_verb alc880_uniwill_init_verbs[] = {
3246 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3247
3248 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3249 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3250 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3251 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3252 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3253 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3254 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3255 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3256 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3258 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3259 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3260 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3261 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3262
3263 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3264 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3265 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3266 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3267 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3268 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3269 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3270 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3271 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3272
3273 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3274 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3275
3276 { }
3277};
3278
3279/*
3280* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003281* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003282 */
3283static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3284 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3285
3286 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3287 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3288 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3289 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3290 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3291 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3292 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3293 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3294 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3295 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3296 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3297 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3298
3299 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3300 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3301 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3302 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3303 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3304 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3305
3306 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3307 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3308
3309 { }
3310};
3311
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003312static struct hda_verb alc880_beep_init_verbs[] = {
3313 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3314 { }
3315};
3316
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003317/* auto-toggle front mic */
3318static void alc880_uniwill_mic_automute(struct hda_codec *codec)
3319{
3320 unsigned int present;
3321 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003322
Wu Fengguang864f92b2009-11-18 12:38:02 +08003323 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003324 bits = present ? HDA_AMP_MUTE : 0;
3325 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003326}
3327
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003328static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003329{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003330 struct alc_spec *spec = codec->spec;
3331
3332 spec->autocfg.hp_pins[0] = 0x14;
3333 spec->autocfg.speaker_pins[0] = 0x15;
3334 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003335}
3336
3337static void alc880_uniwill_init_hook(struct hda_codec *codec)
3338{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003339 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003340 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003341}
3342
3343static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3344 unsigned int res)
3345{
3346 /* Looks like the unsol event is incompatible with the standard
3347 * definition. 4bit tag is placed at 28 bit!
3348 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003349 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003350 case ALC880_MIC_EVENT:
3351 alc880_uniwill_mic_automute(codec);
3352 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003353 default:
3354 alc_automute_amp_unsol_event(codec, res);
3355 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003356 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003357}
3358
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003359static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003360{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003361 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003362
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003363 spec->autocfg.hp_pins[0] = 0x14;
3364 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003365}
3366
3367static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3368{
3369 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003370
Kailang Yangccc656c2006-10-17 12:32:26 +02003371 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003372 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3373 present &= HDA_AMP_VOLMASK;
3374 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3375 HDA_AMP_VOLMASK, present);
3376 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3377 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003378}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003379
Kailang Yangccc656c2006-10-17 12:32:26 +02003380static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3381 unsigned int res)
3382{
3383 /* Looks like the unsol event is incompatible with the standard
3384 * definition. 4bit tag is placed at 28 bit!
3385 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003386 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003387 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003388 else
3389 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003390}
3391
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003392/*
3393 * F1734 pin configuration:
3394 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3395 */
3396static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003397 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003398 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3399 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3400 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3401 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3402
3403 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3404 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3405 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3406 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3407
3408 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3409 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003410 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003411 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3412 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3413 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3414 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3415 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3416 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003417
Takashi Iwai937b4162008-02-11 14:52:36 +01003418 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3419 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3420
Takashi Iwai16ded522005-06-10 19:58:24 +02003421 { }
3422};
3423
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003424/*
3425 * ASUS pin configuration:
3426 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3427 */
3428static struct hda_verb alc880_pin_asus_init_verbs[] = {
3429 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3430 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3431 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3432 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3433
3434 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3435 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3436 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3437 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3438 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3439 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3440 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3441 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3442
3443 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3445 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3446 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3447 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3448 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3449 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3450 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3451 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003452
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003453 { }
3454};
3455
3456/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003457#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3458#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003459#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003460
Kailang Yangdf694da2005-12-05 19:42:22 +01003461/* Clevo m520g init */
3462static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3463 /* headphone output */
3464 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3465 /* line-out */
3466 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3467 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3468 /* Line-in */
3469 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3470 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3471 /* CD */
3472 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3473 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3474 /* Mic1 (rear panel) */
3475 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3476 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3477 /* Mic2 (front panel) */
3478 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3479 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3480 /* headphone */
3481 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3482 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3483 /* change to EAPD mode */
3484 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3485 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3486
3487 { }
3488};
3489
3490static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003491 /* change to EAPD mode */
3492 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3493 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3494
Kailang Yangdf694da2005-12-05 19:42:22 +01003495 /* Headphone output */
3496 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3497 /* Front output*/
3498 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3499 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3500
3501 /* Line In pin widget for input */
3502 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3503 /* CD pin widget for input */
3504 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3505 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3506 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3507
3508 /* change to EAPD mode */
3509 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3510 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3511
3512 { }
3513};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003514
3515/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003516 * LG m1 express dual
3517 *
3518 * Pin assignment:
3519 * Rear Line-In/Out (blue): 0x14
3520 * Build-in Mic-In: 0x15
3521 * Speaker-out: 0x17
3522 * HP-Out (green): 0x1b
3523 * Mic-In/Out (red): 0x19
3524 * SPDIF-Out: 0x1e
3525 */
3526
3527/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3528static hda_nid_t alc880_lg_dac_nids[3] = {
3529 0x05, 0x02, 0x03
3530};
3531
3532/* seems analog CD is not working */
3533static struct hda_input_mux alc880_lg_capture_source = {
3534 .num_items = 3,
3535 .items = {
3536 { "Mic", 0x1 },
3537 { "Line", 0x5 },
3538 { "Internal Mic", 0x6 },
3539 },
3540};
3541
3542/* 2,4,6 channel modes */
3543static struct hda_verb alc880_lg_ch2_init[] = {
3544 /* set line-in and mic-in to input */
3545 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3546 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3547 { }
3548};
3549
3550static struct hda_verb alc880_lg_ch4_init[] = {
3551 /* set line-in to out and mic-in to input */
3552 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3553 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3554 { }
3555};
3556
3557static struct hda_verb alc880_lg_ch6_init[] = {
3558 /* set line-in and mic-in to output */
3559 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3560 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3561 { }
3562};
3563
3564static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3565 { 2, alc880_lg_ch2_init },
3566 { 4, alc880_lg_ch4_init },
3567 { 6, alc880_lg_ch6_init },
3568};
3569
3570static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003571 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3572 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003573 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3574 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3575 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3576 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3577 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3578 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3579 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3580 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3581 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3582 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3583 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3584 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3585 {
3586 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3587 .name = "Channel Mode",
3588 .info = alc_ch_mode_info,
3589 .get = alc_ch_mode_get,
3590 .put = alc_ch_mode_put,
3591 },
3592 { } /* end */
3593};
3594
3595static struct hda_verb alc880_lg_init_verbs[] = {
3596 /* set capture source to mic-in */
3597 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3598 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3599 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3600 /* mute all amp mixer inputs */
3601 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003602 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3603 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003604 /* line-in to input */
3605 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3606 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3607 /* built-in mic */
3608 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3609 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3610 /* speaker-out */
3611 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3612 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3613 /* mic-in to input */
3614 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3615 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3616 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3617 /* HP-out */
3618 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3619 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3620 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3621 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003622 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003623 { }
3624};
3625
3626/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003627static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003628{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003629 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003630
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003631 spec->autocfg.hp_pins[0] = 0x1b;
3632 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003633}
3634
3635/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003636 * LG LW20
3637 *
3638 * Pin assignment:
3639 * Speaker-out: 0x14
3640 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003641 * Built-in Mic-In: 0x19
3642 * Line-In: 0x1b
3643 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003644 * SPDIF-Out: 0x1e
3645 */
3646
Takashi Iwaid6815182006-03-23 16:06:23 +01003647static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003648 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003649 .items = {
3650 { "Mic", 0x0 },
3651 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003652 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003653 },
3654};
3655
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003656#define alc880_lg_lw_modes alc880_threestack_modes
3657
Takashi Iwaid6815182006-03-23 16:06:23 +01003658static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003659 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3660 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3661 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3662 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3663 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3664 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3665 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3666 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3667 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3668 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003669 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3670 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3671 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3672 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003673 {
3674 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3675 .name = "Channel Mode",
3676 .info = alc_ch_mode_info,
3677 .get = alc_ch_mode_get,
3678 .put = alc_ch_mode_put,
3679 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003680 { } /* end */
3681};
3682
3683static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003684 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3685 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3686 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3687
Takashi Iwaid6815182006-03-23 16:06:23 +01003688 /* set capture source to mic-in */
3689 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3690 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3691 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003692 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003693 /* speaker-out */
3694 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3695 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3696 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003697 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3698 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3699 /* mic-in to input */
3700 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3701 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3702 /* built-in mic */
3703 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3704 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3705 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003706 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003707 { }
3708};
3709
3710/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003711static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003712{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003713 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003714
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003715 spec->autocfg.hp_pins[0] = 0x1b;
3716 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003717}
3718
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003719static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3720 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3721 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3722 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3723 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3724 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3725 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3726 { } /* end */
3727};
3728
3729static struct hda_input_mux alc880_medion_rim_capture_source = {
3730 .num_items = 2,
3731 .items = {
3732 { "Mic", 0x0 },
3733 { "Internal Mic", 0x1 },
3734 },
3735};
3736
3737static struct hda_verb alc880_medion_rim_init_verbs[] = {
3738 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3739
3740 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3741 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3742
3743 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3744 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3745 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3746 /* Mic2 (as headphone out) for HP output */
3747 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3748 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3749 /* Internal Speaker */
3750 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3751 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3752
3753 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3754 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3755
3756 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3757 { }
3758};
3759
3760/* toggle speaker-output according to the hp-jack state */
3761static void alc880_medion_rim_automute(struct hda_codec *codec)
3762{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003763 struct alc_spec *spec = codec->spec;
3764 alc_automute_amp(codec);
3765 /* toggle EAPD */
3766 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003767 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3768 else
3769 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3770}
3771
3772static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3773 unsigned int res)
3774{
3775 /* Looks like the unsol event is incompatible with the standard
3776 * definition. 4bit tag is placed at 28 bit!
3777 */
3778 if ((res >> 28) == ALC880_HP_EVENT)
3779 alc880_medion_rim_automute(codec);
3780}
3781
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003782static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003783{
3784 struct alc_spec *spec = codec->spec;
3785
3786 spec->autocfg.hp_pins[0] = 0x14;
3787 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003788}
3789
Takashi Iwaicb53c622007-08-10 17:21:45 +02003790#ifdef CONFIG_SND_HDA_POWER_SAVE
3791static struct hda_amp_list alc880_loopbacks[] = {
3792 { 0x0b, HDA_INPUT, 0 },
3793 { 0x0b, HDA_INPUT, 1 },
3794 { 0x0b, HDA_INPUT, 2 },
3795 { 0x0b, HDA_INPUT, 3 },
3796 { 0x0b, HDA_INPUT, 4 },
3797 { } /* end */
3798};
3799
3800static struct hda_amp_list alc880_lg_loopbacks[] = {
3801 { 0x0b, HDA_INPUT, 1 },
3802 { 0x0b, HDA_INPUT, 6 },
3803 { 0x0b, HDA_INPUT, 7 },
3804 { } /* end */
3805};
3806#endif
3807
Takashi Iwaid6815182006-03-23 16:06:23 +01003808/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003809 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003810 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003811
Linus Torvalds1da177e2005-04-16 15:20:36 -07003812static int alc_init(struct hda_codec *codec)
3813{
3814 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003815 unsigned int i;
3816
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003817 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003818 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003819
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003820 for (i = 0; i < spec->num_init_verbs; i++)
3821 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003822
3823 if (spec->init_hook)
3824 spec->init_hook(codec);
3825
Takashi Iwai9e5341b2010-09-21 09:57:06 +02003826 hda_call_check_power_status(codec, 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003827 return 0;
3828}
3829
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003830static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3831{
3832 struct alc_spec *spec = codec->spec;
3833
3834 if (spec->unsol_event)
3835 spec->unsol_event(codec, res);
3836}
3837
Takashi Iwaicb53c622007-08-10 17:21:45 +02003838#ifdef CONFIG_SND_HDA_POWER_SAVE
3839static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3840{
3841 struct alc_spec *spec = codec->spec;
3842 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3843}
3844#endif
3845
Linus Torvalds1da177e2005-04-16 15:20:36 -07003846/*
3847 * Analog playback callbacks
3848 */
3849static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3850 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003851 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003852{
3853 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003854 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3855 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003856}
3857
3858static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3859 struct hda_codec *codec,
3860 unsigned int stream_tag,
3861 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003862 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003863{
3864 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003865 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3866 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003867}
3868
3869static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3870 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003871 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003872{
3873 struct alc_spec *spec = codec->spec;
3874 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3875}
3876
3877/*
3878 * Digital out
3879 */
3880static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3881 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003882 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003883{
3884 struct alc_spec *spec = codec->spec;
3885 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3886}
3887
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003888static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3889 struct hda_codec *codec,
3890 unsigned int stream_tag,
3891 unsigned int format,
3892 struct snd_pcm_substream *substream)
3893{
3894 struct alc_spec *spec = codec->spec;
3895 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3896 stream_tag, format, substream);
3897}
3898
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003899static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3900 struct hda_codec *codec,
3901 struct snd_pcm_substream *substream)
3902{
3903 struct alc_spec *spec = codec->spec;
3904 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3905}
3906
Linus Torvalds1da177e2005-04-16 15:20:36 -07003907static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3908 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003909 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003910{
3911 struct alc_spec *spec = codec->spec;
3912 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3913}
3914
3915/*
3916 * Analog capture
3917 */
Takashi Iwai63300792008-01-24 15:31:36 +01003918static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003919 struct hda_codec *codec,
3920 unsigned int stream_tag,
3921 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003922 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003923{
3924 struct alc_spec *spec = codec->spec;
3925
Takashi Iwai63300792008-01-24 15:31:36 +01003926 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003927 stream_tag, 0, format);
3928 return 0;
3929}
3930
Takashi Iwai63300792008-01-24 15:31:36 +01003931static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003932 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003933 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003934{
3935 struct alc_spec *spec = codec->spec;
3936
Takashi Iwai888afa12008-03-18 09:57:50 +01003937 snd_hda_codec_cleanup_stream(codec,
3938 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003939 return 0;
3940}
3941
Takashi Iwai840b64c2010-07-13 22:49:01 +02003942/* analog capture with dynamic dual-adc changes */
3943static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3944 struct hda_codec *codec,
3945 unsigned int stream_tag,
3946 unsigned int format,
3947 struct snd_pcm_substream *substream)
3948{
3949 struct alc_spec *spec = codec->spec;
3950 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3951 spec->cur_adc_stream_tag = stream_tag;
3952 spec->cur_adc_format = format;
3953 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3954 return 0;
3955}
3956
3957static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3958 struct hda_codec *codec,
3959 struct snd_pcm_substream *substream)
3960{
3961 struct alc_spec *spec = codec->spec;
3962 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
3963 spec->cur_adc = 0;
3964 return 0;
3965}
3966
3967static struct hda_pcm_stream dualmic_pcm_analog_capture = {
3968 .substreams = 1,
3969 .channels_min = 2,
3970 .channels_max = 2,
3971 .nid = 0, /* fill later */
3972 .ops = {
3973 .prepare = dualmic_capture_pcm_prepare,
3974 .cleanup = dualmic_capture_pcm_cleanup
3975 },
3976};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003977
3978/*
3979 */
3980static struct hda_pcm_stream alc880_pcm_analog_playback = {
3981 .substreams = 1,
3982 .channels_min = 2,
3983 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003984 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003985 .ops = {
3986 .open = alc880_playback_pcm_open,
3987 .prepare = alc880_playback_pcm_prepare,
3988 .cleanup = alc880_playback_pcm_cleanup
3989 },
3990};
3991
3992static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003993 .substreams = 1,
3994 .channels_min = 2,
3995 .channels_max = 2,
3996 /* NID is set in alc_build_pcms */
3997};
3998
3999static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
4000 .substreams = 1,
4001 .channels_min = 2,
4002 .channels_max = 2,
4003 /* NID is set in alc_build_pcms */
4004};
4005
4006static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
4007 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004008 .channels_min = 2,
4009 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004010 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004011 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01004012 .prepare = alc880_alt_capture_pcm_prepare,
4013 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004014 },
4015};
4016
4017static struct hda_pcm_stream alc880_pcm_digital_playback = {
4018 .substreams = 1,
4019 .channels_min = 2,
4020 .channels_max = 2,
4021 /* NID is set in alc_build_pcms */
4022 .ops = {
4023 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004024 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004025 .prepare = alc880_dig_playback_pcm_prepare,
4026 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004027 },
4028};
4029
4030static struct hda_pcm_stream alc880_pcm_digital_capture = {
4031 .substreams = 1,
4032 .channels_min = 2,
4033 .channels_max = 2,
4034 /* NID is set in alc_build_pcms */
4035};
4036
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004037/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01004038static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004039 .substreams = 0,
4040 .channels_min = 0,
4041 .channels_max = 0,
4042};
4043
Linus Torvalds1da177e2005-04-16 15:20:36 -07004044static int alc_build_pcms(struct hda_codec *codec)
4045{
4046 struct alc_spec *spec = codec->spec;
4047 struct hda_pcm *info = spec->pcm_rec;
4048 int i;
4049
4050 codec->num_pcms = 1;
4051 codec->pcm_info = info;
4052
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004053 if (spec->no_analog)
4054 goto skip_analog;
4055
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004056 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
4057 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004058 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01004059
Takashi Iwai4a471b72005-12-07 13:56:29 +01004060 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004061 if (snd_BUG_ON(!spec->multiout.dac_nids))
4062 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004063 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
4064 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
4065 }
4066 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004067 if (snd_BUG_ON(!spec->adc_nids))
4068 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004069 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
4070 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
4071 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004072
Takashi Iwai4a471b72005-12-07 13:56:29 +01004073 if (spec->channel_mode) {
4074 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
4075 for (i = 0; i < spec->num_channel_mode; i++) {
4076 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
4077 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
4078 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004079 }
4080 }
4081
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004082 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02004083 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004084 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004085 snprintf(spec->stream_name_digital,
4086 sizeof(spec->stream_name_digital),
4087 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02004088 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08004089 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004090 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004091 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004092 if (spec->dig_out_type)
4093 info->pcm_type = spec->dig_out_type;
4094 else
4095 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004096 if (spec->multiout.dig_out_nid &&
4097 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004098 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4099 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4100 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004101 if (spec->dig_in_nid &&
4102 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004103 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4104 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4105 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004106 /* FIXME: do we need this for all Realtek codec models? */
4107 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004108 }
4109
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004110 if (spec->no_analog)
4111 return 0;
4112
Takashi Iwaie08a0072006-09-07 17:52:14 +02004113 /* If the use of more than one ADC is requested for the current
4114 * model, configure a second analog capture-only PCM.
4115 */
4116 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004117 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4118 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004119 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004120 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004121 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004122 if (spec->alt_dac_nid) {
4123 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4124 *spec->stream_analog_alt_playback;
4125 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4126 spec->alt_dac_nid;
4127 } else {
4128 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4129 alc_pcm_null_stream;
4130 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4131 }
4132 if (spec->num_adc_nids > 1) {
4133 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4134 *spec->stream_analog_alt_capture;
4135 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4136 spec->adc_nids[1];
4137 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4138 spec->num_adc_nids - 1;
4139 } else {
4140 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4141 alc_pcm_null_stream;
4142 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004143 }
4144 }
4145
Linus Torvalds1da177e2005-04-16 15:20:36 -07004146 return 0;
4147}
4148
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004149static inline void alc_shutup(struct hda_codec *codec)
4150{
4151 snd_hda_shutup_pins(codec);
4152}
4153
Takashi Iwai603c4012008-07-30 15:01:44 +02004154static void alc_free_kctls(struct hda_codec *codec)
4155{
4156 struct alc_spec *spec = codec->spec;
4157
4158 if (spec->kctls.list) {
4159 struct snd_kcontrol_new *kctl = spec->kctls.list;
4160 int i;
4161 for (i = 0; i < spec->kctls.used; i++)
4162 kfree(kctl[i].name);
4163 }
4164 snd_array_free(&spec->kctls);
4165}
4166
Linus Torvalds1da177e2005-04-16 15:20:36 -07004167static void alc_free(struct hda_codec *codec)
4168{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004169 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004170
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004171 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004172 return;
4173
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004174 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004175 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004176 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004177 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004178}
4179
Hector Martinf5de24b2009-12-20 22:51:31 +01004180#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004181static void alc_power_eapd(struct hda_codec *codec)
4182{
4183 /* We currently only handle front, HP */
4184 switch (codec->vendor_id) {
4185 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004186 set_eapd(codec, 0x0f, 0);
4187 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004188 break;
4189 case 0x10ec0262:
4190 case 0x10ec0267:
4191 case 0x10ec0268:
4192 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004193 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05004194 case 0x10ec0272:
4195 case 0x10ec0660:
4196 case 0x10ec0662:
4197 case 0x10ec0663:
4198 case 0x10ec0862:
4199 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004200 set_eapd(codec, 0x14, 0);
4201 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004202 break;
4203 }
4204}
4205
Hector Martinf5de24b2009-12-20 22:51:31 +01004206static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4207{
4208 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004209 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004210 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004211 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004212 return 0;
4213}
4214#endif
4215
Takashi Iwaie044c392008-10-27 16:56:24 +01004216#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004217static int alc_resume(struct hda_codec *codec)
4218{
Takashi Iwaie044c392008-10-27 16:56:24 +01004219 codec->patch_ops.init(codec);
4220 snd_hda_codec_resume_amp(codec);
4221 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004222 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +01004223 return 0;
4224}
Takashi Iwaie044c392008-10-27 16:56:24 +01004225#endif
4226
Linus Torvalds1da177e2005-04-16 15:20:36 -07004227/*
4228 */
4229static struct hda_codec_ops alc_patch_ops = {
4230 .build_controls = alc_build_controls,
4231 .build_pcms = alc_build_pcms,
4232 .init = alc_init,
4233 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004234 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004235#ifdef SND_HDA_NEEDS_RESUME
4236 .resume = alc_resume,
4237#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004238#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004239 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004240 .check_power_status = alc_check_power_status,
4241#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004242 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004243};
4244
Kailang Yangc027ddc2010-03-19 11:33:06 +01004245/* replace the codec chip_name with the given string */
4246static int alc_codec_rename(struct hda_codec *codec, const char *name)
4247{
4248 kfree(codec->chip_name);
4249 codec->chip_name = kstrdup(name, GFP_KERNEL);
4250 if (!codec->chip_name) {
4251 alc_free(codec);
4252 return -ENOMEM;
4253 }
4254 return 0;
4255}
4256
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004257/*
4258 * Test configuration for debugging
4259 *
4260 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4261 * enum controls.
4262 */
4263#ifdef CONFIG_SND_DEBUG
4264static hda_nid_t alc880_test_dac_nids[4] = {
4265 0x02, 0x03, 0x04, 0x05
4266};
4267
4268static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004269 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004270 .items = {
4271 { "In-1", 0x0 },
4272 { "In-2", 0x1 },
4273 { "In-3", 0x2 },
4274 { "In-4", 0x3 },
4275 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004276 { "Front", 0x5 },
4277 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004278 },
4279};
4280
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004281static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004282 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004283 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004284 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004285 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004286};
4287
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004288static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4289 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004290{
4291 static char *texts[] = {
4292 "N/A", "Line Out", "HP Out",
4293 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4294 };
4295 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4296 uinfo->count = 1;
4297 uinfo->value.enumerated.items = 8;
4298 if (uinfo->value.enumerated.item >= 8)
4299 uinfo->value.enumerated.item = 7;
4300 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4301 return 0;
4302}
4303
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004304static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4305 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004306{
4307 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4308 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4309 unsigned int pin_ctl, item = 0;
4310
4311 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4312 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4313 if (pin_ctl & AC_PINCTL_OUT_EN) {
4314 if (pin_ctl & AC_PINCTL_HP_EN)
4315 item = 2;
4316 else
4317 item = 1;
4318 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4319 switch (pin_ctl & AC_PINCTL_VREFEN) {
4320 case AC_PINCTL_VREF_HIZ: item = 3; break;
4321 case AC_PINCTL_VREF_50: item = 4; break;
4322 case AC_PINCTL_VREF_GRD: item = 5; break;
4323 case AC_PINCTL_VREF_80: item = 6; break;
4324 case AC_PINCTL_VREF_100: item = 7; break;
4325 }
4326 }
4327 ucontrol->value.enumerated.item[0] = item;
4328 return 0;
4329}
4330
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004331static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4332 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004333{
4334 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4335 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4336 static unsigned int ctls[] = {
4337 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4338 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4339 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4340 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4341 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4342 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4343 };
4344 unsigned int old_ctl, new_ctl;
4345
4346 old_ctl = snd_hda_codec_read(codec, nid, 0,
4347 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4348 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4349 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004350 int val;
4351 snd_hda_codec_write_cache(codec, nid, 0,
4352 AC_VERB_SET_PIN_WIDGET_CONTROL,
4353 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004354 val = ucontrol->value.enumerated.item[0] >= 3 ?
4355 HDA_AMP_MUTE : 0;
4356 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4357 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004358 return 1;
4359 }
4360 return 0;
4361}
4362
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004363static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4364 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004365{
4366 static char *texts[] = {
4367 "Front", "Surround", "CLFE", "Side"
4368 };
4369 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4370 uinfo->count = 1;
4371 uinfo->value.enumerated.items = 4;
4372 if (uinfo->value.enumerated.item >= 4)
4373 uinfo->value.enumerated.item = 3;
4374 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4375 return 0;
4376}
4377
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004378static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4379 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004380{
4381 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4382 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4383 unsigned int sel;
4384
4385 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4386 ucontrol->value.enumerated.item[0] = sel & 3;
4387 return 0;
4388}
4389
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004390static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4391 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004392{
4393 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4394 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4395 unsigned int sel;
4396
4397 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4398 if (ucontrol->value.enumerated.item[0] != sel) {
4399 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004400 snd_hda_codec_write_cache(codec, nid, 0,
4401 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004402 return 1;
4403 }
4404 return 0;
4405}
4406
4407#define PIN_CTL_TEST(xname,nid) { \
4408 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4409 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004410 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004411 .info = alc_test_pin_ctl_info, \
4412 .get = alc_test_pin_ctl_get, \
4413 .put = alc_test_pin_ctl_put, \
4414 .private_value = nid \
4415 }
4416
4417#define PIN_SRC_TEST(xname,nid) { \
4418 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4419 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004420 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004421 .info = alc_test_pin_src_info, \
4422 .get = alc_test_pin_src_get, \
4423 .put = alc_test_pin_src_put, \
4424 .private_value = nid \
4425 }
4426
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004427static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004428 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4429 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4430 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4431 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004432 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4433 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4434 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4435 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004436 PIN_CTL_TEST("Front Pin Mode", 0x14),
4437 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4438 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4439 PIN_CTL_TEST("Side Pin Mode", 0x17),
4440 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4441 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4442 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4443 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4444 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4445 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4446 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4447 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4448 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4449 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4450 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4451 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4452 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4453 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4454 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4455 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4456 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4457 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004458 {
4459 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4460 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004461 .info = alc_ch_mode_info,
4462 .get = alc_ch_mode_get,
4463 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004464 },
4465 { } /* end */
4466};
4467
4468static struct hda_verb alc880_test_init_verbs[] = {
4469 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004470 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4471 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4472 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4473 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4474 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4475 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4476 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4477 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004478 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004479 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4480 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4481 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4482 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004483 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004484 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4485 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4486 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4487 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004488 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004489 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4490 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4491 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4492 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004493 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004494 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4495 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004496 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4497 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4498 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004499 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004500 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4501 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4502 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4503 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004504 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004505 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004506 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004507 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004508 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004509 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004510 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004511 /* Analog input/passthru */
4512 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4513 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4514 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4515 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4516 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004517 { }
4518};
4519#endif
4520
Linus Torvalds1da177e2005-04-16 15:20:36 -07004521/*
4522 */
4523
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004524static const char *alc880_models[ALC880_MODEL_LAST] = {
4525 [ALC880_3ST] = "3stack",
4526 [ALC880_TCL_S700] = "tcl",
4527 [ALC880_3ST_DIG] = "3stack-digout",
4528 [ALC880_CLEVO] = "clevo",
4529 [ALC880_5ST] = "5stack",
4530 [ALC880_5ST_DIG] = "5stack-digout",
4531 [ALC880_W810] = "w810",
4532 [ALC880_Z71V] = "z71v",
4533 [ALC880_6ST] = "6stack",
4534 [ALC880_6ST_DIG] = "6stack-digout",
4535 [ALC880_ASUS] = "asus",
4536 [ALC880_ASUS_W1V] = "asus-w1v",
4537 [ALC880_ASUS_DIG] = "asus-dig",
4538 [ALC880_ASUS_DIG2] = "asus-dig2",
4539 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004540 [ALC880_UNIWILL_P53] = "uniwill-p53",
4541 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004542 [ALC880_F1734] = "F1734",
4543 [ALC880_LG] = "lg",
4544 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004545 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004546#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004547 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004548#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004549 [ALC880_AUTO] = "auto",
4550};
4551
4552static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004553 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004554 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4555 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4556 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4557 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4558 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4559 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4560 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4561 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004562 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4563 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004564 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4565 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4566 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4567 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4568 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4569 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4570 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4571 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4572 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4573 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004574 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004575 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4576 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4577 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004578 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004579 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004580 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4581 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004582 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4583 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004584 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4585 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4586 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4587 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004588 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4589 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004590 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004591 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004592 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004593 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004594 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4595 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004596 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004597 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004598 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004599 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004600 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004601 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004602 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004603 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004604 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004605 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4606 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004607 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004608 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4609 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4610 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4611 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004612 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4613 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004614 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004615 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004616 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4617 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004618 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4619 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4620 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004621 /* default Intel */
4622 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004623 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4624 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004625 {}
4626};
4627
Takashi Iwai16ded522005-06-10 19:58:24 +02004628/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004629 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004630 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004631static struct alc_config_preset alc880_presets[] = {
4632 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004633 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004634 .init_verbs = { alc880_volume_init_verbs,
4635 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004636 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004637 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004638 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4639 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004640 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004641 .input_mux = &alc880_capture_source,
4642 },
4643 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004644 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004645 .init_verbs = { alc880_volume_init_verbs,
4646 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004647 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004648 .dac_nids = alc880_dac_nids,
4649 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004650 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4651 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004652 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004653 .input_mux = &alc880_capture_source,
4654 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004655 [ALC880_TCL_S700] = {
4656 .mixers = { alc880_tcl_s700_mixer },
4657 .init_verbs = { alc880_volume_init_verbs,
4658 alc880_pin_tcl_S700_init_verbs,
4659 alc880_gpio2_init_verbs },
4660 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4661 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004662 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4663 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004664 .hp_nid = 0x03,
4665 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4666 .channel_mode = alc880_2_jack_modes,
4667 .input_mux = &alc880_capture_source,
4668 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004669 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004670 .mixers = { alc880_three_stack_mixer,
4671 alc880_five_stack_mixer},
4672 .init_verbs = { alc880_volume_init_verbs,
4673 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004674 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4675 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004676 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4677 .channel_mode = alc880_fivestack_modes,
4678 .input_mux = &alc880_capture_source,
4679 },
4680 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004681 .mixers = { alc880_three_stack_mixer,
4682 alc880_five_stack_mixer },
4683 .init_verbs = { alc880_volume_init_verbs,
4684 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004685 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4686 .dac_nids = alc880_dac_nids,
4687 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004688 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4689 .channel_mode = alc880_fivestack_modes,
4690 .input_mux = &alc880_capture_source,
4691 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004692 [ALC880_6ST] = {
4693 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004694 .init_verbs = { alc880_volume_init_verbs,
4695 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004696 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4697 .dac_nids = alc880_6st_dac_nids,
4698 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4699 .channel_mode = alc880_sixstack_modes,
4700 .input_mux = &alc880_6stack_capture_source,
4701 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004702 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004703 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004704 .init_verbs = { alc880_volume_init_verbs,
4705 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004706 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4707 .dac_nids = alc880_6st_dac_nids,
4708 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004709 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4710 .channel_mode = alc880_sixstack_modes,
4711 .input_mux = &alc880_6stack_capture_source,
4712 },
4713 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004714 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004715 .init_verbs = { alc880_volume_init_verbs,
4716 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004717 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004718 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4719 .dac_nids = alc880_w810_dac_nids,
4720 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004721 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4722 .channel_mode = alc880_w810_modes,
4723 .input_mux = &alc880_capture_source,
4724 },
4725 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004726 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004727 .init_verbs = { alc880_volume_init_verbs,
4728 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004729 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4730 .dac_nids = alc880_z71v_dac_nids,
4731 .dig_out_nid = ALC880_DIGOUT_NID,
4732 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004733 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4734 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004735 .input_mux = &alc880_capture_source,
4736 },
4737 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004738 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004739 .init_verbs = { alc880_volume_init_verbs,
4740 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004741 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4742 .dac_nids = alc880_f1734_dac_nids,
4743 .hp_nid = 0x02,
4744 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4745 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004746 .input_mux = &alc880_f1734_capture_source,
4747 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004748 .setup = alc880_uniwill_p53_setup,
4749 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004750 },
4751 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004752 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004753 .init_verbs = { alc880_volume_init_verbs,
4754 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004755 alc880_gpio1_init_verbs },
4756 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4757 .dac_nids = alc880_asus_dac_nids,
4758 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4759 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004760 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004761 .input_mux = &alc880_capture_source,
4762 },
4763 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004764 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004765 .init_verbs = { alc880_volume_init_verbs,
4766 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004767 alc880_gpio1_init_verbs },
4768 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4769 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004770 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004771 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4772 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004773 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004774 .input_mux = &alc880_capture_source,
4775 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004776 [ALC880_ASUS_DIG2] = {
4777 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004778 .init_verbs = { alc880_volume_init_verbs,
4779 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004780 alc880_gpio2_init_verbs }, /* use GPIO2 */
4781 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4782 .dac_nids = alc880_asus_dac_nids,
4783 .dig_out_nid = ALC880_DIGOUT_NID,
4784 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4785 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004786 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004787 .input_mux = &alc880_capture_source,
4788 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004789 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004790 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004791 .init_verbs = { alc880_volume_init_verbs,
4792 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004793 alc880_gpio1_init_verbs },
4794 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4795 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004796 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004797 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4798 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004799 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004800 .input_mux = &alc880_capture_source,
4801 },
4802 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004803 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004804 .init_verbs = { alc880_volume_init_verbs,
4805 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004806 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4807 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004808 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004809 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4810 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004811 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004812 .input_mux = &alc880_capture_source,
4813 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004814 [ALC880_UNIWILL] = {
4815 .mixers = { alc880_uniwill_mixer },
4816 .init_verbs = { alc880_volume_init_verbs,
4817 alc880_uniwill_init_verbs },
4818 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4819 .dac_nids = alc880_asus_dac_nids,
4820 .dig_out_nid = ALC880_DIGOUT_NID,
4821 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4822 .channel_mode = alc880_threestack_modes,
4823 .need_dac_fix = 1,
4824 .input_mux = &alc880_capture_source,
4825 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004826 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004827 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004828 },
4829 [ALC880_UNIWILL_P53] = {
4830 .mixers = { alc880_uniwill_p53_mixer },
4831 .init_verbs = { alc880_volume_init_verbs,
4832 alc880_uniwill_p53_init_verbs },
4833 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4834 .dac_nids = alc880_asus_dac_nids,
4835 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004836 .channel_mode = alc880_threestack_modes,
4837 .input_mux = &alc880_capture_source,
4838 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004839 .setup = alc880_uniwill_p53_setup,
4840 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004841 },
4842 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004843 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004844 .init_verbs = { alc880_volume_init_verbs,
4845 alc880_uniwill_p53_init_verbs,
4846 alc880_beep_init_verbs },
4847 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4848 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004849 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004850 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4851 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004852 .input_mux = &alc880_capture_source,
4853 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004854 .setup = alc880_uniwill_p53_setup,
4855 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004856 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004857 [ALC880_CLEVO] = {
4858 .mixers = { alc880_three_stack_mixer },
4859 .init_verbs = { alc880_volume_init_verbs,
4860 alc880_pin_clevo_init_verbs },
4861 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4862 .dac_nids = alc880_dac_nids,
4863 .hp_nid = 0x03,
4864 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4865 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004866 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004867 .input_mux = &alc880_capture_source,
4868 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004869 [ALC880_LG] = {
4870 .mixers = { alc880_lg_mixer },
4871 .init_verbs = { alc880_volume_init_verbs,
4872 alc880_lg_init_verbs },
4873 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4874 .dac_nids = alc880_lg_dac_nids,
4875 .dig_out_nid = ALC880_DIGOUT_NID,
4876 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4877 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004878 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004879 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004880 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004881 .setup = alc880_lg_setup,
4882 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004883#ifdef CONFIG_SND_HDA_POWER_SAVE
4884 .loopbacks = alc880_lg_loopbacks,
4885#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004886 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004887 [ALC880_LG_LW] = {
4888 .mixers = { alc880_lg_lw_mixer },
4889 .init_verbs = { alc880_volume_init_verbs,
4890 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004891 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004892 .dac_nids = alc880_dac_nids,
4893 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004894 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4895 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004896 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004897 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004898 .setup = alc880_lg_lw_setup,
4899 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004900 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004901 [ALC880_MEDION_RIM] = {
4902 .mixers = { alc880_medion_rim_mixer },
4903 .init_verbs = { alc880_volume_init_verbs,
4904 alc880_medion_rim_init_verbs,
4905 alc_gpio2_init_verbs },
4906 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4907 .dac_nids = alc880_dac_nids,
4908 .dig_out_nid = ALC880_DIGOUT_NID,
4909 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4910 .channel_mode = alc880_2_jack_modes,
4911 .input_mux = &alc880_medion_rim_capture_source,
4912 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004913 .setup = alc880_medion_rim_setup,
4914 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004915 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004916#ifdef CONFIG_SND_DEBUG
4917 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004918 .mixers = { alc880_test_mixer },
4919 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004920 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4921 .dac_nids = alc880_test_dac_nids,
4922 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004923 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4924 .channel_mode = alc880_test_modes,
4925 .input_mux = &alc880_test_capture_source,
4926 },
4927#endif
4928};
4929
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004930/*
4931 * Automatic parse of I/O pins from the BIOS configuration
4932 */
4933
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004934enum {
4935 ALC_CTL_WIDGET_VOL,
4936 ALC_CTL_WIDGET_MUTE,
4937 ALC_CTL_BIND_MUTE,
4938};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004939static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004940 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4941 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004942 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004943};
4944
4945/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004946static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004947 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004948{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004949 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004950
Takashi Iwai603c4012008-07-30 15:01:44 +02004951 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4952 knew = snd_array_new(&spec->kctls);
4953 if (!knew)
4954 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004955 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004956 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004957 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004958 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004959 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004960 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004961 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004962 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004963 return 0;
4964}
4965
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004966static int add_control_with_pfx(struct alc_spec *spec, int type,
4967 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004968 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004969{
4970 char name[32];
4971 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004972 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004973}
4974
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004975#define add_pb_vol_ctrl(spec, type, pfx, val) \
4976 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
4977#define add_pb_sw_ctrl(spec, type, pfx, val) \
4978 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
4979#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
4980 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
4981#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
4982 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004983
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004984#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4985#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4986#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4987#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004988#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4989#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4990#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4991#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4992#define ALC880_PIN_CD_NID 0x1c
4993
4994/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004995static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4996 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004997{
4998 hda_nid_t nid;
4999 int assigned[4];
5000 int i, j;
5001
5002 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02005003 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005004
5005 /* check the pins hardwired to audio widget */
5006 for (i = 0; i < cfg->line_outs; i++) {
5007 nid = cfg->line_out_pins[i];
5008 if (alc880_is_fixed_pin(nid)) {
5009 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01005010 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005011 assigned[idx] = 1;
5012 }
5013 }
5014 /* left pins can be connect to any audio widget */
5015 for (i = 0; i < cfg->line_outs; i++) {
5016 nid = cfg->line_out_pins[i];
5017 if (alc880_is_fixed_pin(nid))
5018 continue;
5019 /* search for an empty channel */
5020 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005021 if (!assigned[j]) {
5022 spec->multiout.dac_nids[i] =
5023 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005024 assigned[j] = 1;
5025 break;
5026 }
5027 }
5028 }
5029 spec->multiout.num_dacs = cfg->line_outs;
5030 return 0;
5031}
5032
5033/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01005034static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
5035 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005036{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005037 static const char *chname[4] = {
5038 "Front", "Surround", NULL /*CLFE*/, "Side"
5039 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005040 hda_nid_t nid;
5041 int i, err;
5042
5043 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005044 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005045 continue;
5046 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
5047 if (i == 2) {
5048 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005049 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5050 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005051 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
5052 HDA_OUTPUT));
5053 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005054 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005055 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5056 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005057 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
5058 HDA_OUTPUT));
5059 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005060 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005061 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5062 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005063 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
5064 HDA_INPUT));
5065 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005066 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005067 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5068 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005069 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
5070 HDA_INPUT));
5071 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005072 return err;
5073 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02005074 const char *pfx;
5075 if (cfg->line_outs == 1 &&
5076 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
5077 pfx = "Speaker";
5078 else
5079 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005080 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005081 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
5082 HDA_OUTPUT));
5083 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005084 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005085 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005086 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
5087 HDA_INPUT));
5088 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005089 return err;
5090 }
5091 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005092 return 0;
5093}
5094
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005095/* add playback controls for speaker and HP outputs */
5096static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5097 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005098{
5099 hda_nid_t nid;
5100 int err;
5101
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005102 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005103 return 0;
5104
5105 if (alc880_is_fixed_pin(pin)) {
5106 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005107 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005108 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005109 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005110 else
5111 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005112 /* control HP volume/switch on the output mixer amp */
5113 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005114 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005115 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5116 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005117 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005118 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005119 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5120 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005121 return err;
5122 } else if (alc880_is_multi_pin(pin)) {
5123 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005124 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005125 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005126 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5127 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005128 return err;
5129 }
5130 return 0;
5131}
5132
5133/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005134static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005135 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005136 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005137{
Kailang Yangdf694da2005-12-05 19:42:22 +01005138 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005139
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005140 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005141 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5142 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005143 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005144 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005145 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5146 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005147 return err;
5148 return 0;
5149}
5150
Takashi Iwai05f5f472009-08-25 13:10:18 +02005151static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005152{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005153 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5154 return (pincap & AC_PINCAP_IN) != 0;
5155}
5156
5157/* create playback/capture controls for input pins */
5158static int alc_auto_create_input_ctls(struct hda_codec *codec,
5159 const struct auto_pin_cfg *cfg,
5160 hda_nid_t mixer,
5161 hda_nid_t cap1, hda_nid_t cap2)
5162{
5163 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005164 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005165 int i, err, idx, type, type_idx = 0;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005166
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005167 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005168 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005169 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005170
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005171 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005172 if (!alc_is_input_pin(codec, pin))
5173 continue;
5174
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005175 type = cfg->inputs[i].type;
5176 if (i > 0 && type == cfg->inputs[i - 1].type)
5177 type_idx++;
5178 else
5179 type_idx = 0;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005180 label = hda_get_autocfg_input_label(codec, cfg, i);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005181 if (mixer) {
5182 idx = get_connection_index(codec, mixer, pin);
5183 if (idx >= 0) {
5184 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005185 label, type_idx,
5186 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005187 if (err < 0)
5188 return err;
5189 }
5190 }
5191
5192 if (!cap1)
5193 continue;
5194 idx = get_connection_index(codec, cap1, pin);
5195 if (idx < 0 && cap2)
5196 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005197 if (idx >= 0)
5198 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005199 }
5200 return 0;
5201}
5202
Takashi Iwai05f5f472009-08-25 13:10:18 +02005203static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5204 const struct auto_pin_cfg *cfg)
5205{
5206 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5207}
5208
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005209static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5210 unsigned int pin_type)
5211{
5212 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5213 pin_type);
5214 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005215 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5216 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005217}
5218
Kailang Yangdf694da2005-12-05 19:42:22 +01005219static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5220 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005221 int dac_idx)
5222{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005223 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005224 /* need the manual connection? */
5225 if (alc880_is_multi_pin(nid)) {
5226 struct alc_spec *spec = codec->spec;
5227 int idx = alc880_multi_pin_idx(nid);
5228 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5229 AC_VERB_SET_CONNECT_SEL,
5230 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5231 }
5232}
5233
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005234static int get_pin_type(int line_out_type)
5235{
5236 if (line_out_type == AUTO_PIN_HP_OUT)
5237 return PIN_HP;
5238 else
5239 return PIN_OUT;
5240}
5241
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005242static void alc880_auto_init_multi_out(struct hda_codec *codec)
5243{
5244 struct alc_spec *spec = codec->spec;
5245 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005246
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005247 for (i = 0; i < spec->autocfg.line_outs; i++) {
5248 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005249 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5250 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005251 }
5252}
5253
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005254static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005255{
5256 struct alc_spec *spec = codec->spec;
5257 hda_nid_t pin;
5258
Takashi Iwai82bc9552006-03-21 11:24:42 +01005259 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005260 if (pin) /* connect to front */
5261 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005262 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005263 if (pin) /* connect to front */
5264 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5265}
5266
5267static void alc880_auto_init_analog_input(struct hda_codec *codec)
5268{
5269 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005270 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005271 int i;
5272
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005273 for (i = 0; i < cfg->num_inputs; i++) {
5274 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005275 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005276 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005277 if (nid != ALC880_PIN_CD_NID &&
5278 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005279 snd_hda_codec_write(codec, nid, 0,
5280 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005281 AMP_OUT_MUTE);
5282 }
5283 }
5284}
5285
Takashi Iwai7f311a42010-04-09 17:32:23 +02005286static void alc880_auto_init_input_src(struct hda_codec *codec)
5287{
5288 struct alc_spec *spec = codec->spec;
5289 int c;
5290
5291 for (c = 0; c < spec->num_adc_nids; c++) {
5292 unsigned int mux_idx;
5293 const struct hda_input_mux *imux;
5294 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5295 imux = &spec->input_mux[mux_idx];
5296 if (!imux->num_items && mux_idx > 0)
5297 imux = &spec->input_mux[0];
5298 if (imux)
5299 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5300 AC_VERB_SET_CONNECT_SEL,
5301 imux->items[0].index);
5302 }
5303}
5304
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005305/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005306/* return 1 if successful, 0 if the proper config is not found,
5307 * or a negative error code
5308 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005309static int alc880_parse_auto_config(struct hda_codec *codec)
5310{
5311 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005312 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005313 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005314
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005315 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5316 alc880_ignore);
5317 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005318 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005319 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005320 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005321
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005322 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5323 if (err < 0)
5324 return err;
5325 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5326 if (err < 0)
5327 return err;
5328 err = alc880_auto_create_extra_out(spec,
5329 spec->autocfg.speaker_pins[0],
5330 "Speaker");
5331 if (err < 0)
5332 return err;
5333 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5334 "Headphone");
5335 if (err < 0)
5336 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005337 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005338 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005339 return err;
5340
5341 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5342
Takashi Iwai757899a2010-07-30 10:48:14 +02005343 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005344
Takashi Iwai603c4012008-07-30 15:01:44 +02005345 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005346 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005347
Takashi Iwaid88897e2008-10-31 15:01:37 +01005348 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005349
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005350 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005351 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005352
Kailang Yang6227cdc2010-02-25 08:36:52 +01005353 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005354
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005355 return 1;
5356}
5357
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005358/* additional initialization for auto-configuration model */
5359static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005360{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005361 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005362 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005363 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005364 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005365 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005366 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005367 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005368 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005369}
5370
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005371/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5372 * one of two digital mic pins, e.g. on ALC272
5373 */
5374static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005375{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005376 struct alc_spec *spec = codec->spec;
5377 int i;
5378
5379 for (i = 0; i < spec->num_adc_nids; i++) {
5380 hda_nid_t cap = spec->capsrc_nids ?
5381 spec->capsrc_nids[i] : spec->adc_nids[i];
5382 int iidx, eidx;
5383
5384 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5385 if (iidx < 0)
5386 continue;
5387 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5388 if (eidx < 0)
5389 continue;
5390 spec->int_mic.mux_idx = iidx;
5391 spec->ext_mic.mux_idx = eidx;
5392 if (spec->capsrc_nids)
5393 spec->capsrc_nids += i;
5394 spec->adc_nids += i;
5395 spec->num_adc_nids = 1;
5396 return;
5397 }
5398 snd_printd(KERN_INFO "hda_codec: %s: "
5399 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5400 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5401 spec->auto_mic = 0; /* disable auto-mic to be sure */
5402}
5403
Takashi Iwai748cce42010-08-04 07:37:39 +02005404/* select or unmute the given capsrc route */
5405static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5406 int idx)
5407{
5408 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5409 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5410 HDA_AMP_MUTE, 0);
5411 } else {
5412 snd_hda_codec_write_cache(codec, cap, 0,
5413 AC_VERB_SET_CONNECT_SEL, idx);
5414 }
5415}
5416
Takashi Iwai840b64c2010-07-13 22:49:01 +02005417/* set the default connection to that pin */
5418static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5419{
5420 struct alc_spec *spec = codec->spec;
5421 int i;
5422
5423 for (i = 0; i < spec->num_adc_nids; i++) {
5424 hda_nid_t cap = spec->capsrc_nids ?
5425 spec->capsrc_nids[i] : spec->adc_nids[i];
5426 int idx;
5427
5428 idx = get_connection_index(codec, cap, pin);
5429 if (idx < 0)
5430 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005431 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005432 return i; /* return the found index */
5433 }
5434 return -1; /* not found */
5435}
5436
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005437/* choose the ADC/MUX containing the input pin and initialize the setup */
5438static void fixup_single_adc(struct hda_codec *codec)
5439{
5440 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005441 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005442 int i;
5443
5444 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005445 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005446 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005447 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005448 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005449 /* use only this ADC */
5450 if (spec->capsrc_nids)
5451 spec->capsrc_nids += i;
5452 spec->adc_nids += i;
5453 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005454 }
5455}
5456
Takashi Iwai840b64c2010-07-13 22:49:01 +02005457/* initialize dual adcs */
5458static void fixup_dual_adc_switch(struct hda_codec *codec)
5459{
5460 struct alc_spec *spec = codec->spec;
5461 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5462 init_capsrc_for_pin(codec, spec->int_mic.pin);
5463}
5464
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005465static void set_capture_mixer(struct hda_codec *codec)
5466{
5467 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005468 static struct snd_kcontrol_new *caps[2][3] = {
5469 { alc_capture_mixer_nosrc1,
5470 alc_capture_mixer_nosrc2,
5471 alc_capture_mixer_nosrc3 },
5472 { alc_capture_mixer1,
5473 alc_capture_mixer2,
5474 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005475 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005476 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005477 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005478 int num_adcs = spec->num_adc_nids;
5479 if (spec->dual_adc_switch)
5480 fixup_dual_adc_switch(codec);
5481 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005482 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005483 else if (spec->input_mux) {
5484 if (spec->input_mux->num_items > 1)
5485 mux = 1;
5486 else if (spec->input_mux->num_items == 1)
5487 fixup_single_adc(codec);
5488 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005489 if (spec->dual_adc_switch)
5490 num_adcs = 1;
5491 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005492 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005493}
5494
Takashi Iwai66946352010-03-29 17:21:45 +02005495/* fill adc_nids (and capsrc_nids) containing all active input pins */
5496static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5497 int num_nids)
5498{
5499 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005500 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005501 int n;
5502 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5503
5504 for (n = 0; n < num_nids; n++) {
5505 hda_nid_t adc, cap;
5506 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5507 int nconns, i, j;
5508
5509 adc = nids[n];
5510 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5511 continue;
5512 cap = adc;
5513 nconns = snd_hda_get_connections(codec, cap, conn,
5514 ARRAY_SIZE(conn));
5515 if (nconns == 1) {
5516 cap = conn[0];
5517 nconns = snd_hda_get_connections(codec, cap, conn,
5518 ARRAY_SIZE(conn));
5519 }
5520 if (nconns <= 0)
5521 continue;
5522 if (!fallback_adc) {
5523 fallback_adc = adc;
5524 fallback_cap = cap;
5525 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005526 for (i = 0; i < cfg->num_inputs; i++) {
5527 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005528 for (j = 0; j < nconns; j++) {
5529 if (conn[j] == nid)
5530 break;
5531 }
5532 if (j >= nconns)
5533 break;
5534 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005535 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005536 int num_adcs = spec->num_adc_nids;
5537 spec->private_adc_nids[num_adcs] = adc;
5538 spec->private_capsrc_nids[num_adcs] = cap;
5539 spec->num_adc_nids++;
5540 spec->adc_nids = spec->private_adc_nids;
5541 if (adc != cap)
5542 spec->capsrc_nids = spec->private_capsrc_nids;
5543 }
5544 }
5545 if (!spec->num_adc_nids) {
5546 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005547 " using fallback 0x%x\n",
5548 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005549 spec->private_adc_nids[0] = fallback_adc;
5550 spec->adc_nids = spec->private_adc_nids;
5551 if (fallback_adc != fallback_cap) {
5552 spec->private_capsrc_nids[0] = fallback_cap;
5553 spec->capsrc_nids = spec->private_adc_nids;
5554 }
5555 }
5556}
5557
Takashi Iwai67d634c2009-11-16 15:35:59 +01005558#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005559#define set_beep_amp(spec, nid, idx, dir) \
5560 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005561
5562static struct snd_pci_quirk beep_white_list[] = {
5563 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005564 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005565 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005566 {}
5567};
5568
5569static inline int has_cdefine_beep(struct hda_codec *codec)
5570{
5571 struct alc_spec *spec = codec->spec;
5572 const struct snd_pci_quirk *q;
5573 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5574 if (q)
5575 return q->value;
5576 return spec->cdefine.enable_pcbeep;
5577}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005578#else
5579#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005580#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005581#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005582
5583/*
5584 * OK, here we have finally the patch for ALC880
5585 */
5586
Linus Torvalds1da177e2005-04-16 15:20:36 -07005587static int patch_alc880(struct hda_codec *codec)
5588{
5589 struct alc_spec *spec;
5590 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005591 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005592
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005593 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005594 if (spec == NULL)
5595 return -ENOMEM;
5596
5597 codec->spec = spec;
5598
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005599 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5600 alc880_models,
5601 alc880_cfg_tbl);
5602 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005603 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5604 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005605 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005606 }
5607
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005608 if (board_config == ALC880_AUTO) {
5609 /* automatic parse from the BIOS config */
5610 err = alc880_parse_auto_config(codec);
5611 if (err < 0) {
5612 alc_free(codec);
5613 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005614 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005615 printk(KERN_INFO
5616 "hda_codec: Cannot set up configuration "
5617 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005618 board_config = ALC880_3ST;
5619 }
5620 }
5621
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005622 err = snd_hda_attach_beep_device(codec, 0x1);
5623 if (err < 0) {
5624 alc_free(codec);
5625 return err;
5626 }
5627
Kailang Yangdf694da2005-12-05 19:42:22 +01005628 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005629 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005630
Linus Torvalds1da177e2005-04-16 15:20:36 -07005631 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5632 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005633 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005634
Linus Torvalds1da177e2005-04-16 15:20:36 -07005635 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5636 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5637
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005638 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005639 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005640 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005641 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005642 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005643 if (wcap != AC_WID_AUD_IN) {
5644 spec->adc_nids = alc880_adc_nids_alt;
5645 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005646 } else {
5647 spec->adc_nids = alc880_adc_nids;
5648 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005649 }
5650 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005651 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005652 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005653
Takashi Iwai2134ea42008-01-10 16:53:55 +01005654 spec->vmaster_nid = 0x0c;
5655
Linus Torvalds1da177e2005-04-16 15:20:36 -07005656 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005657 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005658 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005659#ifdef CONFIG_SND_HDA_POWER_SAVE
5660 if (!spec->loopback.amplist)
5661 spec->loopback.amplist = alc880_loopbacks;
5662#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005663
5664 return 0;
5665}
5666
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005667
Linus Torvalds1da177e2005-04-16 15:20:36 -07005668/*
5669 * ALC260 support
5670 */
5671
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005672static hda_nid_t alc260_dac_nids[1] = {
5673 /* front */
5674 0x02,
5675};
5676
5677static hda_nid_t alc260_adc_nids[1] = {
5678 /* ADC0 */
5679 0x04,
5680};
5681
Kailang Yangdf694da2005-12-05 19:42:22 +01005682static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005683 /* ADC1 */
5684 0x05,
5685};
5686
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005687/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5688 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5689 */
5690static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005691 /* ADC0, ADC1 */
5692 0x04, 0x05
5693};
5694
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005695#define ALC260_DIGOUT_NID 0x03
5696#define ALC260_DIGIN_NID 0x06
5697
5698static struct hda_input_mux alc260_capture_source = {
5699 .num_items = 4,
5700 .items = {
5701 { "Mic", 0x0 },
5702 { "Front Mic", 0x1 },
5703 { "Line", 0x2 },
5704 { "CD", 0x4 },
5705 },
5706};
5707
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005708/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005709 * headphone jack and the internal CD lines since these are the only pins at
5710 * which audio can appear. For flexibility, also allow the option of
5711 * recording the mixer output on the second ADC (ADC0 doesn't have a
5712 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005713 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005714static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5715 {
5716 .num_items = 3,
5717 .items = {
5718 { "Mic/Line", 0x0 },
5719 { "CD", 0x4 },
5720 { "Headphone", 0x2 },
5721 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005722 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005723 {
5724 .num_items = 4,
5725 .items = {
5726 { "Mic/Line", 0x0 },
5727 { "CD", 0x4 },
5728 { "Headphone", 0x2 },
5729 { "Mixer", 0x5 },
5730 },
5731 },
5732
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005733};
5734
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005735/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5736 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005737 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005738static struct hda_input_mux alc260_acer_capture_sources[2] = {
5739 {
5740 .num_items = 4,
5741 .items = {
5742 { "Mic", 0x0 },
5743 { "Line", 0x2 },
5744 { "CD", 0x4 },
5745 { "Headphone", 0x5 },
5746 },
5747 },
5748 {
5749 .num_items = 5,
5750 .items = {
5751 { "Mic", 0x0 },
5752 { "Line", 0x2 },
5753 { "CD", 0x4 },
5754 { "Headphone", 0x6 },
5755 { "Mixer", 0x5 },
5756 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005757 },
5758};
Michael Schwingencc959482009-02-22 18:58:45 +01005759
5760/* Maxdata Favorit 100XS */
5761static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5762 {
5763 .num_items = 2,
5764 .items = {
5765 { "Line/Mic", 0x0 },
5766 { "CD", 0x4 },
5767 },
5768 },
5769 {
5770 .num_items = 3,
5771 .items = {
5772 { "Line/Mic", 0x0 },
5773 { "CD", 0x4 },
5774 { "Mixer", 0x5 },
5775 },
5776 },
5777};
5778
Linus Torvalds1da177e2005-04-16 15:20:36 -07005779/*
5780 * This is just place-holder, so there's something for alc_build_pcms to look
5781 * at when it calculates the maximum number of channels. ALC260 has no mixer
5782 * element which allows changing the channel mode, so the verb list is
5783 * never used.
5784 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005785static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005786 { 2, NULL },
5787};
5788
Kailang Yangdf694da2005-12-05 19:42:22 +01005789
5790/* Mixer combinations
5791 *
5792 * basic: base_output + input + pc_beep + capture
5793 * HP: base_output + input + capture_alt
5794 * HP_3013: hp_3013 + input + capture
5795 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005796 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005797 */
5798
5799static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005800 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005801 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005802 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5803 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5804 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5805 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5806 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005807};
Kailang Yangdf694da2005-12-05 19:42:22 +01005808
5809static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005810 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5811 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5812 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5813 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5814 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5815 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5816 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5817 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005818 { } /* end */
5819};
5820
Takashi Iwaibec15c32008-01-28 18:16:30 +01005821/* update HP, line and mono out pins according to the master switch */
5822static void alc260_hp_master_update(struct hda_codec *codec,
5823 hda_nid_t hp, hda_nid_t line,
5824 hda_nid_t mono)
5825{
5826 struct alc_spec *spec = codec->spec;
5827 unsigned int val = spec->master_sw ? PIN_HP : 0;
5828 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005829 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005830 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005831 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005832 val);
5833 /* mono (speaker) depending on the HP jack sense */
5834 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005835 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005836 val);
5837}
5838
5839static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5840 struct snd_ctl_elem_value *ucontrol)
5841{
5842 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5843 struct alc_spec *spec = codec->spec;
5844 *ucontrol->value.integer.value = spec->master_sw;
5845 return 0;
5846}
5847
5848static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5849 struct snd_ctl_elem_value *ucontrol)
5850{
5851 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5852 struct alc_spec *spec = codec->spec;
5853 int val = !!*ucontrol->value.integer.value;
5854 hda_nid_t hp, line, mono;
5855
5856 if (val == spec->master_sw)
5857 return 0;
5858 spec->master_sw = val;
5859 hp = (kcontrol->private_value >> 16) & 0xff;
5860 line = (kcontrol->private_value >> 8) & 0xff;
5861 mono = kcontrol->private_value & 0xff;
5862 alc260_hp_master_update(codec, hp, line, mono);
5863 return 1;
5864}
5865
5866static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5867 {
5868 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5869 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005870 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005871 .info = snd_ctl_boolean_mono_info,
5872 .get = alc260_hp_master_sw_get,
5873 .put = alc260_hp_master_sw_put,
5874 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5875 },
5876 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5877 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5878 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5879 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5880 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5881 HDA_OUTPUT),
5882 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5883 { } /* end */
5884};
5885
5886static struct hda_verb alc260_hp_unsol_verbs[] = {
5887 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5888 {},
5889};
5890
5891static void alc260_hp_automute(struct hda_codec *codec)
5892{
5893 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005894
Wu Fengguang864f92b2009-11-18 12:38:02 +08005895 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005896 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5897}
5898
5899static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5900{
5901 if ((res >> 26) == ALC880_HP_EVENT)
5902 alc260_hp_automute(codec);
5903}
5904
Kailang Yangdf694da2005-12-05 19:42:22 +01005905static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005906 {
5907 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5908 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005909 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005910 .info = snd_ctl_boolean_mono_info,
5911 .get = alc260_hp_master_sw_get,
5912 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005913 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005914 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005915 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5916 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5917 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5918 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5919 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5920 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005921 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5922 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005923 { } /* end */
5924};
5925
Kailang Yang3f878302008-08-26 13:02:23 +02005926static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5927 .ops = &snd_hda_bind_vol,
5928 .values = {
5929 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5930 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5931 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5932 0
5933 },
5934};
5935
5936static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5937 .ops = &snd_hda_bind_sw,
5938 .values = {
5939 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5940 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5941 0
5942 },
5943};
5944
5945static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5946 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5947 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5948 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5949 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5950 { } /* end */
5951};
5952
Takashi Iwaibec15c32008-01-28 18:16:30 +01005953static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5954 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5955 {},
5956};
5957
5958static void alc260_hp_3013_automute(struct hda_codec *codec)
5959{
5960 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005961
Wu Fengguang864f92b2009-11-18 12:38:02 +08005962 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005963 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005964}
5965
5966static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5967 unsigned int res)
5968{
5969 if ((res >> 26) == ALC880_HP_EVENT)
5970 alc260_hp_3013_automute(codec);
5971}
5972
Kailang Yang3f878302008-08-26 13:02:23 +02005973static void alc260_hp_3012_automute(struct hda_codec *codec)
5974{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005975 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005976
Kailang Yang3f878302008-08-26 13:02:23 +02005977 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5978 bits);
5979 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5980 bits);
5981 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5982 bits);
5983}
5984
5985static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5986 unsigned int res)
5987{
5988 if ((res >> 26) == ALC880_HP_EVENT)
5989 alc260_hp_3012_automute(codec);
5990}
5991
5992/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005993 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5994 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005995static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005996 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005997 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005998 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005999 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6000 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6001 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
6002 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006003 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006004 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6005 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006006 { } /* end */
6007};
6008
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006009/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
6010 * versions of the ALC260 don't act on requests to enable mic bias from NID
6011 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
6012 * datasheet doesn't mention this restriction. At this stage it's not clear
6013 * whether this behaviour is intentional or is a hardware bug in chip
6014 * revisions available in early 2006. Therefore for now allow the
6015 * "Headphone Jack Mode" control to span all choices, but if it turns out
6016 * that the lack of mic bias for this NID is intentional we could change the
6017 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6018 *
6019 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
6020 * don't appear to make the mic bias available from the "line" jack, even
6021 * though the NID used for this jack (0x14) can supply it. The theory is
6022 * that perhaps Acer have included blocking capacitors between the ALC260
6023 * and the output jack. If this turns out to be the case for all such
6024 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
6025 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01006026 *
6027 * The C20x Tablet series have a mono internal speaker which is controlled
6028 * via the chip's Mono sum widget and pin complex, so include the necessary
6029 * controls for such models. On models without a "mono speaker" the control
6030 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006031 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006032static struct snd_kcontrol_new alc260_acer_mixer[] = {
6033 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6034 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006035 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006036 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01006037 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006038 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01006039 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006040 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6041 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6042 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6043 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6044 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6045 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6046 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6047 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006048 { } /* end */
6049};
6050
Michael Schwingencc959482009-02-22 18:58:45 +01006051/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6052 */
6053static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
6054 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6055 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6056 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6057 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6058 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6059 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6060 { } /* end */
6061};
6062
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006063/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6064 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6065 */
6066static struct snd_kcontrol_new alc260_will_mixer[] = {
6067 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6068 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6069 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6070 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6071 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6072 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6073 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6074 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6075 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6076 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006077 { } /* end */
6078};
6079
6080/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6081 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6082 */
6083static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
6084 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6085 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6086 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6087 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6088 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6089 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6090 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6091 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6092 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6093 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6094 { } /* end */
6095};
6096
Kailang Yangdf694da2005-12-05 19:42:22 +01006097/*
6098 * initialization verbs
6099 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006100static struct hda_verb alc260_init_verbs[] = {
6101 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006102 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006103 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006104 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006105 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006106 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006107 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006108 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006109 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006110 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006111 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006112 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006113 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006114 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006115 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006116 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006117 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006118 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6119 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006120 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006121 /* set connection select to line in (default select for this ADC) */
6122 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006123 /* mute capture amp left and right */
6124 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6125 /* set connection select to line in (default select for this ADC) */
6126 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006127 /* set vol=0 Line-Out mixer amp left and right */
6128 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6129 /* unmute pin widget amp left and right (no gain on this amp) */
6130 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6131 /* set vol=0 HP mixer amp left and right */
6132 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6133 /* unmute pin widget amp left and right (no gain on this amp) */
6134 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6135 /* set vol=0 Mono mixer amp left and right */
6136 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6137 /* unmute pin widget amp left and right (no gain on this amp) */
6138 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6139 /* unmute LINE-2 out pin */
6140 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006141 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6142 * Line In 2 = 0x03
6143 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006144 /* mute analog inputs */
6145 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6146 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6148 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006150 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006151 /* mute Front out path */
6152 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6153 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6154 /* mute Headphone out path */
6155 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6156 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6157 /* mute Mono out path */
6158 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6159 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006160 { }
6161};
6162
Takashi Iwai474167d2006-05-17 17:17:43 +02006163#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006164static struct hda_verb alc260_hp_init_verbs[] = {
6165 /* Headphone and output */
6166 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6167 /* mono output */
6168 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6169 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6170 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6171 /* Mic2 (front panel) pin widget for input and vref at 80% */
6172 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6173 /* Line In pin widget for input */
6174 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6175 /* Line-2 pin widget for output */
6176 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6177 /* CD pin widget for input */
6178 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6179 /* unmute amp left and right */
6180 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6181 /* set connection select to line in (default select for this ADC) */
6182 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6183 /* unmute Line-Out mixer amp left and right (volume = 0) */
6184 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6185 /* mute pin widget amp left and right (no gain on this amp) */
6186 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6187 /* unmute HP mixer amp left and right (volume = 0) */
6188 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6189 /* mute pin widget amp left and right (no gain on this amp) */
6190 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006191 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6192 * Line In 2 = 0x03
6193 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006194 /* mute analog inputs */
6195 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6196 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6197 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6198 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6199 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006200 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6201 /* Unmute Front out path */
6202 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6203 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6204 /* Unmute Headphone out path */
6205 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6206 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6207 /* Unmute Mono out path */
6208 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6209 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6210 { }
6211};
Takashi Iwai474167d2006-05-17 17:17:43 +02006212#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006213
6214static struct hda_verb alc260_hp_3013_init_verbs[] = {
6215 /* Line out and output */
6216 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6217 /* mono output */
6218 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6219 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6220 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6221 /* Mic2 (front panel) pin widget for input and vref at 80% */
6222 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6223 /* Line In pin widget for input */
6224 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6225 /* Headphone pin widget for output */
6226 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6227 /* CD pin widget for input */
6228 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6229 /* unmute amp left and right */
6230 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6231 /* set connection select to line in (default select for this ADC) */
6232 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6233 /* unmute Line-Out mixer amp left and right (volume = 0) */
6234 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6235 /* mute pin widget amp left and right (no gain on this amp) */
6236 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6237 /* unmute HP mixer amp left and right (volume = 0) */
6238 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6239 /* mute pin widget amp left and right (no gain on this amp) */
6240 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006241 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6242 * Line In 2 = 0x03
6243 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006244 /* mute analog inputs */
6245 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6246 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006250 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6251 /* Unmute Front out path */
6252 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6253 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6254 /* Unmute Headphone out path */
6255 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6256 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6257 /* Unmute Mono out path */
6258 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6259 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6260 { }
6261};
6262
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006263/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006264 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6265 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006266 */
6267static struct hda_verb alc260_fujitsu_init_verbs[] = {
6268 /* Disable all GPIOs */
6269 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6270 /* Internal speaker is connected to headphone pin */
6271 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6272 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6273 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006274 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6275 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6276 /* Ensure all other unused pins are disabled and muted. */
6277 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6278 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006279 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006280 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006281 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006282 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6283 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6284 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006285
Jonathan Woithef7ace402006-02-28 11:46:14 +01006286 /* Disable digital (SPDIF) pins */
6287 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6288 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006289
Kailang Yangea1fb292008-08-26 12:58:38 +02006290 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006291 * when acting as an output.
6292 */
6293 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6294
6295 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006296 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6297 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6298 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6299 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6300 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6301 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6302 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6303 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6304 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006305
Jonathan Woithef7ace402006-02-28 11:46:14 +01006306 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6307 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6308 /* Unmute Line1 pin widget output buffer since it starts as an output.
6309 * If the pin mode is changed by the user the pin mode control will
6310 * take care of enabling the pin's input/output buffers as needed.
6311 * Therefore there's no need to enable the input buffer at this
6312 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006313 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006314 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006315 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006316 * mixer ctrl)
6317 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006318 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006319
Jonathan Woithef7ace402006-02-28 11:46:14 +01006320 /* Mute capture amp left and right */
6321 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006322 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006323 * in (on mic1 pin)
6324 */
6325 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006326
Jonathan Woithef7ace402006-02-28 11:46:14 +01006327 /* Do the same for the second ADC: mute capture input amp and
6328 * set ADC connection to line in (on mic1 pin)
6329 */
6330 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6331 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006332
Jonathan Woithef7ace402006-02-28 11:46:14 +01006333 /* Mute all inputs to mixer widget (even unconnected ones) */
6334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6335 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6336 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6337 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6338 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6339 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6340 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6341 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006342
6343 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006344};
6345
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006346/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6347 * similar laptops (adapted from Fujitsu init verbs).
6348 */
6349static struct hda_verb alc260_acer_init_verbs[] = {
6350 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6351 * the headphone jack. Turn this on and rely on the standard mute
6352 * methods whenever the user wants to turn these outputs off.
6353 */
6354 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6355 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6356 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6357 /* Internal speaker/Headphone jack is connected to Line-out pin */
6358 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6359 /* Internal microphone/Mic jack is connected to Mic1 pin */
6360 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6361 /* Line In jack is connected to Line1 pin */
6362 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006363 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6364 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006365 /* Ensure all other unused pins are disabled and muted. */
6366 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6367 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006368 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6369 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6370 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6371 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6372 /* Disable digital (SPDIF) pins */
6373 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6374 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6375
Kailang Yangea1fb292008-08-26 12:58:38 +02006376 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006377 * bus when acting as outputs.
6378 */
6379 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6380 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6381
6382 /* Start with output sum widgets muted and their output gains at min */
6383 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6384 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6385 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6386 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6387 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6388 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6389 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6390 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6391 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6392
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006393 /* Unmute Line-out pin widget amp left and right
6394 * (no equiv mixer ctrl)
6395 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006396 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006397 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6398 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006399 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6400 * inputs. If the pin mode is changed by the user the pin mode control
6401 * will take care of enabling the pin's input/output buffers as needed.
6402 * Therefore there's no need to enable the input buffer at this
6403 * stage.
6404 */
6405 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6406 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6407
6408 /* Mute capture amp left and right */
6409 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6410 /* Set ADC connection select to match default mixer setting - mic
6411 * (on mic1 pin)
6412 */
6413 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6414
6415 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006416 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006417 */
6418 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006419 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006420
6421 /* Mute all inputs to mixer widget (even unconnected ones) */
6422 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6423 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6424 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6425 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6426 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6427 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6428 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6429 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6430
6431 { }
6432};
6433
Michael Schwingencc959482009-02-22 18:58:45 +01006434/* Initialisation sequence for Maxdata Favorit 100XS
6435 * (adapted from Acer init verbs).
6436 */
6437static struct hda_verb alc260_favorit100_init_verbs[] = {
6438 /* GPIO 0 enables the output jack.
6439 * Turn this on and rely on the standard mute
6440 * methods whenever the user wants to turn these outputs off.
6441 */
6442 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6443 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6444 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6445 /* Line/Mic input jack is connected to Mic1 pin */
6446 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6447 /* Ensure all other unused pins are disabled and muted. */
6448 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6449 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6450 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6451 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6452 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6453 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6454 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6455 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6456 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6457 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6458 /* Disable digital (SPDIF) pins */
6459 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6460 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6461
6462 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6463 * bus when acting as outputs.
6464 */
6465 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6466 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6467
6468 /* Start with output sum widgets muted and their output gains at min */
6469 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6470 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6471 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6472 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6473 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6474 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6475 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6476 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6477 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6478
6479 /* Unmute Line-out pin widget amp left and right
6480 * (no equiv mixer ctrl)
6481 */
6482 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6483 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6484 * inputs. If the pin mode is changed by the user the pin mode control
6485 * will take care of enabling the pin's input/output buffers as needed.
6486 * Therefore there's no need to enable the input buffer at this
6487 * stage.
6488 */
6489 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6490
6491 /* Mute capture amp left and right */
6492 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6493 /* Set ADC connection select to match default mixer setting - mic
6494 * (on mic1 pin)
6495 */
6496 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6497
6498 /* Do similar with the second ADC: mute capture input amp and
6499 * set ADC connection to mic to match ALSA's default state.
6500 */
6501 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6502 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6503
6504 /* Mute all inputs to mixer widget (even unconnected ones) */
6505 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6506 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6507 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6508 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6509 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6510 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6511 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6512 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6513
6514 { }
6515};
6516
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006517static struct hda_verb alc260_will_verbs[] = {
6518 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6519 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6520 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6521 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6522 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6523 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6524 {}
6525};
6526
6527static struct hda_verb alc260_replacer_672v_verbs[] = {
6528 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6529 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6530 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6531
6532 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6533 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6534 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6535
6536 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6537 {}
6538};
6539
6540/* toggle speaker-output according to the hp-jack state */
6541static void alc260_replacer_672v_automute(struct hda_codec *codec)
6542{
6543 unsigned int present;
6544
6545 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006546 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006547 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006548 snd_hda_codec_write_cache(codec, 0x01, 0,
6549 AC_VERB_SET_GPIO_DATA, 1);
6550 snd_hda_codec_write_cache(codec, 0x0f, 0,
6551 AC_VERB_SET_PIN_WIDGET_CONTROL,
6552 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006553 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006554 snd_hda_codec_write_cache(codec, 0x01, 0,
6555 AC_VERB_SET_GPIO_DATA, 0);
6556 snd_hda_codec_write_cache(codec, 0x0f, 0,
6557 AC_VERB_SET_PIN_WIDGET_CONTROL,
6558 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006559 }
6560}
6561
6562static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6563 unsigned int res)
6564{
6565 if ((res >> 26) == ALC880_HP_EVENT)
6566 alc260_replacer_672v_automute(codec);
6567}
6568
Kailang Yang3f878302008-08-26 13:02:23 +02006569static struct hda_verb alc260_hp_dc7600_verbs[] = {
6570 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6571 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6572 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6573 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6574 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6575 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6576 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6577 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6578 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6579 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6580 {}
6581};
6582
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006583/* Test configuration for debugging, modelled after the ALC880 test
6584 * configuration.
6585 */
6586#ifdef CONFIG_SND_DEBUG
6587static hda_nid_t alc260_test_dac_nids[1] = {
6588 0x02,
6589};
6590static hda_nid_t alc260_test_adc_nids[2] = {
6591 0x04, 0x05,
6592};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006593/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006594 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006595 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006596 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006597static struct hda_input_mux alc260_test_capture_sources[2] = {
6598 {
6599 .num_items = 7,
6600 .items = {
6601 { "MIC1 pin", 0x0 },
6602 { "MIC2 pin", 0x1 },
6603 { "LINE1 pin", 0x2 },
6604 { "LINE2 pin", 0x3 },
6605 { "CD pin", 0x4 },
6606 { "LINE-OUT pin", 0x5 },
6607 { "HP-OUT pin", 0x6 },
6608 },
6609 },
6610 {
6611 .num_items = 8,
6612 .items = {
6613 { "MIC1 pin", 0x0 },
6614 { "MIC2 pin", 0x1 },
6615 { "LINE1 pin", 0x2 },
6616 { "LINE2 pin", 0x3 },
6617 { "CD pin", 0x4 },
6618 { "Mixer", 0x5 },
6619 { "LINE-OUT pin", 0x6 },
6620 { "HP-OUT pin", 0x7 },
6621 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006622 },
6623};
6624static struct snd_kcontrol_new alc260_test_mixer[] = {
6625 /* Output driver widgets */
6626 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6627 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6628 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6629 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6630 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6631 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6632
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006633 /* Modes for retasking pin widgets
6634 * Note: the ALC260 doesn't seem to act on requests to enable mic
6635 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6636 * mention this restriction. At this stage it's not clear whether
6637 * this behaviour is intentional or is a hardware bug in chip
6638 * revisions available at least up until early 2006. Therefore for
6639 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6640 * choices, but if it turns out that the lack of mic bias for these
6641 * NIDs is intentional we could change their modes from
6642 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6643 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006644 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6645 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6646 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6647 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6648 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6649 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6650
6651 /* Loopback mixer controls */
6652 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6653 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6654 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6655 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6656 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6657 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6658 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6659 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6660 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6661 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006662 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6663 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6664 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6665 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006666
6667 /* Controls for GPIO pins, assuming they are configured as outputs */
6668 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6669 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6670 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6671 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6672
Jonathan Woithe92621f12006-02-28 11:47:47 +01006673 /* Switches to allow the digital IO pins to be enabled. The datasheet
6674 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006675 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006676 */
6677 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6678 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6679
Jonathan Woithef8225f62008-01-08 12:16:54 +01006680 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6681 * this output to turn on an external amplifier.
6682 */
6683 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6684 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6685
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006686 { } /* end */
6687};
6688static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006689 /* Enable all GPIOs as outputs with an initial value of 0 */
6690 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6691 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6692 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6693
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006694 /* Enable retasking pins as output, initially without power amp */
6695 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6696 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6697 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6698 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6699 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6700 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6701
Jonathan Woithe92621f12006-02-28 11:47:47 +01006702 /* Disable digital (SPDIF) pins initially, but users can enable
6703 * them via a mixer switch. In the case of SPDIF-out, this initverb
6704 * payload also sets the generation to 0, output to be in "consumer"
6705 * PCM format, copyright asserted, no pre-emphasis and no validity
6706 * control.
6707 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006708 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6709 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6710
Kailang Yangea1fb292008-08-26 12:58:38 +02006711 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006712 * OUT1 sum bus when acting as an output.
6713 */
6714 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6715 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6716 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6717 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6718
6719 /* Start with output sum widgets muted and their output gains at min */
6720 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6721 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6722 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6723 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6724 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6725 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6726 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6727 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6728 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6729
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006730 /* Unmute retasking pin widget output buffers since the default
6731 * state appears to be output. As the pin mode is changed by the
6732 * user the pin mode control will take care of enabling the pin's
6733 * input/output buffers as needed.
6734 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006735 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6736 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6737 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6738 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6739 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6740 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6741 /* Also unmute the mono-out pin widget */
6742 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6743
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006744 /* Mute capture amp left and right */
6745 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006746 /* Set ADC connection select to match default mixer setting (mic1
6747 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006748 */
6749 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6750
6751 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006752 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006753 */
6754 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6755 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6756
6757 /* Mute all inputs to mixer widget (even unconnected ones) */
6758 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6759 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6760 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6761 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6762 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6763 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6764 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6765 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6766
6767 { }
6768};
6769#endif
6770
Takashi Iwai63300792008-01-24 15:31:36 +01006771#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6772#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006773
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006774#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6775#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6776
Kailang Yangdf694da2005-12-05 19:42:22 +01006777/*
6778 * for BIOS auto-configuration
6779 */
6780
6781static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006782 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006783{
6784 hda_nid_t nid_vol;
6785 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006786 int err;
6787
6788 if (nid >= 0x0f && nid < 0x11) {
6789 nid_vol = nid - 0x7;
6790 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6791 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6792 } else if (nid == 0x11) {
6793 nid_vol = nid - 0x7;
6794 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6795 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6796 } else if (nid >= 0x12 && nid <= 0x15) {
6797 nid_vol = 0x08;
6798 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6799 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6800 } else
6801 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006802
Takashi Iwai863b4512008-10-21 17:01:47 +02006803 if (!(*vol_bits & (1 << nid_vol))) {
6804 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006805 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006806 if (err < 0)
6807 return err;
6808 *vol_bits |= (1 << nid_vol);
6809 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006810 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006811 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006812 return err;
6813 return 1;
6814}
6815
6816/* add playback controls from the parsed DAC table */
6817static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6818 const struct auto_pin_cfg *cfg)
6819{
6820 hda_nid_t nid;
6821 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006822 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006823
6824 spec->multiout.num_dacs = 1;
6825 spec->multiout.dac_nids = spec->private_dac_nids;
6826 spec->multiout.dac_nids[0] = 0x02;
6827
6828 nid = cfg->line_out_pins[0];
6829 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006830 const char *pfx;
6831 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6832 pfx = "Master";
6833 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6834 pfx = "Speaker";
6835 else
6836 pfx = "Front";
6837 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006838 if (err < 0)
6839 return err;
6840 }
6841
Takashi Iwai82bc9552006-03-21 11:24:42 +01006842 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006843 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006844 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006845 if (err < 0)
6846 return err;
6847 }
6848
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006849 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006850 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006851 err = alc260_add_playback_controls(spec, nid, "Headphone",
6852 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006853 if (err < 0)
6854 return err;
6855 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006856 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006857}
6858
6859/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006860static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006861 const struct auto_pin_cfg *cfg)
6862{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006863 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006864}
6865
6866static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6867 hda_nid_t nid, int pin_type,
6868 int sel_idx)
6869{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006870 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006871 /* need the manual connection? */
6872 if (nid >= 0x12) {
6873 int idx = nid - 0x12;
6874 snd_hda_codec_write(codec, idx + 0x0b, 0,
6875 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006876 }
6877}
6878
6879static void alc260_auto_init_multi_out(struct hda_codec *codec)
6880{
6881 struct alc_spec *spec = codec->spec;
6882 hda_nid_t nid;
6883
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006884 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006885 if (nid) {
6886 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6887 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6888 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006889
Takashi Iwai82bc9552006-03-21 11:24:42 +01006890 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006891 if (nid)
6892 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6893
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006894 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006895 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006896 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006897}
Kailang Yangdf694da2005-12-05 19:42:22 +01006898
6899#define ALC260_PIN_CD_NID 0x16
6900static void alc260_auto_init_analog_input(struct hda_codec *codec)
6901{
6902 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006903 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01006904 int i;
6905
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006906 for (i = 0; i < cfg->num_inputs; i++) {
6907 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01006908 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02006909 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006910 if (nid != ALC260_PIN_CD_NID &&
6911 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006912 snd_hda_codec_write(codec, nid, 0,
6913 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006914 AMP_OUT_MUTE);
6915 }
6916 }
6917}
6918
Takashi Iwai7f311a42010-04-09 17:32:23 +02006919#define alc260_auto_init_input_src alc880_auto_init_input_src
6920
Kailang Yangdf694da2005-12-05 19:42:22 +01006921/*
6922 * generic initialization of ADC, input mixers and output mixers
6923 */
6924static struct hda_verb alc260_volume_init_verbs[] = {
6925 /*
6926 * Unmute ADC0-1 and set the default input to mic-in
6927 */
6928 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6929 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6930 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6931 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006932
Kailang Yangdf694da2005-12-05 19:42:22 +01006933 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6934 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006935 * Note: PASD motherboards uses the Line In 2 as the input for
6936 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006937 */
6938 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006939 /* mute analog inputs */
6940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6943 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6944 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006945
6946 /*
6947 * Set up output mixers (0x08 - 0x0a)
6948 */
6949 /* set vol=0 to output mixers */
6950 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6951 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6952 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6953 /* set up input amps for analog loopback */
6954 /* Amp Indices: DAC = 0, mixer = 1 */
6955 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6956 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6957 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6958 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6959 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6960 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006961
Kailang Yangdf694da2005-12-05 19:42:22 +01006962 { }
6963};
6964
6965static int alc260_parse_auto_config(struct hda_codec *codec)
6966{
6967 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006968 int err;
6969 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6970
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006971 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6972 alc260_ignore);
6973 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006974 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006975 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6976 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006977 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006978 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006979 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006980 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006981 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006982 return err;
6983
6984 spec->multiout.max_channels = 2;
6985
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006986 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006987 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006988 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006989 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006990
Takashi Iwaid88897e2008-10-31 15:01:37 +01006991 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006992
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006993 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006994 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006995
Kailang Yang6227cdc2010-02-25 08:36:52 +01006996 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006997
Kailang Yangdf694da2005-12-05 19:42:22 +01006998 return 1;
6999}
7000
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007001/* additional initialization for auto-configuration model */
7002static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007003{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007004 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007005 alc260_auto_init_multi_out(codec);
7006 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02007007 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02007008 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007009 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007010 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007011}
7012
Takashi Iwaicb53c622007-08-10 17:21:45 +02007013#ifdef CONFIG_SND_HDA_POWER_SAVE
7014static struct hda_amp_list alc260_loopbacks[] = {
7015 { 0x07, HDA_INPUT, 0 },
7016 { 0x07, HDA_INPUT, 1 },
7017 { 0x07, HDA_INPUT, 2 },
7018 { 0x07, HDA_INPUT, 3 },
7019 { 0x07, HDA_INPUT, 4 },
7020 { } /* end */
7021};
7022#endif
7023
Kailang Yangdf694da2005-12-05 19:42:22 +01007024/*
Takashi Iwaifc091762010-08-04 23:53:36 +02007025 * Pin config fixes
7026 */
7027enum {
7028 PINFIX_HP_DC5750,
7029};
7030
Takashi Iwaifc091762010-08-04 23:53:36 +02007031static const struct alc_fixup alc260_fixups[] = {
7032 [PINFIX_HP_DC5750] = {
Takashi Iwai73413b12010-08-30 09:39:57 +02007033 .pins = (const struct alc_pincfg[]) {
7034 { 0x11, 0x90130110 }, /* speaker */
7035 { }
7036 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007037 },
7038};
7039
7040static struct snd_pci_quirk alc260_fixup_tbl[] = {
7041 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
7042 {}
7043};
7044
7045/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007046 * ALC260 configurations
7047 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007048static const char *alc260_models[ALC260_MODEL_LAST] = {
7049 [ALC260_BASIC] = "basic",
7050 [ALC260_HP] = "hp",
7051 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007052 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007053 [ALC260_FUJITSU_S702X] = "fujitsu",
7054 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007055 [ALC260_WILL] = "will",
7056 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007057 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007058#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007059 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007060#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007061 [ALC260_AUTO] = "auto",
7062};
7063
7064static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007065 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007066 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007067 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007068 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007069 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007070 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007071 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007072 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007073 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007074 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7075 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7076 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7077 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7078 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7079 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7080 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7081 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7082 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007083 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007084 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007085 {}
7086};
7087
Kailang Yangdf694da2005-12-05 19:42:22 +01007088static struct alc_config_preset alc260_presets[] = {
7089 [ALC260_BASIC] = {
7090 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007091 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007092 .init_verbs = { alc260_init_verbs },
7093 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7094 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007095 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007096 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007097 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7098 .channel_mode = alc260_modes,
7099 .input_mux = &alc260_capture_source,
7100 },
7101 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007102 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007103 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007104 .init_verbs = { alc260_init_verbs,
7105 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007106 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7107 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007108 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7109 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007110 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7111 .channel_mode = alc260_modes,
7112 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007113 .unsol_event = alc260_hp_unsol_event,
7114 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007115 },
Kailang Yang3f878302008-08-26 13:02:23 +02007116 [ALC260_HP_DC7600] = {
7117 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007118 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007119 .init_verbs = { alc260_init_verbs,
7120 alc260_hp_dc7600_verbs },
7121 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7122 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007123 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7124 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007125 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7126 .channel_mode = alc260_modes,
7127 .input_mux = &alc260_capture_source,
7128 .unsol_event = alc260_hp_3012_unsol_event,
7129 .init_hook = alc260_hp_3012_automute,
7130 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007131 [ALC260_HP_3013] = {
7132 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007133 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007134 .init_verbs = { alc260_hp_3013_init_verbs,
7135 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007136 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7137 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007138 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7139 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007140 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7141 .channel_mode = alc260_modes,
7142 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007143 .unsol_event = alc260_hp_3013_unsol_event,
7144 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007145 },
7146 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007147 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007148 .init_verbs = { alc260_fujitsu_init_verbs },
7149 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7150 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007151 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7152 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007153 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7154 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007155 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7156 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007157 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007158 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007159 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007160 .init_verbs = { alc260_acer_init_verbs },
7161 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7162 .dac_nids = alc260_dac_nids,
7163 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7164 .adc_nids = alc260_dual_adc_nids,
7165 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7166 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007167 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7168 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007169 },
Michael Schwingencc959482009-02-22 18:58:45 +01007170 [ALC260_FAVORIT100] = {
7171 .mixers = { alc260_favorit100_mixer },
7172 .init_verbs = { alc260_favorit100_init_verbs },
7173 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7174 .dac_nids = alc260_dac_nids,
7175 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7176 .adc_nids = alc260_dual_adc_nids,
7177 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7178 .channel_mode = alc260_modes,
7179 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7180 .input_mux = alc260_favorit100_capture_sources,
7181 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007182 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007183 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007184 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7185 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7186 .dac_nids = alc260_dac_nids,
7187 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7188 .adc_nids = alc260_adc_nids,
7189 .dig_out_nid = ALC260_DIGOUT_NID,
7190 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7191 .channel_mode = alc260_modes,
7192 .input_mux = &alc260_capture_source,
7193 },
7194 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007195 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007196 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7197 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7198 .dac_nids = alc260_dac_nids,
7199 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7200 .adc_nids = alc260_adc_nids,
7201 .dig_out_nid = ALC260_DIGOUT_NID,
7202 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7203 .channel_mode = alc260_modes,
7204 .input_mux = &alc260_capture_source,
7205 .unsol_event = alc260_replacer_672v_unsol_event,
7206 .init_hook = alc260_replacer_672v_automute,
7207 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007208#ifdef CONFIG_SND_DEBUG
7209 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007210 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007211 .init_verbs = { alc260_test_init_verbs },
7212 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7213 .dac_nids = alc260_test_dac_nids,
7214 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7215 .adc_nids = alc260_test_adc_nids,
7216 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7217 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007218 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7219 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007220 },
7221#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007222};
7223
Linus Torvalds1da177e2005-04-16 15:20:36 -07007224static int patch_alc260(struct hda_codec *codec)
7225{
7226 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007227 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007228
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007229 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007230 if (spec == NULL)
7231 return -ENOMEM;
7232
7233 codec->spec = spec;
7234
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007235 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7236 alc260_models,
7237 alc260_cfg_tbl);
7238 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007239 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007240 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007241 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007242 }
7243
Takashi Iwaifc091762010-08-04 23:53:36 +02007244 if (board_config == ALC260_AUTO)
7245 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 1);
7246
Kailang Yangdf694da2005-12-05 19:42:22 +01007247 if (board_config == ALC260_AUTO) {
7248 /* automatic parse from the BIOS config */
7249 err = alc260_parse_auto_config(codec);
7250 if (err < 0) {
7251 alc_free(codec);
7252 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007253 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007254 printk(KERN_INFO
7255 "hda_codec: Cannot set up configuration "
7256 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007257 board_config = ALC260_BASIC;
7258 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007259 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007260
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007261 err = snd_hda_attach_beep_device(codec, 0x1);
7262 if (err < 0) {
7263 alc_free(codec);
7264 return err;
7265 }
7266
Kailang Yangdf694da2005-12-05 19:42:22 +01007267 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007268 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007269
Linus Torvalds1da177e2005-04-16 15:20:36 -07007270 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7271 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307272 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007273
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007274 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7275 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7276
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007277 if (!spec->adc_nids && spec->input_mux) {
7278 /* check whether NID 0x04 is valid */
7279 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007280 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007281 /* get type */
7282 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7283 spec->adc_nids = alc260_adc_nids_alt;
7284 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7285 } else {
7286 spec->adc_nids = alc260_adc_nids;
7287 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7288 }
7289 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007290 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007291 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007292
Takashi Iwaifc091762010-08-04 23:53:36 +02007293 if (board_config == ALC260_AUTO)
7294 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 0);
7295
Takashi Iwai2134ea42008-01-10 16:53:55 +01007296 spec->vmaster_nid = 0x08;
7297
Linus Torvalds1da177e2005-04-16 15:20:36 -07007298 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007299 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007300 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007301#ifdef CONFIG_SND_HDA_POWER_SAVE
7302 if (!spec->loopback.amplist)
7303 spec->loopback.amplist = alc260_loopbacks;
7304#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007305
7306 return 0;
7307}
7308
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007309
Linus Torvalds1da177e2005-04-16 15:20:36 -07007310/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007311 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007312 *
7313 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7314 * configuration. Each pin widget can choose any input DACs and a mixer.
7315 * Each ADC is connected from a mixer of all inputs. This makes possible
7316 * 6-channel independent captures.
7317 *
7318 * In addition, an independent DAC for the multi-playback (not used in this
7319 * driver yet).
7320 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007321#define ALC882_DIGOUT_NID 0x06
7322#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007323#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7324#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7325#define ALC1200_DIGOUT_NID 0x10
7326
Linus Torvalds1da177e2005-04-16 15:20:36 -07007327
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007328static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007329 { 8, NULL }
7330};
7331
Takashi Iwai4953550a2009-06-30 15:28:30 +02007332/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007333static hda_nid_t alc882_dac_nids[4] = {
7334 /* front, rear, clfe, rear_surr */
7335 0x02, 0x03, 0x04, 0x05
7336};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007337#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007338
Takashi Iwai4953550a2009-06-30 15:28:30 +02007339/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007340#define alc882_adc_nids alc880_adc_nids
7341#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007342#define alc883_adc_nids alc882_adc_nids_alt
7343static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7344static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7345#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007346
Takashi Iwaie1406342008-02-11 18:32:32 +01007347static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7348static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007349#define alc883_capsrc_nids alc882_capsrc_nids_alt
7350static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7351#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007352
Linus Torvalds1da177e2005-04-16 15:20:36 -07007353/* input MUX */
7354/* FIXME: should be a matrix-type input source selection */
7355
7356static struct hda_input_mux alc882_capture_source = {
7357 .num_items = 4,
7358 .items = {
7359 { "Mic", 0x0 },
7360 { "Front Mic", 0x1 },
7361 { "Line", 0x2 },
7362 { "CD", 0x4 },
7363 },
7364};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007365
Takashi Iwai4953550a2009-06-30 15:28:30 +02007366#define alc883_capture_source alc882_capture_source
7367
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007368static struct hda_input_mux alc889_capture_source = {
7369 .num_items = 3,
7370 .items = {
7371 { "Front Mic", 0x0 },
7372 { "Mic", 0x3 },
7373 { "Line", 0x2 },
7374 },
7375};
7376
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007377static struct hda_input_mux mb5_capture_source = {
7378 .num_items = 3,
7379 .items = {
7380 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307381 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007382 { "CD", 0x4 },
7383 },
7384};
7385
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007386static struct hda_input_mux macmini3_capture_source = {
7387 .num_items = 2,
7388 .items = {
7389 { "Line", 0x2 },
7390 { "CD", 0x4 },
7391 },
7392};
7393
Takashi Iwai4953550a2009-06-30 15:28:30 +02007394static struct hda_input_mux alc883_3stack_6ch_intel = {
7395 .num_items = 4,
7396 .items = {
7397 { "Mic", 0x1 },
7398 { "Front Mic", 0x0 },
7399 { "Line", 0x2 },
7400 { "CD", 0x4 },
7401 },
7402};
7403
7404static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7405 .num_items = 2,
7406 .items = {
7407 { "Mic", 0x1 },
7408 { "Line", 0x2 },
7409 },
7410};
7411
7412static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7413 .num_items = 4,
7414 .items = {
7415 { "Mic", 0x0 },
David Henningsson150b4322010-07-29 14:46:42 +02007416 { "Int Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007417 { "Line", 0x2 },
7418 { "CD", 0x4 },
7419 },
7420};
7421
7422static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7423 .num_items = 2,
7424 .items = {
7425 { "Mic", 0x0 },
7426 { "Int Mic", 0x1 },
7427 },
7428};
7429
7430static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7431 .num_items = 3,
7432 .items = {
7433 { "Mic", 0x0 },
7434 { "Front Mic", 0x1 },
7435 { "Line", 0x4 },
7436 },
7437};
7438
7439static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7440 .num_items = 2,
7441 .items = {
7442 { "Mic", 0x0 },
7443 { "Line", 0x2 },
7444 },
7445};
7446
7447static struct hda_input_mux alc889A_mb31_capture_source = {
7448 .num_items = 2,
7449 .items = {
7450 { "Mic", 0x0 },
7451 /* Front Mic (0x01) unused */
7452 { "Line", 0x2 },
7453 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007454 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007455 },
7456};
7457
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007458static struct hda_input_mux alc889A_imac91_capture_source = {
7459 .num_items = 2,
7460 .items = {
7461 { "Mic", 0x01 },
7462 { "Line", 0x2 }, /* Not sure! */
7463 },
7464};
7465
Takashi Iwai4953550a2009-06-30 15:28:30 +02007466/*
7467 * 2ch mode
7468 */
7469static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7470 { 2, NULL }
7471};
7472
Kailang Yangdf694da2005-12-05 19:42:22 +01007473/*
Kailang Yang272a5272007-05-14 11:00:38 +02007474 * 2ch mode
7475 */
7476static struct hda_verb alc882_3ST_ch2_init[] = {
7477 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7478 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7479 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7480 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7481 { } /* end */
7482};
7483
7484/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007485 * 4ch mode
7486 */
7487static struct hda_verb alc882_3ST_ch4_init[] = {
7488 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7489 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7490 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7491 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7492 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7493 { } /* end */
7494};
7495
7496/*
Kailang Yang272a5272007-05-14 11:00:38 +02007497 * 6ch mode
7498 */
7499static struct hda_verb alc882_3ST_ch6_init[] = {
7500 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7501 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7502 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7503 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7504 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7505 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7506 { } /* end */
7507};
7508
Takashi Iwai4953550a2009-06-30 15:28:30 +02007509static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007510 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007511 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007512 { 6, alc882_3ST_ch6_init },
7513};
7514
Takashi Iwai4953550a2009-06-30 15:28:30 +02007515#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7516
Kailang Yang272a5272007-05-14 11:00:38 +02007517/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307518 * 2ch mode
7519 */
7520static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7521 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7522 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7523 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7524 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7525 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7526 { } /* end */
7527};
7528
7529/*
7530 * 4ch mode
7531 */
7532static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7533 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7534 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7535 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7536 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7537 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7538 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7539 { } /* end */
7540};
7541
7542/*
7543 * 6ch mode
7544 */
7545static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7546 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7547 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7548 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7549 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7550 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7551 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7552 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7553 { } /* end */
7554};
7555
7556static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7557 { 2, alc883_3ST_ch2_clevo_init },
7558 { 4, alc883_3ST_ch4_clevo_init },
7559 { 6, alc883_3ST_ch6_clevo_init },
7560};
7561
7562
7563/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007564 * 6ch mode
7565 */
7566static struct hda_verb alc882_sixstack_ch6_init[] = {
7567 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7568 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7569 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7570 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7571 { } /* end */
7572};
7573
7574/*
7575 * 8ch mode
7576 */
7577static struct hda_verb alc882_sixstack_ch8_init[] = {
7578 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7579 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7580 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7581 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7582 { } /* end */
7583};
7584
7585static struct hda_channel_mode alc882_sixstack_modes[2] = {
7586 { 6, alc882_sixstack_ch6_init },
7587 { 8, alc882_sixstack_ch8_init },
7588};
7589
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007590
7591/* Macbook Air 2,1 */
7592
7593static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7594 { 2, NULL },
7595};
7596
Takashi Iwai87350ad2007-08-16 18:19:38 +02007597/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007598 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007599 */
7600
7601/*
7602 * 2ch mode
7603 */
7604static struct hda_verb alc885_mbp_ch2_init[] = {
7605 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7606 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7607 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7608 { } /* end */
7609};
7610
7611/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007612 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007613 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007614static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007615 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7616 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7617 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7618 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7619 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7620 { } /* end */
7621};
7622
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007623static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007624 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007625 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007626};
7627
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007628/*
7629 * 2ch
7630 * Speakers/Woofer/HP = Front
7631 * LineIn = Input
7632 */
7633static struct hda_verb alc885_mb5_ch2_init[] = {
7634 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7635 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7636 { } /* end */
7637};
7638
7639/*
7640 * 6ch mode
7641 * Speakers/HP = Front
7642 * Woofer = LFE
7643 * LineIn = Surround
7644 */
7645static struct hda_verb alc885_mb5_ch6_init[] = {
7646 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7647 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7648 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7649 { } /* end */
7650};
7651
7652static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7653 { 2, alc885_mb5_ch2_init },
7654 { 6, alc885_mb5_ch6_init },
7655};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007656
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007657#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007658
7659/*
7660 * 2ch mode
7661 */
7662static struct hda_verb alc883_4ST_ch2_init[] = {
7663 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7664 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7665 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7666 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7667 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7668 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7669 { } /* end */
7670};
7671
7672/*
7673 * 4ch mode
7674 */
7675static struct hda_verb alc883_4ST_ch4_init[] = {
7676 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7677 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7678 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7679 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7680 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7681 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7682 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7683 { } /* end */
7684};
7685
7686/*
7687 * 6ch mode
7688 */
7689static struct hda_verb alc883_4ST_ch6_init[] = {
7690 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7691 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7692 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7693 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7694 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7695 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7696 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7697 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7698 { } /* end */
7699};
7700
7701/*
7702 * 8ch mode
7703 */
7704static struct hda_verb alc883_4ST_ch8_init[] = {
7705 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7706 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7707 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7708 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7709 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7710 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7711 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7712 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7713 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7714 { } /* end */
7715};
7716
7717static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7718 { 2, alc883_4ST_ch2_init },
7719 { 4, alc883_4ST_ch4_init },
7720 { 6, alc883_4ST_ch6_init },
7721 { 8, alc883_4ST_ch8_init },
7722};
7723
7724
7725/*
7726 * 2ch mode
7727 */
7728static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7729 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7730 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7731 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7732 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7733 { } /* end */
7734};
7735
7736/*
7737 * 4ch mode
7738 */
7739static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7740 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7741 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7742 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7743 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7744 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7745 { } /* end */
7746};
7747
7748/*
7749 * 6ch mode
7750 */
7751static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7752 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7753 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7754 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7755 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7756 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7757 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7758 { } /* end */
7759};
7760
7761static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7762 { 2, alc883_3ST_ch2_intel_init },
7763 { 4, alc883_3ST_ch4_intel_init },
7764 { 6, alc883_3ST_ch6_intel_init },
7765};
7766
7767/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007768 * 2ch mode
7769 */
7770static struct hda_verb alc889_ch2_intel_init[] = {
7771 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7772 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7773 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7774 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7775 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7776 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7777 { } /* end */
7778};
7779
7780/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007781 * 6ch mode
7782 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007783static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007784 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7785 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7786 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7787 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7788 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007789 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7790 { } /* end */
7791};
7792
7793/*
7794 * 8ch mode
7795 */
7796static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007797 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7798 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7799 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7800 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7801 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007802 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7803 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007804 { } /* end */
7805};
7806
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007807static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7808 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007809 { 6, alc889_ch6_intel_init },
7810 { 8, alc889_ch8_intel_init },
7811};
7812
7813/*
7814 * 6ch mode
7815 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007816static struct hda_verb alc883_sixstack_ch6_init[] = {
7817 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7818 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7819 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7820 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7821 { } /* end */
7822};
7823
7824/*
7825 * 8ch mode
7826 */
7827static struct hda_verb alc883_sixstack_ch8_init[] = {
7828 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7829 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7830 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7831 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7832 { } /* end */
7833};
7834
7835static struct hda_channel_mode alc883_sixstack_modes[2] = {
7836 { 6, alc883_sixstack_ch6_init },
7837 { 8, alc883_sixstack_ch8_init },
7838};
7839
7840
Linus Torvalds1da177e2005-04-16 15:20:36 -07007841/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7842 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7843 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007844static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007845 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007846 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007847 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007848 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007849 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7850 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007851 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7852 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007853 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007854 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007855 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7856 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7857 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7858 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7859 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7860 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007861 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007862 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7863 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007864 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007865 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007866 { } /* end */
7867};
7868
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007869/* Macbook Air 2,1 same control for HP and internal Speaker */
7870
7871static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7872 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7873 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7874 { }
7875};
7876
7877
Takashi Iwai87350ad2007-08-16 18:19:38 +02007878static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007879 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7880 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7881 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7882 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7883 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007884 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7885 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007886 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7887 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007888 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007889 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7890 { } /* end */
7891};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007892
7893static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007894 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7895 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7896 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7897 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7898 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7899 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307900 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7901 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307902 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7903 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007904 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7905 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7906 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7907 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7908 { } /* end */
7909};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007910
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007911static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7912 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7913 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7914 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7915 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7916 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7917 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7918 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7919 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7920 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7921 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7922 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7923 { } /* end */
7924};
7925
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007926static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007927 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7928 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007929 { } /* end */
7930};
7931
7932
Kailang Yangbdd148a2007-05-08 15:19:08 +02007933static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7934 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7935 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7936 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7937 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7938 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7939 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7940 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7941 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7942 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007943 { } /* end */
7944};
7945
Kailang Yang272a5272007-05-14 11:00:38 +02007946static struct snd_kcontrol_new alc882_targa_mixer[] = {
7947 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7948 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7949 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7950 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7951 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7952 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7953 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007956 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007957 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7958 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007959 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007960 { } /* end */
7961};
7962
7963/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7964 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7965 */
7966static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7967 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7968 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7969 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7970 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7971 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7972 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7973 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7974 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7975 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7976 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7977 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7978 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007979 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007980 { } /* end */
7981};
7982
Takashi Iwai914759b2007-09-06 14:52:04 +02007983static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7984 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7985 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7986 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7987 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7988 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7989 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7990 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7991 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7992 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7993 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007994 { } /* end */
7995};
7996
Kailang Yangdf694da2005-12-05 19:42:22 +01007997static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7998 {
7999 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8000 .name = "Channel Mode",
8001 .info = alc_ch_mode_info,
8002 .get = alc_ch_mode_get,
8003 .put = alc_ch_mode_put,
8004 },
8005 { } /* end */
8006};
8007
Takashi Iwai4953550a2009-06-30 15:28:30 +02008008static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07008009 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008010 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8011 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008012 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008013 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8014 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008015 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008016 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8017 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008018 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008019 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8020 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008021
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008022 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008023 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008024 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008025 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008026 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008027 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008028 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008029 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008030 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008031 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008032 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008033 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008034 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008035 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008036 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008037 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008038 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008039 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008040 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8041 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008042 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008043 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8044 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008045 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008046 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8047 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8048 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8049 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8050 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008051 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008052 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008053
8054 /* FIXME: use matrix-type input source selection */
8055 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008056 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008057 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008058 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008059 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008060 /* ADC2: mute amp left and right */
8061 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008062 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008063 /* ADC3: mute amp left and right */
8064 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008065 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008066
8067 { }
8068};
8069
Takashi Iwai4953550a2009-06-30 15:28:30 +02008070static struct hda_verb alc882_adc1_init_verbs[] = {
8071 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8072 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8073 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8074 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8075 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8076 /* ADC1: mute amp left and right */
8077 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8078 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8079 { }
8080};
8081
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008082static struct hda_verb alc882_eapd_verbs[] = {
8083 /* change to EAPD mode */
8084 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008085 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008086 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008087};
8088
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008089static struct hda_verb alc889_eapd_verbs[] = {
8090 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8091 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8092 { }
8093};
8094
Wu Fengguang6732bd02009-07-30 09:19:14 +02008095static struct hda_verb alc_hp15_unsol_verbs[] = {
8096 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8097 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8098 {}
8099};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008100
8101static struct hda_verb alc885_init_verbs[] = {
8102 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008103 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8104 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008105 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008106 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8107 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008108 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008109 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8110 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008111 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008112 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8113 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008114
8115 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008116 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008117 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8118 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8119 /* Front Pin: output 0 (0x0c) */
8120 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8121 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8122 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8123 /* Rear Pin: output 1 (0x0d) */
8124 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8125 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8126 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8127 /* CLFE Pin: output 2 (0x0e) */
8128 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8129 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8130 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8131 /* Side Pin: output 3 (0x0f) */
8132 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8133 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8134 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8135 /* Mic (rear) pin: input vref at 80% */
8136 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8137 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8138 /* Front Mic pin: input vref at 80% */
8139 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8140 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8141 /* Line In pin: input */
8142 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8143 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8144
8145 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8146 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008147 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008148 /* Input mixer2 */
8149 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008150 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008151 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008152 /* ADC2: mute amp left and right */
8153 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8154 /* ADC3: mute amp left and right */
8155 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8156
8157 { }
8158};
8159
8160static struct hda_verb alc885_init_input_verbs[] = {
8161 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8162 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8163 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8164 { }
8165};
8166
8167
8168/* Unmute Selector 24h and set the default input to front mic */
8169static struct hda_verb alc889_init_input_verbs[] = {
8170 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8171 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8172 { }
8173};
8174
8175
Takashi Iwai4953550a2009-06-30 15:28:30 +02008176#define alc883_init_verbs alc882_base_init_verbs
8177
Tobin Davis9102cd12006-12-15 10:02:12 +01008178/* Mac Pro test */
8179static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8180 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8181 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8182 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8183 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8184 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008185 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008186 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8187 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008188 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008189 { } /* end */
8190};
8191
8192static struct hda_verb alc882_macpro_init_verbs[] = {
8193 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8194 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8195 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8196 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8197 /* Front Pin: output 0 (0x0c) */
8198 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8199 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8200 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8201 /* Front Mic pin: input vref at 80% */
8202 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8203 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8204 /* Speaker: output */
8205 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8206 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8207 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8208 /* Headphone output (output 0 - 0x0c) */
8209 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8210 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8211 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8212
8213 /* FIXME: use matrix-type input source selection */
8214 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8215 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8216 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8217 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8218 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8219 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8220 /* Input mixer2 */
8221 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8222 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8223 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8224 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8225 /* Input mixer3 */
8226 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8227 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8228 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8229 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8230 /* ADC1: mute amp left and right */
8231 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8232 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8233 /* ADC2: mute amp left and right */
8234 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8235 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8236 /* ADC3: mute amp left and right */
8237 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8238 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8239
8240 { }
8241};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008242
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008243/* Macbook 5,1 */
8244static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008245 /* DACs */
8246 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8247 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8248 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8249 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008250 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008251 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8252 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8253 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008254 /* Surround mixer */
8255 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8256 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8257 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8258 /* LFE mixer */
8259 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8260 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8261 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8262 /* HP mixer */
8263 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8264 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8265 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8266 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008267 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8268 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008269 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8270 /* LFE Pin (0x0e) */
8271 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8272 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8273 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8274 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008275 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8276 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008277 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308278 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008279 /* Front Mic pin: input vref at 80% */
8280 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8281 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8282 /* Line In pin */
8283 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8284 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8285
Alex Murrayb8f171e2010-06-14 12:08:43 +09308286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8287 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8288 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008289 { }
8290};
8291
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008292/* Macmini 3,1 */
8293static struct hda_verb alc885_macmini3_init_verbs[] = {
8294 /* DACs */
8295 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8296 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8297 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8298 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8299 /* Front mixer */
8300 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8301 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8302 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8303 /* Surround mixer */
8304 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8305 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8306 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8307 /* LFE mixer */
8308 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8309 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8310 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8311 /* HP mixer */
8312 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8313 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8314 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8315 /* Front Pin (0x0c) */
8316 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8317 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8318 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8319 /* LFE Pin (0x0e) */
8320 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8321 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8322 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8323 /* HP Pin (0x0f) */
8324 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8325 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8326 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8327 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8328 /* Line In pin */
8329 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8330 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8331
8332 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8333 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8334 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8335 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8336 { }
8337};
8338
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008339
8340static struct hda_verb alc885_mba21_init_verbs[] = {
8341 /*Internal and HP Speaker Mixer*/
8342 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8343 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8344 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8345 /*Internal Speaker Pin (0x0c)*/
8346 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8347 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8348 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8349 /* HP Pin: output 0 (0x0e) */
8350 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8351 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8352 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8353 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8354 /* Line in (is hp when jack connected)*/
8355 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8356 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8357
8358 { }
8359 };
8360
8361
Takashi Iwai87350ad2007-08-16 18:19:38 +02008362/* Macbook Pro rev3 */
8363static struct hda_verb alc885_mbp3_init_verbs[] = {
8364 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8365 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8366 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8367 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8368 /* Rear mixer */
8369 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8370 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8371 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008372 /* HP mixer */
8373 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8374 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8375 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008376 /* Front Pin: output 0 (0x0c) */
8377 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8378 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8379 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008380 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008381 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008382 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8383 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008384 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8385 /* Mic (rear) pin: input vref at 80% */
8386 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8387 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8388 /* Front Mic pin: input vref at 80% */
8389 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8390 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8391 /* Line In pin: use output 1 when in LineOut mode */
8392 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8393 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8394 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8395
8396 /* FIXME: use matrix-type input source selection */
8397 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8398 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8399 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8400 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8401 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8402 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8403 /* Input mixer2 */
8404 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8405 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8406 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8407 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8408 /* Input mixer3 */
8409 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8410 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8411 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8412 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8413 /* ADC1: mute amp left and right */
8414 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8415 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8416 /* ADC2: mute amp left and right */
8417 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8418 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8419 /* ADC3: mute amp left and right */
8420 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8421 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8422
8423 { }
8424};
8425
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008426/* iMac 9,1 */
8427static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008428 /* Internal Speaker Pin (0x0c) */
8429 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8430 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8431 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8432 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8433 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8434 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8435 /* HP Pin: Rear */
8436 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8437 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8438 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8439 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8440 /* Line in Rear */
8441 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8442 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8443 /* Front Mic pin: input vref at 80% */
8444 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8445 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008446 /* Rear mixer */
8447 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8448 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8449 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008450 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8451 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8452 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8453 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8454 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008455 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8456 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8457 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8458 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008459 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008460 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8461 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8462 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8463 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008464 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008465 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8466 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8467 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8468 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008469 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008470 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8471 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008472 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008473 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8474 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008475 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008476 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8477 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008478 { }
8479};
8480
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008481/* iMac 24 mixer. */
8482static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8483 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8484 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8485 { } /* end */
8486};
8487
8488/* iMac 24 init verbs. */
8489static struct hda_verb alc885_imac24_init_verbs[] = {
8490 /* Internal speakers: output 0 (0x0c) */
8491 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8492 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8493 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8494 /* Internal speakers: output 0 (0x0c) */
8495 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8496 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8497 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8498 /* Headphone: output 0 (0x0c) */
8499 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8500 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8501 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8502 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8503 /* Front Mic: input vref at 80% */
8504 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8505 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8506 { }
8507};
8508
8509/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008510static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008511{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008512 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008513
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008514 spec->autocfg.hp_pins[0] = 0x14;
8515 spec->autocfg.speaker_pins[0] = 0x18;
8516 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008517}
8518
Takashi Iwai9d54f082010-02-22 08:34:40 +01008519#define alc885_mb5_setup alc885_imac24_setup
8520#define alc885_macmini3_setup alc885_imac24_setup
8521
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008522/* Macbook Air 2,1 */
8523static void alc885_mba21_setup(struct hda_codec *codec)
8524{
8525 struct alc_spec *spec = codec->spec;
8526
8527 spec->autocfg.hp_pins[0] = 0x14;
8528 spec->autocfg.speaker_pins[0] = 0x18;
8529}
8530
8531
8532
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008533static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008534{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008535 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008536
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008537 spec->autocfg.hp_pins[0] = 0x15;
8538 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008539}
8540
Takashi Iwai9d54f082010-02-22 08:34:40 +01008541static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308542{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008543 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308544
Takashi Iwai9d54f082010-02-22 08:34:40 +01008545 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008546 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008547 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008548}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008549
Kailang Yang272a5272007-05-14 11:00:38 +02008550static struct hda_verb alc882_targa_verbs[] = {
8551 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8552 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8553
8554 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8555 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008556
Kailang Yang272a5272007-05-14 11:00:38 +02008557 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8558 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8559 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8560
8561 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008562 { } /* end */
8563};
8564
8565/* toggle speaker-output according to the hp-jack state */
8566static void alc882_targa_automute(struct hda_codec *codec)
8567{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008568 struct alc_spec *spec = codec->spec;
8569 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008570 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008571 spec->jack_present ? 1 : 3);
8572}
8573
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008574static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008575{
8576 struct alc_spec *spec = codec->spec;
8577
8578 spec->autocfg.hp_pins[0] = 0x14;
8579 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008580}
8581
8582static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8583{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008584 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008585 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008586}
8587
8588static struct hda_verb alc882_asus_a7j_verbs[] = {
8589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8590 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8591
8592 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8593 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8594 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008595
Kailang Yang272a5272007-05-14 11:00:38 +02008596 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8597 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8598 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8599
8600 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8601 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8602 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8603 { } /* end */
8604};
8605
Takashi Iwai914759b2007-09-06 14:52:04 +02008606static struct hda_verb alc882_asus_a7m_verbs[] = {
8607 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8608 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8609
8610 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8611 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8612 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008613
Takashi Iwai914759b2007-09-06 14:52:04 +02008614 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8615 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8616 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8617
8618 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8619 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8620 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8621 { } /* end */
8622};
8623
Tobin Davis9102cd12006-12-15 10:02:12 +01008624static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8625{
8626 unsigned int gpiostate, gpiomask, gpiodir;
8627
8628 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8629 AC_VERB_GET_GPIO_DATA, 0);
8630
8631 if (!muted)
8632 gpiostate |= (1 << pin);
8633 else
8634 gpiostate &= ~(1 << pin);
8635
8636 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8637 AC_VERB_GET_GPIO_MASK, 0);
8638 gpiomask |= (1 << pin);
8639
8640 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8641 AC_VERB_GET_GPIO_DIRECTION, 0);
8642 gpiodir |= (1 << pin);
8643
8644
8645 snd_hda_codec_write(codec, codec->afg, 0,
8646 AC_VERB_SET_GPIO_MASK, gpiomask);
8647 snd_hda_codec_write(codec, codec->afg, 0,
8648 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8649
8650 msleep(1);
8651
8652 snd_hda_codec_write(codec, codec->afg, 0,
8653 AC_VERB_SET_GPIO_DATA, gpiostate);
8654}
8655
Takashi Iwai7debbe52007-08-16 15:01:03 +02008656/* set up GPIO at initialization */
8657static void alc885_macpro_init_hook(struct hda_codec *codec)
8658{
8659 alc882_gpio_mute(codec, 0, 0);
8660 alc882_gpio_mute(codec, 1, 0);
8661}
8662
8663/* set up GPIO and update auto-muting at initialization */
8664static void alc885_imac24_init_hook(struct hda_codec *codec)
8665{
8666 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008667 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008668}
8669
Kailang Yangdf694da2005-12-05 19:42:22 +01008670/*
8671 * generic initialization of ADC, input mixers and output mixers
8672 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008673static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008674 /*
8675 * Unmute ADC0-2 and set the default input to mic-in
8676 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008677 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8678 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8679 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8680 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8681
Kailang Yangdf694da2005-12-05 19:42:22 +01008682 /*
8683 * Set up output mixers (0x0c - 0x0f)
8684 */
8685 /* set vol=0 to output mixers */
8686 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8687 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8688 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8689 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8690 /* set up input amps for analog loopback */
8691 /* Amp Indices: DAC = 0, mixer = 1 */
8692 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8693 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8694 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8695 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8696 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8697 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8698 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8699 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8700 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8701 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8702
8703 /* FIXME: use matrix-type input source selection */
8704 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008705 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008706 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008707 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008708 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008709 { }
8710};
8711
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008712/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8713static struct hda_verb alc889A_mb31_ch2_init[] = {
8714 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8715 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8716 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8717 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8718 { } /* end */
8719};
8720
8721/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8722static struct hda_verb alc889A_mb31_ch4_init[] = {
8723 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8724 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8725 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8726 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8727 { } /* end */
8728};
8729
8730/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8731static struct hda_verb alc889A_mb31_ch5_init[] = {
8732 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8733 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8734 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8735 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8736 { } /* end */
8737};
8738
8739/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8740static struct hda_verb alc889A_mb31_ch6_init[] = {
8741 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8742 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8743 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8744 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8745 { } /* end */
8746};
8747
8748static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8749 { 2, alc889A_mb31_ch2_init },
8750 { 4, alc889A_mb31_ch4_init },
8751 { 5, alc889A_mb31_ch5_init },
8752 { 6, alc889A_mb31_ch6_init },
8753};
8754
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008755static struct hda_verb alc883_medion_eapd_verbs[] = {
8756 /* eanable EAPD on medion laptop */
8757 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8758 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8759 { }
8760};
8761
Takashi Iwai4953550a2009-06-30 15:28:30 +02008762#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008763
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008764static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8765 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8766 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8767 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8768 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8769 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8770 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8771 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8772 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8773 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8774 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8775 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8776 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8777 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008778 { } /* end */
8779};
8780
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008781static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008782 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8783 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8784 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8785 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8786 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8787 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8788 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8789 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8790 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8791 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008792 { } /* end */
8793};
8794
Jiang zhefb97dc62008-03-06 11:07:11 +01008795static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8796 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8797 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8798 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8799 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8800 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8801 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8802 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8803 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8804 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8805 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008806 { } /* end */
8807};
8808
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008809static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8810 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8811 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8812 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8813 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8814 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8815 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8816 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8817 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008818 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008819 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8820 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008821 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008822 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008823 { } /* end */
8824};
8825
8826static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8827 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8828 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8829 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8830 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8831 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8832 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8833 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8834 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8835 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8836 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8837 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8838 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8839 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8840 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008841 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008842 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8843 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008844 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008845 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008846 { } /* end */
8847};
8848
Jiang zhe17bba1b2008-06-04 12:11:07 +02008849static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8850 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8851 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8852 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8853 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8854 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8855 HDA_OUTPUT),
8856 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8857 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8858 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8860 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8861 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8862 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8863 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8864 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8865 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8866 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8867 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8868 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8869 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008870 { } /* end */
8871};
8872
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008873static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8874 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8875 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8876 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8877 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8878 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8879 HDA_OUTPUT),
8880 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8881 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8882 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8883 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8884 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8885 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8886 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8887 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8888 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8889 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8890 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8891 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8892 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8893 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8894 { } /* end */
8895};
8896
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008897static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008898 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008899 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008900 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008901 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008902 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8903 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008904 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8905 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008906 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8907 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8908 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8909 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8910 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8911 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008912 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008913 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8914 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008915 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008916 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008917 { } /* end */
8918};
8919
Sasha Alexandrc2592492009-06-16 14:52:54 -04008920static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008921 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008922 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008923 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008924 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008925 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8926 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8927 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8928 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8929 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8930 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8932 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8933 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8934 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008936 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008937 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008938 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008939};
Kailang Yangccc656c2006-10-17 12:32:26 +02008940
Sasha Alexandrc2592492009-06-16 14:52:54 -04008941static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008942 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008943 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008944 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008945 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008946 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8947 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8948 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008949 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008950 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008951 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8952 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8953 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008954 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008955};
Kailang Yangccc656c2006-10-17 12:32:26 +02008956
Takashi Iwaib99dba32009-09-17 18:23:00 +02008957static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8958 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8959 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8960 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8961 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8962 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8963 { } /* end */
8964};
8965
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008966static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8967 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8968 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008969 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8970 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008971 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8972 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8973 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8974 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008975 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008976};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008977
Kailang Yang272a5272007-05-14 11:00:38 +02008978static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8979 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8980 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8981 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8982 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8983 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8984 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8985 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson150b4322010-07-29 14:46:42 +02008986 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8987 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008988 { } /* end */
8989};
8990
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02008991static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
8992 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8993 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8994 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8995 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
8996 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
8997 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
8998 { } /* end */
8999};
9000
9001static struct hda_verb alc883_medion_wim2160_verbs[] = {
9002 /* Unmute front mixer */
9003 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9004 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9005
9006 /* Set speaker pin to front mixer */
9007 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9008
9009 /* Init headphone pin */
9010 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9011 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9012 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9013 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9014
9015 { } /* end */
9016};
9017
9018/* toggle speaker-output according to the hp-jack state */
9019static void alc883_medion_wim2160_setup(struct hda_codec *codec)
9020{
9021 struct alc_spec *spec = codec->spec;
9022
9023 spec->autocfg.hp_pins[0] = 0x1a;
9024 spec->autocfg.speaker_pins[0] = 0x15;
9025}
9026
Tobin Davis2880a862007-08-07 11:50:26 +02009027static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009028 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9029 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009030 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009031 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9032 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009033 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9034 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9035 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009036 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009037};
Tobin Davis2880a862007-08-07 11:50:26 +02009038
Tony Vroond2fd4b02009-06-21 00:40:10 +01009039static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
9040 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009041 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009042 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9043 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009044 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9045 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9046 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9047 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9048 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9049 { } /* end */
9050};
9051
Kailang Yange2757d52008-08-26 13:17:46 +02009052static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
9053 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9054 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9055 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9056 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9057 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9058 0x0d, 1, 0x0, HDA_OUTPUT),
9059 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9060 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9061 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9062 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9063 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009064 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9065 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9066 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9067 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9068 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9069 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9070 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9071 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9072 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9073 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009074 { } /* end */
9075};
9076
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009077static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9078 /* Output mixers */
9079 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9080 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9081 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9082 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9083 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9084 HDA_OUTPUT),
9085 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9086 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9087 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9088 /* Output switches */
9089 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9090 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9091 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9092 /* Boost mixers */
9093 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
9094 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
9095 /* Input mixers */
9096 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9097 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9098 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9099 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9100 { } /* end */
9101};
9102
Guido Günther3e1647c2009-06-05 00:47:26 +02009103static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9104 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9105 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9106 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9107 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9108 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
9109 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9110 { } /* end */
9111};
9112
Kailang Yange2757d52008-08-26 13:17:46 +02009113static struct hda_bind_ctls alc883_bind_cap_vol = {
9114 .ops = &snd_hda_bind_vol,
9115 .values = {
9116 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9117 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9118 0
9119 },
9120};
9121
9122static struct hda_bind_ctls alc883_bind_cap_switch = {
9123 .ops = &snd_hda_bind_sw,
9124 .values = {
9125 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9126 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9127 0
9128 },
9129};
9130
9131static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9132 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9133 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9134 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9135 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9136 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9137 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9138 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9139 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009140 { } /* end */
9141};
9142
9143static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009144 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9145 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9146 {
9147 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9148 /* .name = "Capture Source", */
9149 .name = "Input Source",
9150 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009151 .info = alc_mux_enum_info,
9152 .get = alc_mux_enum_get,
9153 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009154 },
9155 { } /* end */
9156};
9157
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009158static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9159 {
9160 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9161 .name = "Channel Mode",
9162 .info = alc_ch_mode_info,
9163 .get = alc_ch_mode_get,
9164 .put = alc_ch_mode_put,
9165 },
9166 { } /* end */
9167};
9168
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009169/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009170static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009171{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009172 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009173
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009174 spec->autocfg.hp_pins[0] = 0x15;
9175 spec->autocfg.speaker_pins[0] = 0x14;
9176 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009177}
9178
9179/* auto-toggle front mic */
9180/*
9181static void alc883_mitac_mic_automute(struct hda_codec *codec)
9182{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009183 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009184
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009185 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
9186}
9187*/
9188
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009189static struct hda_verb alc883_mitac_verbs[] = {
9190 /* HP */
9191 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9192 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9193 /* Subwoofer */
9194 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9195 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9196
9197 /* enable unsolicited event */
9198 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9199 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9200
9201 { } /* end */
9202};
9203
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309204static struct hda_verb alc883_clevo_m540r_verbs[] = {
9205 /* HP */
9206 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9207 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9208 /* Int speaker */
9209 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9210
9211 /* enable unsolicited event */
9212 /*
9213 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9214 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9215 */
9216
9217 { } /* end */
9218};
9219
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009220static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009221 /* HP */
9222 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9223 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9224 /* Int speaker */
9225 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9226 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9227
9228 /* enable unsolicited event */
9229 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009230 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009231
9232 { } /* end */
9233};
9234
Jiang zhefb97dc62008-03-06 11:07:11 +01009235static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9236 /* HP */
9237 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9238 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9239 /* Subwoofer */
9240 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9241 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9242
9243 /* enable unsolicited event */
9244 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9245
9246 { } /* end */
9247};
9248
Sasha Alexandrc2592492009-06-16 14:52:54 -04009249static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009250 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9251 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9252
9253 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9254 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009255
David Heidelberger64a8be72009-06-08 16:15:18 +02009256/* Connect Line-Out side jack (SPDIF) to Side */
9257 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9258 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9259 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9260/* Connect Mic jack to CLFE */
9261 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9262 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9263 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9264/* Connect Line-in jack to Surround */
9265 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9266 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9267 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9268/* Connect HP out jack to Front */
9269 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9270 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9271 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009272
9273 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009274
9275 { } /* end */
9276};
9277
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009278static struct hda_verb alc883_lenovo_101e_verbs[] = {
9279 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9280 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9281 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9282 { } /* end */
9283};
9284
Kailang Yang272a5272007-05-14 11:00:38 +02009285static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9286 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9287 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9288 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9289 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9290 { } /* end */
9291};
9292
9293static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9294 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9295 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9296 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9297 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9298 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9299 { } /* end */
9300};
9301
Kailang Yang189609a2007-08-20 11:31:23 +02009302static struct hda_verb alc883_haier_w66_verbs[] = {
9303 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9304 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9305
9306 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9307
9308 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9309 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9310 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9311 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9312 { } /* end */
9313};
9314
Kailang Yange2757d52008-08-26 13:17:46 +02009315static struct hda_verb alc888_lenovo_sky_verbs[] = {
9316 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9317 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9318 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9319 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9320 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9321 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9322 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9323 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9324 { } /* end */
9325};
9326
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009327static struct hda_verb alc888_6st_dell_verbs[] = {
9328 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9329 { }
9330};
9331
Guido Günther3e1647c2009-06-05 00:47:26 +02009332static struct hda_verb alc883_vaiott_verbs[] = {
9333 /* HP */
9334 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9335 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9336
9337 /* enable unsolicited event */
9338 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9339
9340 { } /* end */
9341};
9342
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009343static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009344{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009345 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009346
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009347 spec->autocfg.hp_pins[0] = 0x1b;
9348 spec->autocfg.speaker_pins[0] = 0x14;
9349 spec->autocfg.speaker_pins[1] = 0x16;
9350 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009351}
9352
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009353static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009354 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009355 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9356 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009357 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009358 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009359};
9360
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009361/*
9362 * 2ch mode
9363 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009364static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009365 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9366 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9367 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9368 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009369 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009370};
9371
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009372/*
9373 * 4ch mode
9374 */
9375static struct hda_verb alc888_3st_hp_4ch_init[] = {
9376 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9377 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9378 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9379 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9380 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9381 { } /* end */
9382};
9383
9384/*
9385 * 6ch mode
9386 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009387static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009388 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9389 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009390 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009391 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9392 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009393 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9394 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009395};
9396
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009397static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009398 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009399 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009400 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009401};
9402
Kailang Yang272a5272007-05-14 11:00:38 +02009403/* toggle front-jack and RCA according to the hp-jack state */
9404static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9405{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009406 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009407
Takashi Iwai47fd8302007-08-10 17:11:07 +02009408 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9409 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9410 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9411 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009412}
9413
9414/* toggle RCA according to the front-jack state */
9415static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9416{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009417 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009418
Takashi Iwai47fd8302007-08-10 17:11:07 +02009419 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9420 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009421}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009422
Kailang Yang272a5272007-05-14 11:00:38 +02009423static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9424 unsigned int res)
9425{
9426 if ((res >> 26) == ALC880_HP_EVENT)
9427 alc888_lenovo_ms7195_front_automute(codec);
9428 if ((res >> 26) == ALC880_FRONT_EVENT)
9429 alc888_lenovo_ms7195_rca_automute(codec);
9430}
9431
Kailang Yang272a5272007-05-14 11:00:38 +02009432/* toggle speaker-output according to the hp-jack state */
Takashi Iwaidc4271702010-11-29 07:42:59 +01009433static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009434{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009435 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009436
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009437 spec->autocfg.hp_pins[0] = 0x14;
9438 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009439}
9440
Kailang Yangccc656c2006-10-17 12:32:26 +02009441/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009442#define alc883_targa_init_hook alc882_targa_init_hook
9443#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009444
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009445static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
9446{
9447 unsigned int present;
9448
Takashi Iwaid56757a2009-11-18 08:00:14 +01009449 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009450 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
9451 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9452}
9453
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009454static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009455{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009456 struct alc_spec *spec = codec->spec;
9457
9458 spec->autocfg.hp_pins[0] = 0x15;
9459 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009460}
9461
9462static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9463{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009464 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009465 alc883_clevo_m720_mic_automute(codec);
9466}
9467
9468static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009469 unsigned int res)
9470{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009471 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009472 case ALC880_MIC_EVENT:
9473 alc883_clevo_m720_mic_automute(codec);
9474 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009475 default:
9476 alc_automute_amp_unsol_event(codec, res);
9477 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009478 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009479}
9480
Jiang zhefb97dc62008-03-06 11:07:11 +01009481/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009482static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009483{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009484 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009485
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009486 spec->autocfg.hp_pins[0] = 0x14;
9487 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009488}
9489
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009490static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009491{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009492 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009493
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009494 spec->autocfg.hp_pins[0] = 0x1b;
9495 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009496}
9497
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009498static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9499{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009500 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009501
Takashi Iwai47fd8302007-08-10 17:11:07 +02009502 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9503 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009504}
9505
9506static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9507{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009508 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009509
Takashi Iwai47fd8302007-08-10 17:11:07 +02009510 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9511 HDA_AMP_MUTE, bits);
9512 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9513 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009514}
9515
9516static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9517 unsigned int res)
9518{
9519 if ((res >> 26) == ALC880_HP_EVENT)
9520 alc883_lenovo_101e_all_automute(codec);
9521 if ((res >> 26) == ALC880_FRONT_EVENT)
9522 alc883_lenovo_101e_ispeaker_automute(codec);
9523}
9524
Takashi Iwai676a9b52007-08-16 15:23:35 +02009525/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009526static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009527{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009528 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009529
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009530 spec->autocfg.hp_pins[0] = 0x14;
9531 spec->autocfg.speaker_pins[0] = 0x15;
9532 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009533}
9534
Kailang Yangd1a991a2007-08-15 16:21:59 +02009535static struct hda_verb alc883_acer_eapd_verbs[] = {
9536 /* HP Pin: output 0 (0x0c) */
9537 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9538 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9539 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9540 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009541 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9542 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009543 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009544 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9545 /* eanable EAPD on medion laptop */
9546 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9547 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009548 /* enable unsolicited event */
9549 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009550 { }
9551};
9552
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009553static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009554{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009555 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009556
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009557 spec->autocfg.hp_pins[0] = 0x1b;
9558 spec->autocfg.speaker_pins[0] = 0x14;
9559 spec->autocfg.speaker_pins[1] = 0x15;
9560 spec->autocfg.speaker_pins[2] = 0x16;
9561 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009562}
9563
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009564static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009565{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009566 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009567
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009568 spec->autocfg.hp_pins[0] = 0x1b;
9569 spec->autocfg.speaker_pins[0] = 0x14;
9570 spec->autocfg.speaker_pins[1] = 0x15;
9571 spec->autocfg.speaker_pins[2] = 0x16;
9572 spec->autocfg.speaker_pins[3] = 0x17;
9573 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009574}
9575
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009576static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009577{
9578 struct alc_spec *spec = codec->spec;
9579
9580 spec->autocfg.hp_pins[0] = 0x15;
9581 spec->autocfg.speaker_pins[0] = 0x14;
9582 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009583}
9584
Kailang Yange2757d52008-08-26 13:17:46 +02009585static struct hda_verb alc888_asus_m90v_verbs[] = {
9586 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9587 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9588 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9589 /* enable unsolicited event */
9590 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9591 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9592 { } /* end */
9593};
9594
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009595static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009596{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009597 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009598
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009599 spec->autocfg.hp_pins[0] = 0x1b;
9600 spec->autocfg.speaker_pins[0] = 0x14;
9601 spec->autocfg.speaker_pins[1] = 0x15;
9602 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009603 spec->ext_mic.pin = 0x18;
9604 spec->int_mic.pin = 0x19;
9605 spec->ext_mic.mux_idx = 0;
9606 spec->int_mic.mux_idx = 1;
9607 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009608}
9609
9610static struct hda_verb alc888_asus_eee1601_verbs[] = {
9611 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9612 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9613 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9614 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9615 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9616 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9617 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9618 /* enable unsolicited event */
9619 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9620 { } /* end */
9621};
9622
Kailang Yange2757d52008-08-26 13:17:46 +02009623static void alc883_eee1601_inithook(struct hda_codec *codec)
9624{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009625 struct alc_spec *spec = codec->spec;
9626
9627 spec->autocfg.hp_pins[0] = 0x14;
9628 spec->autocfg.speaker_pins[0] = 0x1b;
9629 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009630}
9631
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009632static struct hda_verb alc889A_mb31_verbs[] = {
9633 /* Init rear pin (used as headphone output) */
9634 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9635 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9636 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9637 /* Init line pin (used as output in 4ch and 6ch mode) */
9638 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9639 /* Init line 2 pin (used as headphone out by default) */
9640 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9641 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9642 { } /* end */
9643};
9644
9645/* Mute speakers according to the headphone jack state */
9646static void alc889A_mb31_automute(struct hda_codec *codec)
9647{
9648 unsigned int present;
9649
9650 /* Mute only in 2ch or 4ch mode */
9651 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9652 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009653 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009654 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9655 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9656 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9657 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9658 }
9659}
9660
9661static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9662{
9663 if ((res >> 26) == ALC880_HP_EVENT)
9664 alc889A_mb31_automute(codec);
9665}
9666
Takashi Iwai4953550a2009-06-30 15:28:30 +02009667
Takashi Iwaicb53c622007-08-10 17:21:45 +02009668#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009669#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009670#endif
9671
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009672/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009673#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9674#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9675#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9676#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9677
9678static hda_nid_t alc883_slave_dig_outs[] = {
9679 ALC1200_DIGOUT_NID, 0,
9680};
9681
9682static hda_nid_t alc1200_slave_dig_outs[] = {
9683 ALC883_DIGOUT_NID, 0,
9684};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009685
9686/*
9687 * configuration and preset
9688 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009689static const char *alc882_models[ALC882_MODEL_LAST] = {
9690 [ALC882_3ST_DIG] = "3stack-dig",
9691 [ALC882_6ST_DIG] = "6stack-dig",
9692 [ALC882_ARIMA] = "arima",
9693 [ALC882_W2JC] = "w2jc",
9694 [ALC882_TARGA] = "targa",
9695 [ALC882_ASUS_A7J] = "asus-a7j",
9696 [ALC882_ASUS_A7M] = "asus-a7m",
9697 [ALC885_MACPRO] = "macpro",
9698 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009699 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009700 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009701 [ALC885_MBP3] = "mbp3",
9702 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009703 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009704 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009705 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9706 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009707 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009708 [ALC883_TARGA_DIG] = "targa-dig",
9709 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009710 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009711 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009712 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009713 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009714 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009715 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009716 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009717 [ALC883_MEDION] = "medion",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009718 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009719 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009720 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009721 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9722 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009723 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009724 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009725 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009726 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009727 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309728 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009729 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009730 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009731 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009732 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009733 [ALC889A_INTEL] = "intel-alc889a",
9734 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009735 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009736 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009737 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009738 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009739};
9740
Takashi Iwai4953550a2009-06-30 15:28:30 +02009741static struct snd_pci_quirk alc882_cfg_tbl[] = {
9742 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9743
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009744 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009745 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009746 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009747 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9748 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009749 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009750 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9751 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009752 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009753 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009754 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9755 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009756 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9757 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009758 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9759 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009760 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009761 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009762 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009763 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009764 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9765 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009766 /* default Acer -- disabled as it causes more problems.
9767 * model=auto should work fine now
9768 */
9769 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009770
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009771 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009772
Tobin Davisfebe3372007-06-12 11:27:46 +02009773 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009774 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9775 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009776 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009777 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009778 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009779
9780 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9781 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9782 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009783 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009784 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9785 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9786 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009787 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009788 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009789 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009790 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009791
9792 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009793 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009794 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009795 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009796 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9797 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009798 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009799 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009800 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9801
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009802 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9803 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9804 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009805 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009806 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009807 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009808 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009809 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009810 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9811 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9812 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9813 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9814 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9815 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009816 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009817 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9818 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9819 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009820 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009821 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009822 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9823 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009824 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009825 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009826 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009827 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009828 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009829 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009830 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009831 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009832 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009833
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009834 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009835 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009836 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9837 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309838 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009839 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009840 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009841 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009842 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009843 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009844 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009845 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009846 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009847 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009848 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009849 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9850 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009851 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Takashi Iwai959973b2008-11-05 11:30:56 +01009852 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009853 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009854 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009855
Jiang zhe17bba1b2008-06-04 12:11:07 +02009856 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9857 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009858 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009859 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9860 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9861 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009862 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009863
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009864 {}
9865};
9866
Takashi Iwai4953550a2009-06-30 15:28:30 +02009867/* codec SSID table for Intel Mac */
9868static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9869 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9870 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9871 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9872 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9873 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9874 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9875 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009876 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009877 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009878 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009879 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009880 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9881 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9882 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009883 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009884 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009885 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009886 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9887 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009888 */
9889 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009890 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009891 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009892 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009893};
9894
Takashi Iwai4953550a2009-06-30 15:28:30 +02009895static struct alc_config_preset alc882_presets[] = {
9896 [ALC882_3ST_DIG] = {
9897 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009898 .init_verbs = { alc882_base_init_verbs,
9899 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009900 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9901 .dac_nids = alc882_dac_nids,
9902 .dig_out_nid = ALC882_DIGOUT_NID,
9903 .dig_in_nid = ALC882_DIGIN_NID,
9904 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9905 .channel_mode = alc882_ch_modes,
9906 .need_dac_fix = 1,
9907 .input_mux = &alc882_capture_source,
9908 },
9909 [ALC882_6ST_DIG] = {
9910 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009911 .init_verbs = { alc882_base_init_verbs,
9912 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009913 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9914 .dac_nids = alc882_dac_nids,
9915 .dig_out_nid = ALC882_DIGOUT_NID,
9916 .dig_in_nid = ALC882_DIGIN_NID,
9917 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9918 .channel_mode = alc882_sixstack_modes,
9919 .input_mux = &alc882_capture_source,
9920 },
9921 [ALC882_ARIMA] = {
9922 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009923 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9924 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009925 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9926 .dac_nids = alc882_dac_nids,
9927 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9928 .channel_mode = alc882_sixstack_modes,
9929 .input_mux = &alc882_capture_source,
9930 },
9931 [ALC882_W2JC] = {
9932 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009933 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9934 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009935 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9936 .dac_nids = alc882_dac_nids,
9937 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9938 .channel_mode = alc880_threestack_modes,
9939 .need_dac_fix = 1,
9940 .input_mux = &alc882_capture_source,
9941 .dig_out_nid = ALC882_DIGOUT_NID,
9942 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009943 [ALC885_MBA21] = {
9944 .mixers = { alc885_mba21_mixer },
9945 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9946 .num_dacs = 2,
9947 .dac_nids = alc882_dac_nids,
9948 .channel_mode = alc885_mba21_ch_modes,
9949 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9950 .input_mux = &alc882_capture_source,
9951 .unsol_event = alc_automute_amp_unsol_event,
9952 .setup = alc885_mba21_setup,
9953 .init_hook = alc_automute_amp,
9954 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009955 [ALC885_MBP3] = {
9956 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9957 .init_verbs = { alc885_mbp3_init_verbs,
9958 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009959 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009960 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009961 .hp_nid = 0x04,
9962 .channel_mode = alc885_mbp_4ch_modes,
9963 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009964 .input_mux = &alc882_capture_source,
9965 .dig_out_nid = ALC882_DIGOUT_NID,
9966 .dig_in_nid = ALC882_DIGIN_NID,
9967 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009968 .setup = alc885_mbp3_setup,
9969 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009970 },
9971 [ALC885_MB5] = {
9972 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9973 .init_verbs = { alc885_mb5_init_verbs,
9974 alc880_gpio1_init_verbs },
9975 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9976 .dac_nids = alc882_dac_nids,
9977 .channel_mode = alc885_mb5_6ch_modes,
9978 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9979 .input_mux = &mb5_capture_source,
9980 .dig_out_nid = ALC882_DIGOUT_NID,
9981 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009982 .unsol_event = alc_automute_amp_unsol_event,
9983 .setup = alc885_mb5_setup,
9984 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009985 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009986 [ALC885_MACMINI3] = {
9987 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9988 .init_verbs = { alc885_macmini3_init_verbs,
9989 alc880_gpio1_init_verbs },
9990 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9991 .dac_nids = alc882_dac_nids,
9992 .channel_mode = alc885_macmini3_6ch_modes,
9993 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9994 .input_mux = &macmini3_capture_source,
9995 .dig_out_nid = ALC882_DIGOUT_NID,
9996 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009997 .unsol_event = alc_automute_amp_unsol_event,
9998 .setup = alc885_macmini3_setup,
9999 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010000 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010001 [ALC885_MACPRO] = {
10002 .mixers = { alc882_macpro_mixer },
10003 .init_verbs = { alc882_macpro_init_verbs },
10004 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10005 .dac_nids = alc882_dac_nids,
10006 .dig_out_nid = ALC882_DIGOUT_NID,
10007 .dig_in_nid = ALC882_DIGIN_NID,
10008 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10009 .channel_mode = alc882_ch_modes,
10010 .input_mux = &alc882_capture_source,
10011 .init_hook = alc885_macpro_init_hook,
10012 },
10013 [ALC885_IMAC24] = {
10014 .mixers = { alc885_imac24_mixer },
10015 .init_verbs = { alc885_imac24_init_verbs },
10016 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10017 .dac_nids = alc882_dac_nids,
10018 .dig_out_nid = ALC882_DIGOUT_NID,
10019 .dig_in_nid = ALC882_DIGIN_NID,
10020 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10021 .channel_mode = alc882_ch_modes,
10022 .input_mux = &alc882_capture_source,
10023 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010024 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010025 .init_hook = alc885_imac24_init_hook,
10026 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010027 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010028 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010029 .init_verbs = { alc885_imac91_init_verbs,
10030 alc880_gpio1_init_verbs },
10031 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10032 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010033 .channel_mode = alc885_mba21_ch_modes,
10034 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10035 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010036 .dig_out_nid = ALC882_DIGOUT_NID,
10037 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010038 .unsol_event = alc_automute_amp_unsol_event,
10039 .setup = alc885_imac91_setup,
10040 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010041 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010042 [ALC882_TARGA] = {
10043 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010044 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010045 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010046 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10047 .dac_nids = alc882_dac_nids,
10048 .dig_out_nid = ALC882_DIGOUT_NID,
10049 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10050 .adc_nids = alc882_adc_nids,
10051 .capsrc_nids = alc882_capsrc_nids,
10052 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10053 .channel_mode = alc882_3ST_6ch_modes,
10054 .need_dac_fix = 1,
10055 .input_mux = &alc882_capture_source,
10056 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010057 .setup = alc882_targa_setup,
10058 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010059 },
10060 [ALC882_ASUS_A7J] = {
10061 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010062 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10063 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010064 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10065 .dac_nids = alc882_dac_nids,
10066 .dig_out_nid = ALC882_DIGOUT_NID,
10067 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10068 .adc_nids = alc882_adc_nids,
10069 .capsrc_nids = alc882_capsrc_nids,
10070 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10071 .channel_mode = alc882_3ST_6ch_modes,
10072 .need_dac_fix = 1,
10073 .input_mux = &alc882_capture_source,
10074 },
10075 [ALC882_ASUS_A7M] = {
10076 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010077 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10078 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010079 alc882_asus_a7m_verbs },
10080 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10081 .dac_nids = alc882_dac_nids,
10082 .dig_out_nid = ALC882_DIGOUT_NID,
10083 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10084 .channel_mode = alc880_threestack_modes,
10085 .need_dac_fix = 1,
10086 .input_mux = &alc882_capture_source,
10087 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010088 [ALC883_3ST_2ch_DIG] = {
10089 .mixers = { alc883_3ST_2ch_mixer },
10090 .init_verbs = { alc883_init_verbs },
10091 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10092 .dac_nids = alc883_dac_nids,
10093 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010094 .dig_in_nid = ALC883_DIGIN_NID,
10095 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10096 .channel_mode = alc883_3ST_2ch_modes,
10097 .input_mux = &alc883_capture_source,
10098 },
10099 [ALC883_3ST_6ch_DIG] = {
10100 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10101 .init_verbs = { alc883_init_verbs },
10102 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10103 .dac_nids = alc883_dac_nids,
10104 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010105 .dig_in_nid = ALC883_DIGIN_NID,
10106 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10107 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010108 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010109 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010110 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010111 [ALC883_3ST_6ch] = {
10112 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10113 .init_verbs = { alc883_init_verbs },
10114 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10115 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010116 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10117 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010118 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010119 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010120 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010121 [ALC883_3ST_6ch_INTEL] = {
10122 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10123 .init_verbs = { alc883_init_verbs },
10124 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10125 .dac_nids = alc883_dac_nids,
10126 .dig_out_nid = ALC883_DIGOUT_NID,
10127 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010128 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010129 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10130 .channel_mode = alc883_3ST_6ch_intel_modes,
10131 .need_dac_fix = 1,
10132 .input_mux = &alc883_3stack_6ch_intel,
10133 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010134 [ALC889A_INTEL] = {
10135 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010136 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10137 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010138 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10139 .dac_nids = alc883_dac_nids,
10140 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10141 .adc_nids = alc889_adc_nids,
10142 .dig_out_nid = ALC883_DIGOUT_NID,
10143 .dig_in_nid = ALC883_DIGIN_NID,
10144 .slave_dig_outs = alc883_slave_dig_outs,
10145 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10146 .channel_mode = alc889_8ch_intel_modes,
10147 .capsrc_nids = alc889_capsrc_nids,
10148 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010149 .setup = alc889_automute_setup,
10150 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010151 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010152 .need_dac_fix = 1,
10153 },
10154 [ALC889_INTEL] = {
10155 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10156 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010157 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010158 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10159 .dac_nids = alc883_dac_nids,
10160 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10161 .adc_nids = alc889_adc_nids,
10162 .dig_out_nid = ALC883_DIGOUT_NID,
10163 .dig_in_nid = ALC883_DIGIN_NID,
10164 .slave_dig_outs = alc883_slave_dig_outs,
10165 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10166 .channel_mode = alc889_8ch_intel_modes,
10167 .capsrc_nids = alc889_capsrc_nids,
10168 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010169 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010170 .init_hook = alc889_intel_init_hook,
10171 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010172 .need_dac_fix = 1,
10173 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010174 [ALC883_6ST_DIG] = {
10175 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10176 .init_verbs = { alc883_init_verbs },
10177 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10178 .dac_nids = alc883_dac_nids,
10179 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010180 .dig_in_nid = ALC883_DIGIN_NID,
10181 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10182 .channel_mode = alc883_sixstack_modes,
10183 .input_mux = &alc883_capture_source,
10184 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010185 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010186 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010187 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10188 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010189 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10190 .dac_nids = alc883_dac_nids,
10191 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010192 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10193 .channel_mode = alc883_3ST_6ch_modes,
10194 .need_dac_fix = 1,
10195 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010196 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010197 .setup = alc882_targa_setup,
10198 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010199 },
10200 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010201 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010202 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10203 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010204 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10205 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010206 .adc_nids = alc883_adc_nids_alt,
10207 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010208 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010209 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010210 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10211 .channel_mode = alc883_3ST_2ch_modes,
10212 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010213 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010214 .setup = alc882_targa_setup,
10215 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010216 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010217 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010218 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10219 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010220 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010221 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010222 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10223 .dac_nids = alc883_dac_nids,
10224 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10225 .adc_nids = alc883_adc_nids_rev,
10226 .capsrc_nids = alc883_capsrc_nids_rev,
10227 .dig_out_nid = ALC883_DIGOUT_NID,
10228 .dig_in_nid = ALC883_DIGIN_NID,
10229 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10230 .channel_mode = alc883_4ST_8ch_modes,
10231 .need_dac_fix = 1,
10232 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010233 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010234 .setup = alc882_targa_setup,
10235 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010236 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010237 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010238 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010239 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10240 * and the headphone jack. Turn this on and rely on the
10241 * standard mute methods whenever the user wants to turn
10242 * these outputs off.
10243 */
10244 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10245 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10246 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010247 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10248 .channel_mode = alc883_3ST_2ch_modes,
10249 .input_mux = &alc883_capture_source,
10250 },
Tobin Davis2880a862007-08-07 11:50:26 +020010251 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010252 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010253 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010254 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10255 .dac_nids = alc883_dac_nids,
10256 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010257 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10258 .channel_mode = alc883_3ST_2ch_modes,
10259 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010260 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010261 .setup = alc883_acer_aspire_setup,
10262 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010263 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010264 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010265 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010266 alc883_chmode_mixer },
10267 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10268 alc888_acer_aspire_4930g_verbs },
10269 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10270 .dac_nids = alc883_dac_nids,
10271 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10272 .adc_nids = alc883_adc_nids_rev,
10273 .capsrc_nids = alc883_capsrc_nids_rev,
10274 .dig_out_nid = ALC883_DIGOUT_NID,
10275 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10276 .channel_mode = alc883_3ST_6ch_modes,
10277 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010278 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010279 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010280 ARRAY_SIZE(alc888_2_capture_sources),
10281 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010282 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010283 .setup = alc888_acer_aspire_4930g_setup,
10284 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010285 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010286 [ALC888_ACER_ASPIRE_6530G] = {
10287 .mixers = { alc888_acer_aspire_6530_mixer },
10288 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10289 alc888_acer_aspire_6530g_verbs },
10290 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10291 .dac_nids = alc883_dac_nids,
10292 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10293 .adc_nids = alc883_adc_nids_rev,
10294 .capsrc_nids = alc883_capsrc_nids_rev,
10295 .dig_out_nid = ALC883_DIGOUT_NID,
10296 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10297 .channel_mode = alc883_3ST_2ch_modes,
10298 .num_mux_defs =
10299 ARRAY_SIZE(alc888_2_capture_sources),
10300 .input_mux = alc888_acer_aspire_6530_sources,
10301 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010302 .setup = alc888_acer_aspire_6530g_setup,
10303 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010304 },
Hector Martin3b315d72009-06-02 10:54:19 +020010305 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010306 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010307 alc883_chmode_mixer },
10308 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010309 alc889_acer_aspire_8930g_verbs,
10310 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010311 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10312 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010313 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10314 .adc_nids = alc889_adc_nids,
10315 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010316 .dig_out_nid = ALC883_DIGOUT_NID,
10317 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10318 .channel_mode = alc883_3ST_6ch_modes,
10319 .need_dac_fix = 1,
10320 .const_channel_count = 6,
10321 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010322 ARRAY_SIZE(alc889_capture_sources),
10323 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010324 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010325 .setup = alc889_acer_aspire_8930g_setup,
10326 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010327#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010328 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010329#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010330 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010331 [ALC888_ACER_ASPIRE_7730G] = {
10332 .mixers = { alc883_3ST_6ch_mixer,
10333 alc883_chmode_mixer },
10334 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10335 alc888_acer_aspire_7730G_verbs },
10336 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10337 .dac_nids = alc883_dac_nids,
10338 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10339 .adc_nids = alc883_adc_nids_rev,
10340 .capsrc_nids = alc883_capsrc_nids_rev,
10341 .dig_out_nid = ALC883_DIGOUT_NID,
10342 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10343 .channel_mode = alc883_3ST_6ch_modes,
10344 .need_dac_fix = 1,
10345 .const_channel_count = 6,
10346 .input_mux = &alc883_capture_source,
10347 .unsol_event = alc_automute_amp_unsol_event,
Denis Kuplyakovd9477202010-11-24 06:01:09 +010010348 .setup = alc888_acer_aspire_7730g_setup,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010349 .init_hook = alc_automute_amp,
10350 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010351 [ALC883_MEDION] = {
10352 .mixers = { alc883_fivestack_mixer,
10353 alc883_chmode_mixer },
10354 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010355 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010356 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10357 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010358 .adc_nids = alc883_adc_nids_alt,
10359 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010360 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010361 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10362 .channel_mode = alc883_sixstack_modes,
10363 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010364 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010365 [ALC883_MEDION_WIM2160] = {
10366 .mixers = { alc883_medion_wim2160_mixer },
10367 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10368 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10369 .dac_nids = alc883_dac_nids,
10370 .dig_out_nid = ALC883_DIGOUT_NID,
10371 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10372 .adc_nids = alc883_adc_nids,
10373 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10374 .channel_mode = alc883_3ST_2ch_modes,
10375 .input_mux = &alc883_capture_source,
10376 .unsol_event = alc_automute_amp_unsol_event,
10377 .setup = alc883_medion_wim2160_setup,
10378 .init_hook = alc_automute_amp,
10379 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010380 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010381 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010382 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10383 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10384 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010385 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10386 .channel_mode = alc883_3ST_2ch_modes,
10387 .input_mux = &alc883_capture_source,
10388 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010389 [ALC883_CLEVO_M540R] = {
10390 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10391 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10392 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10393 .dac_nids = alc883_dac_nids,
10394 .dig_out_nid = ALC883_DIGOUT_NID,
10395 .dig_in_nid = ALC883_DIGIN_NID,
10396 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10397 .channel_mode = alc883_3ST_6ch_clevo_modes,
10398 .need_dac_fix = 1,
10399 .input_mux = &alc883_capture_source,
10400 /* This machine has the hardware HP auto-muting, thus
10401 * we need no software mute via unsol event
10402 */
10403 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010404 [ALC883_CLEVO_M720] = {
10405 .mixers = { alc883_clevo_m720_mixer },
10406 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010407 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10408 .dac_nids = alc883_dac_nids,
10409 .dig_out_nid = ALC883_DIGOUT_NID,
10410 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10411 .channel_mode = alc883_3ST_2ch_modes,
10412 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010413 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010414 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010415 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010416 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010417 [ALC883_LENOVO_101E_2ch] = {
10418 .mixers = { alc883_lenovo_101e_2ch_mixer},
10419 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10420 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10421 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010422 .adc_nids = alc883_adc_nids_alt,
10423 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010424 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010425 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10426 .channel_mode = alc883_3ST_2ch_modes,
10427 .input_mux = &alc883_lenovo_101e_capture_source,
10428 .unsol_event = alc883_lenovo_101e_unsol_event,
10429 .init_hook = alc883_lenovo_101e_all_automute,
10430 },
Kailang Yang272a5272007-05-14 11:00:38 +020010431 [ALC883_LENOVO_NB0763] = {
10432 .mixers = { alc883_lenovo_nb0763_mixer },
10433 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10434 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10435 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010436 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10437 .channel_mode = alc883_3ST_2ch_modes,
10438 .need_dac_fix = 1,
10439 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010440 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwaidc4271702010-11-29 07:42:59 +010010441 .setup = alc883_lenovo_nb0763_setup,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010442 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010443 },
10444 [ALC888_LENOVO_MS7195_DIG] = {
10445 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10446 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10447 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10448 .dac_nids = alc883_dac_nids,
10449 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010450 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10451 .channel_mode = alc883_3ST_6ch_modes,
10452 .need_dac_fix = 1,
10453 .input_mux = &alc883_capture_source,
10454 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10455 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010456 },
10457 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010458 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010459 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10460 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10461 .dac_nids = alc883_dac_nids,
10462 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010463 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10464 .channel_mode = alc883_3ST_2ch_modes,
10465 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010466 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010467 .setup = alc883_haier_w66_setup,
10468 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010469 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010470 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010471 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010472 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010473 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10474 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010475 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10476 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010477 .need_dac_fix = 1,
10478 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010479 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010480 .setup = alc888_3st_hp_setup,
10481 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010482 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010483 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010484 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010485 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10486 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10487 .dac_nids = alc883_dac_nids,
10488 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010489 .dig_in_nid = ALC883_DIGIN_NID,
10490 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10491 .channel_mode = alc883_sixstack_modes,
10492 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010493 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010494 .setup = alc888_6st_dell_setup,
10495 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010496 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010497 [ALC883_MITAC] = {
10498 .mixers = { alc883_mitac_mixer },
10499 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10500 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10501 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010502 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10503 .channel_mode = alc883_3ST_2ch_modes,
10504 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010505 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010506 .setup = alc883_mitac_setup,
10507 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010508 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010509 [ALC883_FUJITSU_PI2515] = {
10510 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10511 .init_verbs = { alc883_init_verbs,
10512 alc883_2ch_fujitsu_pi2515_verbs},
10513 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10514 .dac_nids = alc883_dac_nids,
10515 .dig_out_nid = ALC883_DIGOUT_NID,
10516 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10517 .channel_mode = alc883_3ST_2ch_modes,
10518 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010519 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010520 .setup = alc883_2ch_fujitsu_pi2515_setup,
10521 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010522 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010523 [ALC888_FUJITSU_XA3530] = {
10524 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10525 .init_verbs = { alc883_init_verbs,
10526 alc888_fujitsu_xa3530_verbs },
10527 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10528 .dac_nids = alc883_dac_nids,
10529 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10530 .adc_nids = alc883_adc_nids_rev,
10531 .capsrc_nids = alc883_capsrc_nids_rev,
10532 .dig_out_nid = ALC883_DIGOUT_NID,
10533 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10534 .channel_mode = alc888_4ST_8ch_intel_modes,
10535 .num_mux_defs =
10536 ARRAY_SIZE(alc888_2_capture_sources),
10537 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010538 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010539 .setup = alc888_fujitsu_xa3530_setup,
10540 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010541 },
Kailang Yange2757d52008-08-26 13:17:46 +020010542 [ALC888_LENOVO_SKY] = {
10543 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10544 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10545 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10546 .dac_nids = alc883_dac_nids,
10547 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010548 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10549 .channel_mode = alc883_sixstack_modes,
10550 .need_dac_fix = 1,
10551 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010552 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010553 .setup = alc888_lenovo_sky_setup,
10554 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010555 },
10556 [ALC888_ASUS_M90V] = {
10557 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10558 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10559 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10560 .dac_nids = alc883_dac_nids,
10561 .dig_out_nid = ALC883_DIGOUT_NID,
10562 .dig_in_nid = ALC883_DIGIN_NID,
10563 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10564 .channel_mode = alc883_3ST_6ch_modes,
10565 .need_dac_fix = 1,
10566 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010567 .unsol_event = alc_sku_unsol_event,
10568 .setup = alc883_mode2_setup,
10569 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010570 },
10571 [ALC888_ASUS_EEE1601] = {
10572 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010573 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010574 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10575 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10576 .dac_nids = alc883_dac_nids,
10577 .dig_out_nid = ALC883_DIGOUT_NID,
10578 .dig_in_nid = ALC883_DIGIN_NID,
10579 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10580 .channel_mode = alc883_3ST_2ch_modes,
10581 .need_dac_fix = 1,
10582 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010583 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010584 .init_hook = alc883_eee1601_inithook,
10585 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010586 [ALC1200_ASUS_P5Q] = {
10587 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10588 .init_verbs = { alc883_init_verbs },
10589 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10590 .dac_nids = alc883_dac_nids,
10591 .dig_out_nid = ALC1200_DIGOUT_NID,
10592 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010593 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010594 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10595 .channel_mode = alc883_sixstack_modes,
10596 .input_mux = &alc883_capture_source,
10597 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010598 [ALC889A_MB31] = {
10599 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10600 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10601 alc880_gpio1_init_verbs },
10602 .adc_nids = alc883_adc_nids,
10603 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010604 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010605 .dac_nids = alc883_dac_nids,
10606 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10607 .channel_mode = alc889A_mb31_6ch_modes,
10608 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10609 .input_mux = &alc889A_mb31_capture_source,
10610 .dig_out_nid = ALC883_DIGOUT_NID,
10611 .unsol_event = alc889A_mb31_unsol_event,
10612 .init_hook = alc889A_mb31_automute,
10613 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010614 [ALC883_SONY_VAIO_TT] = {
10615 .mixers = { alc883_vaiott_mixer },
10616 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10617 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10618 .dac_nids = alc883_dac_nids,
10619 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10620 .channel_mode = alc883_3ST_2ch_modes,
10621 .input_mux = &alc883_capture_source,
10622 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010623 .setup = alc883_vaiott_setup,
10624 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010625 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010626};
10627
10628
10629/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010630 * Pin config fixes
10631 */
10632enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010633 PINFIX_ABIT_AW9D_MAX,
10634 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010635 PINFIX_ACER_ASPIRE_7736,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010636};
10637
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010638static const struct alc_fixup alc882_fixups[] = {
10639 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010640 .pins = (const struct alc_pincfg[]) {
10641 { 0x15, 0x01080104 }, /* side */
10642 { 0x16, 0x01011012 }, /* rear */
10643 { 0x17, 0x01016011 }, /* clfe */
10644 { }
10645 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010646 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010647 [PINFIX_PB_M5210] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010648 .verbs = (const struct hda_verb[]) {
10649 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10650 {}
10651 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010652 },
David Henningssonc3d226a2010-10-14 15:42:08 +020010653 [PINFIX_ACER_ASPIRE_7736] = {
10654 .sku = ALC_FIXUP_SKU_IGNORE,
10655 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010656};
10657
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010658static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010659 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010660 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020010661 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010662 {}
10663};
10664
10665/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010666 * BIOS auto configuration
10667 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010668static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10669 const struct auto_pin_cfg *cfg)
10670{
10671 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10672}
10673
Takashi Iwai4953550a2009-06-30 15:28:30 +020010674static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010675 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010676 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010677{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010678 int idx;
10679
Takashi Iwai489008c2010-04-07 09:06:00 +020010680 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010681 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010682
Takashi Iwai489008c2010-04-07 09:06:00 +020010683 if (dac == 0x25)
10684 idx = 4;
10685 else if (dac >= 0x02 && dac <= 0x05)
10686 idx = dac - 2;
10687 else
10688 return;
10689 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010690}
10691
Takashi Iwai4953550a2009-06-30 15:28:30 +020010692static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010693{
10694 struct alc_spec *spec = codec->spec;
10695 int i;
10696
10697 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010698 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010699 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010700 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010701 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010702 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010703 }
10704}
10705
Takashi Iwai4953550a2009-06-30 15:28:30 +020010706static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010707{
10708 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010709 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010710 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010711
Takashi Iwai5855fb82010-09-16 18:24:02 +020010712 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10713 pin = spec->autocfg.hp_pins[i];
10714 if (!pin)
10715 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010716 dac = spec->multiout.hp_nid;
10717 if (!dac)
10718 dac = spec->multiout.dac_nids[0]; /* to front */
10719 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10720 }
Takashi Iwai5855fb82010-09-16 18:24:02 +020010721 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10722 pin = spec->autocfg.speaker_pins[i];
10723 if (!pin)
10724 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010725 dac = spec->multiout.extra_out_nid[0];
10726 if (!dac)
10727 dac = spec->multiout.dac_nids[0]; /* to front */
10728 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10729 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010730}
10731
Takashi Iwai4953550a2009-06-30 15:28:30 +020010732static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010733{
10734 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010735 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010736 int i;
10737
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010738 for (i = 0; i < cfg->num_inputs; i++) {
10739 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010740 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010741 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10742 snd_hda_codec_write(codec, nid, 0,
10743 AC_VERB_SET_AMP_GAIN_MUTE,
10744 AMP_OUT_MUTE);
10745 }
10746}
10747
10748static void alc882_auto_init_input_src(struct hda_codec *codec)
10749{
10750 struct alc_spec *spec = codec->spec;
10751 int c;
10752
10753 for (c = 0; c < spec->num_adc_nids; c++) {
10754 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10755 hda_nid_t nid = spec->capsrc_nids[c];
10756 unsigned int mux_idx;
10757 const struct hda_input_mux *imux;
10758 int conns, mute, idx, item;
10759
10760 conns = snd_hda_get_connections(codec, nid, conn_list,
10761 ARRAY_SIZE(conn_list));
10762 if (conns < 0)
10763 continue;
10764 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10765 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010766 if (!imux->num_items && mux_idx > 0)
10767 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010768 for (idx = 0; idx < conns; idx++) {
10769 /* if the current connection is the selected one,
10770 * unmute it as default - otherwise mute it
10771 */
10772 mute = AMP_IN_MUTE(idx);
10773 for (item = 0; item < imux->num_items; item++) {
10774 if (imux->items[item].index == idx) {
10775 if (spec->cur_mux[c] == item)
10776 mute = AMP_IN_UNMUTE(idx);
10777 break;
10778 }
10779 }
10780 /* check if we have a selector or mixer
10781 * we could check for the widget type instead, but
10782 * just check for Amp-In presence (in case of mixer
10783 * without amp-in there is something wrong, this
10784 * function shouldn't be used or capsrc nid is wrong)
10785 */
10786 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010787 snd_hda_codec_write(codec, nid, 0,
10788 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010789 mute);
10790 else if (mute != AMP_IN_MUTE(idx))
10791 snd_hda_codec_write(codec, nid, 0,
10792 AC_VERB_SET_CONNECT_SEL,
10793 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010794 }
10795 }
10796}
10797
Takashi Iwai4953550a2009-06-30 15:28:30 +020010798/* add mic boosts if needed */
10799static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010800{
10801 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010802 struct auto_pin_cfg *cfg = &spec->autocfg;
10803 int i, err;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010804 hda_nid_t nid;
10805
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010806 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010807 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010808 break;
10809 nid = cfg->inputs[i].pin;
10810 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +020010811 char label[32];
10812 snprintf(label, sizeof(label), "%s Boost",
10813 hda_get_autocfg_input_label(codec, cfg, i));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010814 err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010815 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010816 if (err < 0)
10817 return err;
10818 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010819 }
10820 return 0;
10821}
10822
10823/* almost identical with ALC880 parser... */
10824static int alc882_parse_auto_config(struct hda_codec *codec)
10825{
10826 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010827 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010828 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010829
Takashi Iwai05f5f472009-08-25 13:10:18 +020010830 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10831 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010832 if (err < 0)
10833 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010834 if (!spec->autocfg.line_outs)
10835 return 0; /* can't find valid BIOS pin config */
10836
10837 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10838 if (err < 0)
10839 return err;
10840 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10841 if (err < 0)
10842 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010843 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10844 "Headphone");
10845 if (err < 0)
10846 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010847 err = alc880_auto_create_extra_out(spec,
10848 spec->autocfg.speaker_pins[0],
10849 "Speaker");
10850 if (err < 0)
10851 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010852 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10853 if (err < 0)
10854 return err;
10855
10856 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10857
Takashi Iwai757899a2010-07-30 10:48:14 +020010858 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010859
10860 if (spec->kctls.list)
10861 add_mixer(spec, spec->kctls.list);
10862
10863 add_verb(spec, alc883_auto_init_verbs);
10864 /* if ADC 0x07 is available, initialize it, too */
10865 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10866 add_verb(spec, alc882_adc1_init_verbs);
10867
10868 spec->num_mux_defs = 1;
10869 spec->input_mux = &spec->private_imux[0];
10870
Kailang Yang6227cdc2010-02-25 08:36:52 +010010871 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010872
10873 err = alc_auto_add_mic_boost(codec);
10874 if (err < 0)
10875 return err;
10876
Takashi Iwai776e1842007-08-29 15:07:11 +020010877 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010878}
10879
10880/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010881static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010882{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010883 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010884 alc882_auto_init_multi_out(codec);
10885 alc882_auto_init_hp_out(codec);
10886 alc882_auto_init_analog_input(codec);
10887 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010888 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010889 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010890 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010891}
10892
Takashi Iwai4953550a2009-06-30 15:28:30 +020010893static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010894{
10895 struct alc_spec *spec;
10896 int err, board_config;
10897
10898 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10899 if (spec == NULL)
10900 return -ENOMEM;
10901
10902 codec->spec = spec;
10903
Takashi Iwai4953550a2009-06-30 15:28:30 +020010904 switch (codec->vendor_id) {
10905 case 0x10ec0882:
10906 case 0x10ec0885:
10907 break;
10908 default:
10909 /* ALC883 and variants */
10910 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10911 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010912 }
10913
Takashi Iwai4953550a2009-06-30 15:28:30 +020010914 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10915 alc882_models,
10916 alc882_cfg_tbl);
10917
10918 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10919 board_config = snd_hda_check_board_codec_sid_config(codec,
10920 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10921
10922 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010923 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010924 codec->chip_name);
10925 board_config = ALC882_AUTO;
10926 }
10927
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010928 if (board_config == ALC882_AUTO)
10929 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010930
David Henningsson90622912010-10-14 14:50:18 +020010931 alc_auto_parse_customize_define(codec);
10932
Takashi Iwai4953550a2009-06-30 15:28:30 +020010933 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010934 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010935 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010936 if (err < 0) {
10937 alc_free(codec);
10938 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010939 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010940 printk(KERN_INFO
10941 "hda_codec: Cannot set up configuration "
10942 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010943 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010944 }
10945 }
10946
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010947 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020010948 err = snd_hda_attach_beep_device(codec, 0x1);
10949 if (err < 0) {
10950 alc_free(codec);
10951 return err;
10952 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010953 }
10954
Takashi Iwai4953550a2009-06-30 15:28:30 +020010955 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010956 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010957
Takashi Iwai4953550a2009-06-30 15:28:30 +020010958 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10959 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10960 /* FIXME: setup DAC5 */
10961 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10962 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10963
10964 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10965 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10966
Takashi Iwai4953550a2009-06-30 15:28:30 +020010967 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010968 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010969 spec->num_adc_nids = 0;
10970 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010971 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010972 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010973 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010974 hda_nid_t nid = alc882_adc_nids[i];
10975 unsigned int wcap = get_wcaps(codec, nid);
10976 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010977 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010978 if (wcap != AC_WID_AUD_IN)
10979 continue;
10980 spec->private_adc_nids[spec->num_adc_nids] = nid;
10981 err = snd_hda_get_connections(codec, nid, &cap, 1);
10982 if (err < 0)
10983 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010984 err = snd_hda_get_connections(codec, cap, items,
10985 ARRAY_SIZE(items));
10986 if (err < 0)
10987 continue;
10988 for (j = 0; j < imux->num_items; j++)
10989 if (imux->items[j].index >= err)
10990 break;
10991 if (j < imux->num_items)
10992 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010993 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10994 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010995 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010996 spec->adc_nids = spec->private_adc_nids;
10997 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010998 }
10999
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011000 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010011001
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011002 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010011003 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011004
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011005 if (board_config == ALC882_AUTO)
11006 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
11007
Takashi Iwai2134ea42008-01-10 16:53:55 +010011008 spec->vmaster_nid = 0x0c;
11009
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011010 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011011 if (board_config == ALC882_AUTO)
11012 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011013
11014 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011015#ifdef CONFIG_SND_HDA_POWER_SAVE
11016 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011017 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011018#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011019
11020 return 0;
11021}
11022
Takashi Iwai4953550a2009-06-30 15:28:30 +020011023
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011024/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011025 * ALC262 support
11026 */
11027
11028#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11029#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11030
11031#define alc262_dac_nids alc260_dac_nids
11032#define alc262_adc_nids alc882_adc_nids
11033#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011034#define alc262_capsrc_nids alc882_capsrc_nids
11035#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011036
11037#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011038#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011039
Kailang Yang4e555fe2008-08-26 13:05:55 +020011040static hda_nid_t alc262_dmic_adc_nids[1] = {
11041 /* ADC0 */
11042 0x09
11043};
11044
11045static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
11046
Kailang Yangdf694da2005-12-05 19:42:22 +010011047static struct snd_kcontrol_new alc262_base_mixer[] = {
11048 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11049 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11050 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11051 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11052 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11053 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11054 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11055 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011056 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011057 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11058 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011059 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011060 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11061 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11062 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11063 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011064 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011065};
11066
Takashi Iwaice875f02008-01-28 18:17:43 +010011067/* update HP, line and mono-out pins according to the master switch */
11068static void alc262_hp_master_update(struct hda_codec *codec)
11069{
11070 struct alc_spec *spec = codec->spec;
11071 int val = spec->master_sw;
11072
11073 /* HP & line-out */
11074 snd_hda_codec_write_cache(codec, 0x1b, 0,
11075 AC_VERB_SET_PIN_WIDGET_CONTROL,
11076 val ? PIN_HP : 0);
11077 snd_hda_codec_write_cache(codec, 0x15, 0,
11078 AC_VERB_SET_PIN_WIDGET_CONTROL,
11079 val ? PIN_HP : 0);
11080 /* mono (speaker) depending on the HP jack sense */
11081 val = val && !spec->jack_present;
11082 snd_hda_codec_write_cache(codec, 0x16, 0,
11083 AC_VERB_SET_PIN_WIDGET_CONTROL,
11084 val ? PIN_OUT : 0);
11085}
11086
11087static void alc262_hp_bpc_automute(struct hda_codec *codec)
11088{
11089 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011090
11091 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011092 alc262_hp_master_update(codec);
11093}
11094
11095static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11096{
11097 if ((res >> 26) != ALC880_HP_EVENT)
11098 return;
11099 alc262_hp_bpc_automute(codec);
11100}
11101
11102static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11103{
11104 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011105
11106 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011107 alc262_hp_master_update(codec);
11108}
11109
11110static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11111 unsigned int res)
11112{
11113 if ((res >> 26) != ALC880_HP_EVENT)
11114 return;
11115 alc262_hp_wildwest_automute(codec);
11116}
11117
Takashi Iwaib72519b2009-05-08 14:31:55 +020011118#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011119
11120static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11121 struct snd_ctl_elem_value *ucontrol)
11122{
11123 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11124 struct alc_spec *spec = codec->spec;
11125 int val = !!*ucontrol->value.integer.value;
11126
11127 if (val == spec->master_sw)
11128 return 0;
11129 spec->master_sw = val;
11130 alc262_hp_master_update(codec);
11131 return 1;
11132}
11133
Takashi Iwaib72519b2009-05-08 14:31:55 +020011134#define ALC262_HP_MASTER_SWITCH \
11135 { \
11136 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11137 .name = "Master Playback Switch", \
11138 .info = snd_ctl_boolean_mono_info, \
11139 .get = alc262_hp_master_sw_get, \
11140 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011141 }, \
11142 { \
11143 .iface = NID_MAPPING, \
11144 .name = "Master Playback Switch", \
11145 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011146 }
11147
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011148
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011149static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011150 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011151 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11152 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11153 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011154 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11155 HDA_OUTPUT),
11156 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11157 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011158 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11159 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011160 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011161 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11162 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011163 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011164 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11165 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11166 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11167 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011168 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11169 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11170 { } /* end */
11171};
11172
Kailang Yangcd7509a2007-01-26 18:33:17 +010011173static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011174 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011175 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11176 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11177 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11178 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011179 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11180 HDA_OUTPUT),
11181 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11182 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011183 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11184 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011185 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011186 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11187 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11188 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11189 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011190 { } /* end */
11191};
11192
11193static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11194 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11195 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011196 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011197 { } /* end */
11198};
11199
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011200/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011201static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011202{
11203 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011204
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011205 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011206 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011207}
11208
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011209static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011210 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11211 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011212 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11213 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11214 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11215 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11216 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11217 { } /* end */
11218};
11219
11220static struct hda_verb alc262_hp_t5735_verbs[] = {
11221 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11222 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11223
11224 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11225 { }
11226};
11227
Kailang Yang8c427222008-01-10 13:03:59 +010011228static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011229 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11230 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011231 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11232 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011233 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11234 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11235 { } /* end */
11236};
11237
11238static struct hda_verb alc262_hp_rp5700_verbs[] = {
11239 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11240 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11241 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11242 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11243 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11244 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11245 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11246 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11247 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11248 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11249 {}
11250};
11251
11252static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11253 .num_items = 1,
11254 .items = {
11255 { "Line", 0x1 },
11256 },
11257};
11258
Takashi Iwai42171c12009-05-08 14:11:43 +020011259/* bind hp and internal speaker mute (with plug check) as master switch */
11260static void alc262_hippo_master_update(struct hda_codec *codec)
11261{
11262 struct alc_spec *spec = codec->spec;
11263 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11264 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11265 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11266 unsigned int mute;
11267
11268 /* HP */
11269 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11270 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11271 HDA_AMP_MUTE, mute);
11272 /* mute internal speaker per jack sense */
11273 if (spec->jack_present)
11274 mute = HDA_AMP_MUTE;
11275 if (line_nid)
11276 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11277 HDA_AMP_MUTE, mute);
11278 if (speaker_nid && speaker_nid != line_nid)
11279 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11280 HDA_AMP_MUTE, mute);
11281}
11282
11283#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11284
11285static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11286 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011287{
11288 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011289 struct alc_spec *spec = codec->spec;
11290 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011291
Takashi Iwai42171c12009-05-08 14:11:43 +020011292 if (val == spec->master_sw)
11293 return 0;
11294 spec->master_sw = val;
11295 alc262_hippo_master_update(codec);
11296 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011297}
Takashi Iwai5b319542007-07-26 11:49:22 +020011298
Takashi Iwai42171c12009-05-08 14:11:43 +020011299#define ALC262_HIPPO_MASTER_SWITCH \
11300 { \
11301 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11302 .name = "Master Playback Switch", \
11303 .info = snd_ctl_boolean_mono_info, \
11304 .get = alc262_hippo_master_sw_get, \
11305 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011306 }, \
11307 { \
11308 .iface = NID_MAPPING, \
11309 .name = "Master Playback Switch", \
11310 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11311 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011312 }
11313
11314static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11315 ALC262_HIPPO_MASTER_SWITCH,
11316 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11317 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11318 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11319 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11320 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11321 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11322 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11323 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11324 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11325 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11326 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11327 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11328 { } /* end */
11329};
11330
11331static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11332 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11333 ALC262_HIPPO_MASTER_SWITCH,
11334 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11335 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11336 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11337 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11338 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11339 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11340 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11341 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11342 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11343 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11344 { } /* end */
11345};
11346
11347/* mute/unmute internal speaker according to the hp jack and mute state */
11348static void alc262_hippo_automute(struct hda_codec *codec)
11349{
11350 struct alc_spec *spec = codec->spec;
11351 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011352
Wu Fengguang864f92b2009-11-18 12:38:02 +080011353 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011354 alc262_hippo_master_update(codec);
11355}
11356
11357static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11358{
11359 if ((res >> 26) != ALC880_HP_EVENT)
11360 return;
11361 alc262_hippo_automute(codec);
11362}
11363
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011364static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011365{
11366 struct alc_spec *spec = codec->spec;
11367
11368 spec->autocfg.hp_pins[0] = 0x15;
11369 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011370}
11371
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011372static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011373{
11374 struct alc_spec *spec = codec->spec;
11375
11376 spec->autocfg.hp_pins[0] = 0x1b;
11377 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011378}
11379
11380
Kailang Yang272a5272007-05-14 11:00:38 +020011381static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011382 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011383 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011384 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11385 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11386 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11387 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11388 { } /* end */
11389};
11390
Kailang Yang83c34212007-07-05 11:43:05 +020011391static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011392 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11393 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011394 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11395 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11396 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11397 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11398 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11399 { } /* end */
11400};
Kailang Yang272a5272007-05-14 11:00:38 +020011401
Tony Vroonba340e82009-02-02 19:01:30 +000011402static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11403 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11404 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11405 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11406 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11407 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11408 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11409 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11410 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11411 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11412 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11413 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11414 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11415 { } /* end */
11416};
11417
11418static struct hda_verb alc262_tyan_verbs[] = {
11419 /* Headphone automute */
11420 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11421 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11422 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11423
11424 /* P11 AUX_IN, white 4-pin connector */
11425 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11426 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11427 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11428 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11429
11430 {}
11431};
11432
11433/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011434static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011435{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011436 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011437
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011438 spec->autocfg.hp_pins[0] = 0x1b;
11439 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011440}
11441
Tony Vroonba340e82009-02-02 19:01:30 +000011442
Kailang Yangdf694da2005-12-05 19:42:22 +010011443#define alc262_capture_mixer alc882_capture_mixer
11444#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11445
11446/*
11447 * generic initialization of ADC, input mixers and output mixers
11448 */
11449static struct hda_verb alc262_init_verbs[] = {
11450 /*
11451 * Unmute ADC0-2 and set the default input to mic-in
11452 */
11453 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11454 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11455 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11456 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11457 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11458 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11459
Takashi Iwaicb53c622007-08-10 17:21:45 +020011460 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011461 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011462 * Note: PASD motherboards uses the Line In 2 as the input for
11463 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011464 */
11465 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011466 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11467 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11468 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11469 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11470 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011471
11472 /*
11473 * Set up output mixers (0x0c - 0x0e)
11474 */
11475 /* set vol=0 to output mixers */
11476 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11477 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11478 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11479 /* set up input amps for analog loopback */
11480 /* Amp Indices: DAC = 0, mixer = 1 */
11481 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11482 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11483 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11484 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11485 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11486 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11487
11488 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11489 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11490 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11491 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11492 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11493 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11494
11495 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11496 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11497 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11498 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11499 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011500
Kailang Yangdf694da2005-12-05 19:42:22 +010011501 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11502 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011503
Kailang Yangdf694da2005-12-05 19:42:22 +010011504 /* FIXME: use matrix-type input source selection */
11505 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11506 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11507 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11508 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11509 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11510 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11511 /* Input mixer2 */
11512 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11513 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11514 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11515 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11516 /* Input mixer3 */
11517 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11518 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11519 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011520 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011521
11522 { }
11523};
11524
Kailang Yang4e555fe2008-08-26 13:05:55 +020011525static struct hda_verb alc262_eapd_verbs[] = {
11526 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11527 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11528 { }
11529};
11530
Kailang Yangccc656c2006-10-17 12:32:26 +020011531static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11532 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11533 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11534 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11535
11536 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11537 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11538 {}
11539};
11540
Kailang Yang272a5272007-05-14 11:00:38 +020011541static struct hda_verb alc262_sony_unsol_verbs[] = {
11542 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11543 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11544 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11545
11546 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11547 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011548 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011549};
11550
Kailang Yang4e555fe2008-08-26 13:05:55 +020011551static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11552 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11553 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11554 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11555 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11556 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011557 { } /* end */
11558};
11559
11560static struct hda_verb alc262_toshiba_s06_verbs[] = {
11561 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11562 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11563 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11564 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11565 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11566 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11567 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11568 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11569 {}
11570};
11571
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011572static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011573{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011574 struct alc_spec *spec = codec->spec;
11575
11576 spec->autocfg.hp_pins[0] = 0x15;
11577 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011578 spec->ext_mic.pin = 0x18;
11579 spec->ext_mic.mux_idx = 0;
11580 spec->int_mic.pin = 0x12;
11581 spec->int_mic.mux_idx = 9;
11582 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011583}
11584
Takashi Iwai834be882006-03-01 14:16:17 +010011585/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011586 * nec model
11587 * 0x15 = headphone
11588 * 0x16 = internal speaker
11589 * 0x18 = external mic
11590 */
11591
11592static struct snd_kcontrol_new alc262_nec_mixer[] = {
11593 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11594 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11595
11596 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11597 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11598 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11599
11600 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11601 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11602 { } /* end */
11603};
11604
11605static struct hda_verb alc262_nec_verbs[] = {
11606 /* Unmute Speaker */
11607 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11608
11609 /* Headphone */
11610 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11611 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11612
11613 /* External mic to headphone */
11614 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11615 /* External mic to speaker */
11616 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11617 {}
11618};
11619
11620/*
Takashi Iwai834be882006-03-01 14:16:17 +010011621 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011622 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11623 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011624 */
11625
11626#define ALC_HP_EVENT 0x37
11627
11628static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11629 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11630 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011631 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11632 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011633 {}
11634};
11635
Jiang zhe0e31daf2008-03-20 12:12:39 +010011636static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11637 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11638 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11639 {}
11640};
11641
Daniel T Chene2595322009-12-19 18:19:02 -050011642static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11643 /* Front Mic pin: input vref at 50% */
11644 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11645 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11646 {}
11647};
11648
Takashi Iwai834be882006-03-01 14:16:17 +010011649static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011650 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011651 .items = {
11652 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011653 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011654 { "CD", 0x4 },
11655 },
11656};
11657
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011658static struct hda_input_mux alc262_HP_capture_source = {
11659 .num_items = 5,
11660 .items = {
11661 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011662 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011663 { "Line", 0x2 },
11664 { "CD", 0x4 },
11665 { "AUX IN", 0x6 },
11666 },
11667};
11668
zhejiangaccbe492007-08-31 12:36:05 +020011669static struct hda_input_mux alc262_HP_D7000_capture_source = {
11670 .num_items = 4,
11671 .items = {
11672 { "Mic", 0x0 },
11673 { "Front Mic", 0x2 },
11674 { "Line", 0x1 },
11675 { "CD", 0x4 },
11676 },
11677};
11678
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011679/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011680static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11681{
11682 struct alc_spec *spec = codec->spec;
11683 unsigned int mute;
11684
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011685 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011686 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11687 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011688 spec->sense_updated = 1;
11689 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011690 /* unmute internal speaker only if both HPs are unplugged and
11691 * master switch is on
11692 */
11693 if (spec->jack_present)
11694 mute = HDA_AMP_MUTE;
11695 else
Takashi Iwai834be882006-03-01 14:16:17 +010011696 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011697 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11698 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011699}
11700
11701/* unsolicited event for HP jack sensing */
11702static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11703 unsigned int res)
11704{
11705 if ((res >> 26) != ALC_HP_EVENT)
11706 return;
11707 alc262_fujitsu_automute(codec, 1);
11708}
11709
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011710static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11711{
11712 alc262_fujitsu_automute(codec, 1);
11713}
11714
Takashi Iwai834be882006-03-01 14:16:17 +010011715/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011716static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11717 .ops = &snd_hda_bind_vol,
11718 .values = {
11719 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11720 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11721 0
11722 },
11723};
Takashi Iwai834be882006-03-01 14:16:17 +010011724
Jiang zhe0e31daf2008-03-20 12:12:39 +010011725/* mute/unmute internal speaker according to the hp jack and mute state */
11726static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11727{
11728 struct alc_spec *spec = codec->spec;
11729 unsigned int mute;
11730
11731 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011732 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011733 spec->sense_updated = 1;
11734 }
11735 if (spec->jack_present) {
11736 /* mute internal speaker */
11737 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11738 HDA_AMP_MUTE, HDA_AMP_MUTE);
11739 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11740 HDA_AMP_MUTE, HDA_AMP_MUTE);
11741 } else {
11742 /* unmute internal speaker if necessary */
11743 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11744 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11745 HDA_AMP_MUTE, mute);
11746 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11747 HDA_AMP_MUTE, mute);
11748 }
11749}
11750
11751/* unsolicited event for HP jack sensing */
11752static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11753 unsigned int res)
11754{
11755 if ((res >> 26) != ALC_HP_EVENT)
11756 return;
11757 alc262_lenovo_3000_automute(codec, 1);
11758}
11759
Takashi Iwai8de56b72009-07-24 16:51:47 +020011760static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11761 int dir, int idx, long *valp)
11762{
11763 int i, change = 0;
11764
11765 for (i = 0; i < 2; i++, valp++)
11766 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11767 HDA_AMP_MUTE,
11768 *valp ? 0 : HDA_AMP_MUTE);
11769 return change;
11770}
11771
Takashi Iwai834be882006-03-01 14:16:17 +010011772/* bind hp and internal speaker mute (with plug check) */
11773static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11774 struct snd_ctl_elem_value *ucontrol)
11775{
11776 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11777 long *valp = ucontrol->value.integer.value;
11778 int change;
11779
Takashi Iwai8de56b72009-07-24 16:51:47 +020011780 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11781 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011782 if (change)
11783 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011784 return change;
11785}
11786
11787static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011788 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011789 {
11790 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11791 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011792 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011793 .info = snd_hda_mixer_amp_switch_info,
11794 .get = snd_hda_mixer_amp_switch_get,
11795 .put = alc262_fujitsu_master_sw_put,
11796 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11797 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011798 {
11799 .iface = NID_MAPPING,
11800 .name = "Master Playback Switch",
11801 .private_value = 0x1b,
11802 },
Takashi Iwai834be882006-03-01 14:16:17 +010011803 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11804 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11805 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11806 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11807 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011808 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11809 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11810 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011811 { } /* end */
11812};
11813
Jiang zhe0e31daf2008-03-20 12:12:39 +010011814/* bind hp and internal speaker mute (with plug check) */
11815static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11816 struct snd_ctl_elem_value *ucontrol)
11817{
11818 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11819 long *valp = ucontrol->value.integer.value;
11820 int change;
11821
Takashi Iwai8de56b72009-07-24 16:51:47 +020011822 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011823 if (change)
11824 alc262_lenovo_3000_automute(codec, 0);
11825 return change;
11826}
11827
11828static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11829 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11830 {
11831 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11832 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011833 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011834 .info = snd_hda_mixer_amp_switch_info,
11835 .get = snd_hda_mixer_amp_switch_get,
11836 .put = alc262_lenovo_3000_master_sw_put,
11837 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11838 },
11839 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11840 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11841 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11842 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11843 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11844 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11845 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11846 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11847 { } /* end */
11848};
11849
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011850static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11851 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011852 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011853 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11854 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11855 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11856 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11857 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11858 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11859 { } /* end */
11860};
11861
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011862/* additional init verbs for Benq laptops */
11863static struct hda_verb alc262_EAPD_verbs[] = {
11864 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11865 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11866 {}
11867};
11868
Kailang Yang83c34212007-07-05 11:43:05 +020011869static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11870 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11871 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11872
11873 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11874 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11875 {}
11876};
11877
Tobin Davisf651b502007-10-26 12:40:47 +020011878/* Samsung Q1 Ultra Vista model setup */
11879static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011880 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11881 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011882 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11883 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11884 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011885 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011886 { } /* end */
11887};
11888
11889static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011890 /* output mixer */
11891 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11892 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11893 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11894 /* speaker */
11895 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11896 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11897 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11898 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11899 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011900 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011901 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11902 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11903 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11904 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11905 /* internal mic */
11906 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11907 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11908 /* ADC, choose mic */
11909 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11910 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11911 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11912 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11913 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11914 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11915 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11916 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11917 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11918 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011919 {}
11920};
11921
Tobin Davisf651b502007-10-26 12:40:47 +020011922/* mute/unmute internal speaker according to the hp jack and mute state */
11923static void alc262_ultra_automute(struct hda_codec *codec)
11924{
11925 struct alc_spec *spec = codec->spec;
11926 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011927
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011928 mute = 0;
11929 /* auto-mute only when HP is used as HP */
11930 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011931 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011932 if (spec->jack_present)
11933 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011934 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011935 /* mute/unmute internal speaker */
11936 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11937 HDA_AMP_MUTE, mute);
11938 /* mute/unmute HP */
11939 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11940 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011941}
11942
11943/* unsolicited event for HP jack sensing */
11944static void alc262_ultra_unsol_event(struct hda_codec *codec,
11945 unsigned int res)
11946{
11947 if ((res >> 26) != ALC880_HP_EVENT)
11948 return;
11949 alc262_ultra_automute(codec);
11950}
11951
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011952static struct hda_input_mux alc262_ultra_capture_source = {
11953 .num_items = 2,
11954 .items = {
11955 { "Mic", 0x1 },
11956 { "Headphone", 0x7 },
11957 },
11958};
11959
11960static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11961 struct snd_ctl_elem_value *ucontrol)
11962{
11963 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11964 struct alc_spec *spec = codec->spec;
11965 int ret;
11966
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011967 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011968 if (!ret)
11969 return 0;
11970 /* reprogram the HP pin as mic or HP according to the input source */
11971 snd_hda_codec_write_cache(codec, 0x15, 0,
11972 AC_VERB_SET_PIN_WIDGET_CONTROL,
11973 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11974 alc262_ultra_automute(codec); /* mute/unmute HP */
11975 return ret;
11976}
11977
11978static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11979 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11980 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11981 {
11982 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11983 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011984 .info = alc_mux_enum_info,
11985 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011986 .put = alc262_ultra_mux_enum_put,
11987 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011988 {
11989 .iface = NID_MAPPING,
11990 .name = "Capture Source",
11991 .private_value = 0x15,
11992 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011993 { } /* end */
11994};
11995
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011996/* We use two mixers depending on the output pin; 0x16 is a mono output
11997 * and thus it's bound with a different mixer.
11998 * This function returns which mixer amp should be used.
11999 */
12000static int alc262_check_volbit(hda_nid_t nid)
12001{
12002 if (!nid)
12003 return 0;
12004 else if (nid == 0x16)
12005 return 2;
12006 else
12007 return 1;
12008}
12009
12010static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012011 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012012{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012013 unsigned long val;
12014 int vbit;
12015
12016 vbit = alc262_check_volbit(nid);
12017 if (!vbit)
12018 return 0;
12019 if (*vbits & vbit) /* a volume control for this mixer already there */
12020 return 0;
12021 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012022 if (vbit == 2)
12023 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
12024 else
12025 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012026 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012027}
12028
12029static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012030 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012031{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012032 unsigned long val;
12033
12034 if (!nid)
12035 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012036 if (nid == 0x16)
12037 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
12038 else
12039 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012040 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012041}
12042
Kailang Yangdf694da2005-12-05 19:42:22 +010012043/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012044static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
12045 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012046{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012047 const char *pfx;
12048 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020012049 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012050
12051 spec->multiout.num_dacs = 1; /* only use one dac */
12052 spec->multiout.dac_nids = spec->private_dac_nids;
12053 spec->multiout.dac_nids[0] = 2;
12054
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012055 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
12056 pfx = "Master";
12057 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12058 pfx = "Speaker";
Takashi Iwai033688a2010-09-08 15:47:09 +020012059 else if (cfg->line_out_type == AUTO_PIN_HP_OUT)
12060 pfx = "Headphone";
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012061 else
12062 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012063 for (i = 0; i < 2; i++) {
12064 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12065 if (err < 0)
12066 return err;
12067 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12068 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12069 "Speaker", i);
12070 if (err < 0)
12071 return err;
12072 }
12073 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12074 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12075 "Headphone", i);
12076 if (err < 0)
12077 return err;
12078 }
12079 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012080
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012081 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12082 alc262_check_volbit(cfg->speaker_pins[0]) |
12083 alc262_check_volbit(cfg->hp_pins[0]);
12084 if (vbits == 1 || vbits == 2)
12085 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012086 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012087 for (i = 0; i < 2; i++) {
12088 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12089 &vbits, i);
12090 if (err < 0)
12091 return err;
12092 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12093 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12094 "Speaker", &vbits, i);
12095 if (err < 0)
12096 return err;
12097 }
12098 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12099 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12100 "Headphone", &vbits, i);
12101 if (err < 0)
12102 return err;
12103 }
12104 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012105 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012106}
12107
Takashi Iwai05f5f472009-08-25 13:10:18 +020012108#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012109 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012110
12111/*
12112 * generic initialization of ADC, input mixers and output mixers
12113 */
12114static struct hda_verb alc262_volume_init_verbs[] = {
12115 /*
12116 * Unmute ADC0-2 and set the default input to mic-in
12117 */
12118 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12119 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12120 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12121 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12122 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12123 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12124
Takashi Iwaicb53c622007-08-10 17:21:45 +020012125 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012126 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012127 * Note: PASD motherboards uses the Line In 2 as the input for
12128 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012129 */
12130 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12133 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12135 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012136
12137 /*
12138 * Set up output mixers (0x0c - 0x0f)
12139 */
12140 /* set vol=0 to output mixers */
12141 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12142 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12143 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012144
Kailang Yangdf694da2005-12-05 19:42:22 +010012145 /* set up input amps for analog loopback */
12146 /* Amp Indices: DAC = 0, mixer = 1 */
12147 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12148 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12149 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12150 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12151 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12152 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12153
12154 /* FIXME: use matrix-type input source selection */
12155 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12156 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12157 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12158 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12159 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12160 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12161 /* Input mixer2 */
12162 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12163 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12164 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12165 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12166 /* Input mixer3 */
12167 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12168 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12169 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12170 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12171
12172 { }
12173};
12174
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012175static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12176 /*
12177 * Unmute ADC0-2 and set the default input to mic-in
12178 */
12179 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12180 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12181 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12182 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12183 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12184 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12185
Takashi Iwaicb53c622007-08-10 17:21:45 +020012186 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012187 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012188 * Note: PASD motherboards uses the Line In 2 as the input for
12189 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012190 */
12191 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012192 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12193 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12194 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12195 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12196 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12197 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12198 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012199
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012200 /*
12201 * Set up output mixers (0x0c - 0x0e)
12202 */
12203 /* set vol=0 to output mixers */
12204 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12205 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12206 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12207
12208 /* set up input amps for analog loopback */
12209 /* Amp Indices: DAC = 0, mixer = 1 */
12210 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12211 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12212 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12213 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12214 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12215 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12216
Takashi Iwaice875f02008-01-28 18:17:43 +010012217 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012218 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12219 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12220
12221 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12222 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12223
12224 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12225 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12226
12227 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12228 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12229 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12230 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12231 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12232
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012233 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012234 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12235 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012236 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012237 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12238 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12239
12240
12241 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012242 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12243 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012244 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012245 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12246 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12247 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12248 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12249 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12250 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12251 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12252 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012253 /* Input mixer2 */
12254 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012255 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12256 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12257 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12258 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12259 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12260 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12261 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12262 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012263 /* Input mixer3 */
12264 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012265 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12266 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12267 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12268 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12269 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12270 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12271 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12272 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012273
Takashi Iwaice875f02008-01-28 18:17:43 +010012274 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12275
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012276 { }
12277};
12278
Kailang Yangcd7509a2007-01-26 18:33:17 +010012279static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12280 /*
12281 * Unmute ADC0-2 and set the default input to mic-in
12282 */
12283 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12284 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12285 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12286 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12287 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12288 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12289
Takashi Iwaicb53c622007-08-10 17:21:45 +020012290 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012291 * mixer widget
12292 * Note: PASD motherboards uses the Line In 2 as the input for front
12293 * panel mic (mic 2)
12294 */
12295 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012296 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12297 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12298 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12299 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12300 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12301 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12302 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12303 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012304 /*
12305 * Set up output mixers (0x0c - 0x0e)
12306 */
12307 /* set vol=0 to output mixers */
12308 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12309 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12310 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12311
12312 /* set up input amps for analog loopback */
12313 /* Amp Indices: DAC = 0, mixer = 1 */
12314 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12315 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12316 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12317 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12318 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12319 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12320
12321
12322 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12323 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12324 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12325 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12326 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12327 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12328 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12329
12330 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12331 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12332
12333 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12334 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12335
12336 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12337 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12338 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12339 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12340 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12341 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12342
12343 /* FIXME: use matrix-type input source selection */
12344 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12345 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12346 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12347 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12348 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12349 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12350 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12351 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12352 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12353 /* Input mixer2 */
12354 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12355 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12356 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12357 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12358 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12359 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12360 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12361 /* Input mixer3 */
12362 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12363 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12364 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12365 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12366 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12367 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12368 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12369
Takashi Iwaice875f02008-01-28 18:17:43 +010012370 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12371
Kailang Yangcd7509a2007-01-26 18:33:17 +010012372 { }
12373};
12374
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012375static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12376
12377 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12378 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12379 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12380
12381 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12382 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12383 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12384 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12385
12386 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12387 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12388 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12389 {}
12390};
12391
Takashi Iwai18675e42010-09-08 15:55:44 +020012392/*
12393 * Pin config fixes
12394 */
12395enum {
12396 PINFIX_FSC_H270,
12397};
12398
12399static const struct alc_fixup alc262_fixups[] = {
12400 [PINFIX_FSC_H270] = {
12401 .pins = (const struct alc_pincfg[]) {
12402 { 0x14, 0x99130110 }, /* speaker */
12403 { 0x15, 0x0221142f }, /* front HP */
12404 { 0x1b, 0x0121141f }, /* rear HP */
12405 { }
12406 }
12407 },
12408 [PINFIX_PB_M5210] = {
12409 .verbs = (const struct hda_verb[]) {
12410 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
12411 {}
12412 }
12413 },
12414};
12415
12416static struct snd_pci_quirk alc262_fixup_tbl[] = {
12417 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12418 {}
12419};
12420
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012421
Takashi Iwaicb53c622007-08-10 17:21:45 +020012422#ifdef CONFIG_SND_HDA_POWER_SAVE
12423#define alc262_loopbacks alc880_loopbacks
12424#endif
12425
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012426/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012427#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12428#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12429#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12430#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12431
12432/*
12433 * BIOS auto configuration
12434 */
12435static int alc262_parse_auto_config(struct hda_codec *codec)
12436{
12437 struct alc_spec *spec = codec->spec;
12438 int err;
12439 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12440
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012441 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12442 alc262_ignore);
12443 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012444 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012445 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012446 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012447 spec->multiout.max_channels = 2;
12448 spec->no_analog = 1;
12449 goto dig_only;
12450 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012451 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012452 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012453 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12454 if (err < 0)
12455 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012456 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012457 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012458 return err;
12459
12460 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12461
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012462 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012463 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012464
Takashi Iwai603c4012008-07-30 15:01:44 +020012465 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012466 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012467
Takashi Iwaid88897e2008-10-31 15:01:37 +010012468 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012469 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012470 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012471
Takashi Iwai776e1842007-08-29 15:07:11 +020012472 err = alc_auto_add_mic_boost(codec);
12473 if (err < 0)
12474 return err;
12475
Kailang Yang6227cdc2010-02-25 08:36:52 +010012476 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012477
Kailang Yangdf694da2005-12-05 19:42:22 +010012478 return 1;
12479}
12480
12481#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12482#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12483#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012484#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012485
12486
12487/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012488static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012489{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012490 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012491 alc262_auto_init_multi_out(codec);
12492 alc262_auto_init_hp_out(codec);
12493 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012494 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012495 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012496 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012497 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012498}
12499
12500/*
12501 * configuration and preset
12502 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012503static const char *alc262_models[ALC262_MODEL_LAST] = {
12504 [ALC262_BASIC] = "basic",
12505 [ALC262_HIPPO] = "hippo",
12506 [ALC262_HIPPO_1] = "hippo_1",
12507 [ALC262_FUJITSU] = "fujitsu",
12508 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012509 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012510 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012511 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012512 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012513 [ALC262_BENQ_T31] = "benq-t31",
12514 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012515 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012516 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012517 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012518 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012519 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012520 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012521 [ALC262_AUTO] = "auto",
12522};
12523
12524static struct snd_pci_quirk alc262_cfg_tbl[] = {
12525 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012526 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012527 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12528 ALC262_HP_BPC),
12529 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12530 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012531 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12532 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012533 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012534 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012535 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012536 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012537 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012538 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012539 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012540 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012541 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12542 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12543 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012544 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12545 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012546 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012547 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012548 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012549 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012550 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012551 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012552 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012553 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012554#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012555 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12556 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012557#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012558 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012559 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012560 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012561 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012562 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012563 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012564 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12565 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012566 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012567 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012568 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012569 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012570 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012571 {}
12572};
12573
12574static struct alc_config_preset alc262_presets[] = {
12575 [ALC262_BASIC] = {
12576 .mixers = { alc262_base_mixer },
12577 .init_verbs = { alc262_init_verbs },
12578 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12579 .dac_nids = alc262_dac_nids,
12580 .hp_nid = 0x03,
12581 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12582 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012583 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012584 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012585 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012586 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012587 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012588 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12589 .dac_nids = alc262_dac_nids,
12590 .hp_nid = 0x03,
12591 .dig_out_nid = ALC262_DIGOUT_NID,
12592 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12593 .channel_mode = alc262_modes,
12594 .input_mux = &alc262_capture_source,
12595 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012596 .setup = alc262_hippo_setup,
12597 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012598 },
12599 [ALC262_HIPPO_1] = {
12600 .mixers = { alc262_hippo1_mixer },
12601 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12602 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12603 .dac_nids = alc262_dac_nids,
12604 .hp_nid = 0x02,
12605 .dig_out_nid = ALC262_DIGOUT_NID,
12606 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12607 .channel_mode = alc262_modes,
12608 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012609 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012610 .setup = alc262_hippo1_setup,
12611 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012612 },
Takashi Iwai834be882006-03-01 14:16:17 +010012613 [ALC262_FUJITSU] = {
12614 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012615 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12616 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012617 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12618 .dac_nids = alc262_dac_nids,
12619 .hp_nid = 0x03,
12620 .dig_out_nid = ALC262_DIGOUT_NID,
12621 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12622 .channel_mode = alc262_modes,
12623 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012624 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012625 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012626 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012627 [ALC262_HP_BPC] = {
12628 .mixers = { alc262_HP_BPC_mixer },
12629 .init_verbs = { alc262_HP_BPC_init_verbs },
12630 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12631 .dac_nids = alc262_dac_nids,
12632 .hp_nid = 0x03,
12633 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12634 .channel_mode = alc262_modes,
12635 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012636 .unsol_event = alc262_hp_bpc_unsol_event,
12637 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012638 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012639 [ALC262_HP_BPC_D7000_WF] = {
12640 .mixers = { alc262_HP_BPC_WildWest_mixer },
12641 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12642 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12643 .dac_nids = alc262_dac_nids,
12644 .hp_nid = 0x03,
12645 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12646 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012647 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012648 .unsol_event = alc262_hp_wildwest_unsol_event,
12649 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012650 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012651 [ALC262_HP_BPC_D7000_WL] = {
12652 .mixers = { alc262_HP_BPC_WildWest_mixer,
12653 alc262_HP_BPC_WildWest_option_mixer },
12654 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12655 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12656 .dac_nids = alc262_dac_nids,
12657 .hp_nid = 0x03,
12658 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12659 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012660 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012661 .unsol_event = alc262_hp_wildwest_unsol_event,
12662 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012663 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012664 [ALC262_HP_TC_T5735] = {
12665 .mixers = { alc262_hp_t5735_mixer },
12666 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12667 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12668 .dac_nids = alc262_dac_nids,
12669 .hp_nid = 0x03,
12670 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12671 .channel_mode = alc262_modes,
12672 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012673 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012674 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012675 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012676 },
12677 [ALC262_HP_RP5700] = {
12678 .mixers = { alc262_hp_rp5700_mixer },
12679 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12680 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12681 .dac_nids = alc262_dac_nids,
12682 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12683 .channel_mode = alc262_modes,
12684 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012685 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012686 [ALC262_BENQ_ED8] = {
12687 .mixers = { alc262_base_mixer },
12688 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12689 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12690 .dac_nids = alc262_dac_nids,
12691 .hp_nid = 0x03,
12692 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12693 .channel_mode = alc262_modes,
12694 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012695 },
Kailang Yang272a5272007-05-14 11:00:38 +020012696 [ALC262_SONY_ASSAMD] = {
12697 .mixers = { alc262_sony_mixer },
12698 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12699 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12700 .dac_nids = alc262_dac_nids,
12701 .hp_nid = 0x02,
12702 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12703 .channel_mode = alc262_modes,
12704 .input_mux = &alc262_capture_source,
12705 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012706 .setup = alc262_hippo_setup,
12707 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012708 },
12709 [ALC262_BENQ_T31] = {
12710 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012711 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12712 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012713 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12714 .dac_nids = alc262_dac_nids,
12715 .hp_nid = 0x03,
12716 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12717 .channel_mode = alc262_modes,
12718 .input_mux = &alc262_capture_source,
12719 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012720 .setup = alc262_hippo_setup,
12721 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012722 },
Tobin Davisf651b502007-10-26 12:40:47 +020012723 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012724 .mixers = { alc262_ultra_mixer },
12725 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012726 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012727 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12728 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012729 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12730 .channel_mode = alc262_modes,
12731 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012732 .adc_nids = alc262_adc_nids, /* ADC0 */
12733 .capsrc_nids = alc262_capsrc_nids,
12734 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012735 .unsol_event = alc262_ultra_unsol_event,
12736 .init_hook = alc262_ultra_automute,
12737 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012738 [ALC262_LENOVO_3000] = {
12739 .mixers = { alc262_lenovo_3000_mixer },
12740 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012741 alc262_lenovo_3000_unsol_verbs,
12742 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012743 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12744 .dac_nids = alc262_dac_nids,
12745 .hp_nid = 0x03,
12746 .dig_out_nid = ALC262_DIGOUT_NID,
12747 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12748 .channel_mode = alc262_modes,
12749 .input_mux = &alc262_fujitsu_capture_source,
12750 .unsol_event = alc262_lenovo_3000_unsol_event,
12751 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012752 [ALC262_NEC] = {
12753 .mixers = { alc262_nec_mixer },
12754 .init_verbs = { alc262_nec_verbs },
12755 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12756 .dac_nids = alc262_dac_nids,
12757 .hp_nid = 0x03,
12758 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12759 .channel_mode = alc262_modes,
12760 .input_mux = &alc262_capture_source,
12761 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012762 [ALC262_TOSHIBA_S06] = {
12763 .mixers = { alc262_toshiba_s06_mixer },
12764 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12765 alc262_eapd_verbs },
12766 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12767 .capsrc_nids = alc262_dmic_capsrc_nids,
12768 .dac_nids = alc262_dac_nids,
12769 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012770 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012771 .dig_out_nid = ALC262_DIGOUT_NID,
12772 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12773 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012774 .unsol_event = alc_sku_unsol_event,
12775 .setup = alc262_toshiba_s06_setup,
12776 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012777 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012778 [ALC262_TOSHIBA_RX1] = {
12779 .mixers = { alc262_toshiba_rx1_mixer },
12780 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12781 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12782 .dac_nids = alc262_dac_nids,
12783 .hp_nid = 0x03,
12784 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12785 .channel_mode = alc262_modes,
12786 .input_mux = &alc262_capture_source,
12787 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012788 .setup = alc262_hippo_setup,
12789 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012790 },
Tony Vroonba340e82009-02-02 19:01:30 +000012791 [ALC262_TYAN] = {
12792 .mixers = { alc262_tyan_mixer },
12793 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12794 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12795 .dac_nids = alc262_dac_nids,
12796 .hp_nid = 0x02,
12797 .dig_out_nid = ALC262_DIGOUT_NID,
12798 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12799 .channel_mode = alc262_modes,
12800 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012801 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012802 .setup = alc262_tyan_setup,
12803 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012804 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012805};
12806
12807static int patch_alc262(struct hda_codec *codec)
12808{
12809 struct alc_spec *spec;
12810 int board_config;
12811 int err;
12812
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012813 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012814 if (spec == NULL)
12815 return -ENOMEM;
12816
12817 codec->spec = spec;
12818#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012819 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12820 * under-run
12821 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012822 {
12823 int tmp;
12824 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12825 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12826 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12827 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12828 }
12829#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012830 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012831
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012832 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12833
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012834 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12835 alc262_models,
12836 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012837
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012838 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012839 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12840 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012841 board_config = ALC262_AUTO;
12842 }
12843
Takashi Iwai18675e42010-09-08 15:55:44 +020012844 if (board_config == ALC262_AUTO)
12845 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 1);
12846
Kailang Yangdf694da2005-12-05 19:42:22 +010012847 if (board_config == ALC262_AUTO) {
12848 /* automatic parse from the BIOS config */
12849 err = alc262_parse_auto_config(codec);
12850 if (err < 0) {
12851 alc_free(codec);
12852 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012853 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012854 printk(KERN_INFO
12855 "hda_codec: Cannot set up configuration "
12856 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012857 board_config = ALC262_BASIC;
12858 }
12859 }
12860
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012861 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012862 err = snd_hda_attach_beep_device(codec, 0x1);
12863 if (err < 0) {
12864 alc_free(codec);
12865 return err;
12866 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012867 }
12868
Kailang Yangdf694da2005-12-05 19:42:22 +010012869 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012870 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012871
Kailang Yangdf694da2005-12-05 19:42:22 +010012872 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12873 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012874
Kailang Yangdf694da2005-12-05 19:42:22 +010012875 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12876 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12877
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012878 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012879 int i;
12880 /* check whether the digital-mic has to be supported */
12881 for (i = 0; i < spec->input_mux->num_items; i++) {
12882 if (spec->input_mux->items[i].index >= 9)
12883 break;
12884 }
12885 if (i < spec->input_mux->num_items) {
12886 /* use only ADC0 */
12887 spec->adc_nids = alc262_dmic_adc_nids;
12888 spec->num_adc_nids = 1;
12889 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012890 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012891 /* all analog inputs */
12892 /* check whether NID 0x07 is valid */
12893 unsigned int wcap = get_wcaps(codec, 0x07);
12894
12895 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012896 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012897 if (wcap != AC_WID_AUD_IN) {
12898 spec->adc_nids = alc262_adc_nids_alt;
12899 spec->num_adc_nids =
12900 ARRAY_SIZE(alc262_adc_nids_alt);
12901 spec->capsrc_nids = alc262_capsrc_nids_alt;
12902 } else {
12903 spec->adc_nids = alc262_adc_nids;
12904 spec->num_adc_nids =
12905 ARRAY_SIZE(alc262_adc_nids);
12906 spec->capsrc_nids = alc262_capsrc_nids;
12907 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012908 }
12909 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012910 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012911 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012912 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012913 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012914
Takashi Iwai18675e42010-09-08 15:55:44 +020012915 if (board_config == ALC262_AUTO)
12916 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 0);
12917
Takashi Iwai2134ea42008-01-10 16:53:55 +010012918 spec->vmaster_nid = 0x0c;
12919
Kailang Yangdf694da2005-12-05 19:42:22 +010012920 codec->patch_ops = alc_patch_ops;
12921 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012922 spec->init_hook = alc262_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020012923
12924 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020012925#ifdef CONFIG_SND_HDA_POWER_SAVE
12926 if (!spec->loopback.amplist)
12927 spec->loopback.amplist = alc262_loopbacks;
12928#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012929
Kailang Yangdf694da2005-12-05 19:42:22 +010012930 return 0;
12931}
12932
Kailang Yangdf694da2005-12-05 19:42:22 +010012933/*
Kailang Yanga361d842007-06-05 12:30:55 +020012934 * ALC268 channel source setting (2 channel)
12935 */
12936#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12937#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012938
Kailang Yanga361d842007-06-05 12:30:55 +020012939static hda_nid_t alc268_dac_nids[2] = {
12940 /* front, hp */
12941 0x02, 0x03
12942};
12943
12944static hda_nid_t alc268_adc_nids[2] = {
12945 /* ADC0-1 */
12946 0x08, 0x07
12947};
12948
12949static hda_nid_t alc268_adc_nids_alt[1] = {
12950 /* ADC0 */
12951 0x08
12952};
12953
Takashi Iwaie1406342008-02-11 18:32:32 +010012954static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12955
Kailang Yanga361d842007-06-05 12:30:55 +020012956static struct snd_kcontrol_new alc268_base_mixer[] = {
12957 /* output mixer control */
12958 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12959 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12960 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12961 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012962 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12963 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12964 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012965 { }
12966};
12967
Takashi Iwai42171c12009-05-08 14:11:43 +020012968static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12969 /* output mixer control */
12970 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12971 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12972 ALC262_HIPPO_MASTER_SWITCH,
12973 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12974 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12975 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12976 { }
12977};
12978
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012979/* bind Beep switches of both NID 0x0f and 0x10 */
12980static struct hda_bind_ctls alc268_bind_beep_sw = {
12981 .ops = &snd_hda_bind_sw,
12982 .values = {
12983 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12984 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12985 0
12986 },
12987};
12988
12989static struct snd_kcontrol_new alc268_beep_mixer[] = {
12990 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12991 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12992 { }
12993};
12994
Kailang Yangd1a991a2007-08-15 16:21:59 +020012995static struct hda_verb alc268_eapd_verbs[] = {
12996 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12997 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12998 { }
12999};
13000
Takashi Iwaid2738092007-08-16 14:59:45 +020013001/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020013002static struct hda_verb alc268_toshiba_verbs[] = {
13003 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13004 { } /* end */
13005};
13006
13007/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020013008/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020013009static struct hda_bind_ctls alc268_acer_bind_master_vol = {
13010 .ops = &snd_hda_bind_vol,
13011 .values = {
13012 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13013 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
13014 0
13015 },
13016};
13017
Takashi Iwai889c4392007-08-23 18:56:52 +020013018/* mute/unmute internal speaker according to the hp jack and mute state */
13019static void alc268_acer_automute(struct hda_codec *codec, int force)
13020{
13021 struct alc_spec *spec = codec->spec;
13022 unsigned int mute;
13023
13024 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080013025 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020013026 spec->sense_updated = 1;
13027 }
13028 if (spec->jack_present)
13029 mute = HDA_AMP_MUTE; /* mute internal speaker */
13030 else /* unmute internal speaker if necessary */
13031 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13032 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13033 HDA_AMP_MUTE, mute);
13034}
13035
13036
13037/* bind hp and internal speaker mute (with plug check) */
13038static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
13039 struct snd_ctl_elem_value *ucontrol)
13040{
13041 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
13042 long *valp = ucontrol->value.integer.value;
13043 int change;
13044
Takashi Iwai8de56b72009-07-24 16:51:47 +020013045 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020013046 if (change)
13047 alc268_acer_automute(codec, 0);
13048 return change;
13049}
Takashi Iwaid2738092007-08-16 14:59:45 +020013050
Kailang Yang8ef355d2008-08-26 13:10:22 +020013051static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
13052 /* output mixer control */
13053 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13054 {
13055 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13056 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013057 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013058 .info = snd_hda_mixer_amp_switch_info,
13059 .get = snd_hda_mixer_amp_switch_get,
13060 .put = alc268_acer_master_sw_put,
13061 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13062 },
13063 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13064 { }
13065};
13066
Takashi Iwaid2738092007-08-16 14:59:45 +020013067static struct snd_kcontrol_new alc268_acer_mixer[] = {
13068 /* output mixer control */
13069 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13070 {
13071 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13072 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013073 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013074 .info = snd_hda_mixer_amp_switch_info,
13075 .get = snd_hda_mixer_amp_switch_get,
13076 .put = alc268_acer_master_sw_put,
13077 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13078 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020013079 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13080 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13081 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013082 { }
13083};
13084
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013085static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13086 /* output mixer control */
13087 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13088 {
13089 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13090 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013091 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013092 .info = snd_hda_mixer_amp_switch_info,
13093 .get = snd_hda_mixer_amp_switch_get,
13094 .put = alc268_acer_master_sw_put,
13095 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13096 },
13097 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13098 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
13099 { }
13100};
13101
Kailang Yang8ef355d2008-08-26 13:10:22 +020013102static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13103 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13104 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13105 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13106 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13107 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13108 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13109 { }
13110};
13111
Takashi Iwaid2738092007-08-16 14:59:45 +020013112static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013113 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13114 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013115 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13116 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013117 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13118 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013119 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13120 { }
13121};
13122
13123/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013124#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013125#define alc268_toshiba_setup alc262_hippo_setup
13126#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013127
13128static void alc268_acer_unsol_event(struct hda_codec *codec,
13129 unsigned int res)
13130{
Takashi Iwai889c4392007-08-23 18:56:52 +020013131 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013132 return;
13133 alc268_acer_automute(codec, 1);
13134}
13135
Takashi Iwai889c4392007-08-23 18:56:52 +020013136static void alc268_acer_init_hook(struct hda_codec *codec)
13137{
13138 alc268_acer_automute(codec, 1);
13139}
13140
Kailang Yang8ef355d2008-08-26 13:10:22 +020013141/* toggle speaker-output according to the hp-jack state */
13142static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13143{
13144 unsigned int present;
13145 unsigned char bits;
13146
Wu Fengguang864f92b2009-11-18 12:38:02 +080013147 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013148 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013149 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013150 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013151 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013152 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013153}
13154
Kailang Yang8ef355d2008-08-26 13:10:22 +020013155static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13156 unsigned int res)
13157{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013158 switch (res >> 26) {
13159 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013160 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013161 break;
13162 case ALC880_MIC_EVENT:
13163 alc_mic_automute(codec);
13164 break;
13165 }
13166}
13167
13168static void alc268_acer_lc_setup(struct hda_codec *codec)
13169{
13170 struct alc_spec *spec = codec->spec;
13171 spec->ext_mic.pin = 0x18;
13172 spec->ext_mic.mux_idx = 0;
13173 spec->int_mic.pin = 0x12;
13174 spec->int_mic.mux_idx = 6;
13175 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013176}
13177
13178static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13179{
13180 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013181 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013182}
13183
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013184static struct snd_kcontrol_new alc268_dell_mixer[] = {
13185 /* output mixer control */
13186 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13187 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13188 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13189 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13190 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13191 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13192 { }
13193};
13194
13195static struct hda_verb alc268_dell_verbs[] = {
13196 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13197 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13198 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013199 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013200 { }
13201};
13202
13203/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013204static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013205{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013206 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013207
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013208 spec->autocfg.hp_pins[0] = 0x15;
13209 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013210 spec->ext_mic.pin = 0x18;
13211 spec->ext_mic.mux_idx = 0;
13212 spec->int_mic.pin = 0x19;
13213 spec->int_mic.mux_idx = 1;
13214 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013215}
13216
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013217static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13218 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13219 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13220 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13221 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13222 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13223 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
13224 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13225 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13226 { }
13227};
13228
13229static struct hda_verb alc267_quanta_il1_verbs[] = {
13230 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13231 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13232 { }
13233};
13234
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013235static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013236{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013237 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013238 spec->autocfg.hp_pins[0] = 0x15;
13239 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013240 spec->ext_mic.pin = 0x18;
13241 spec->ext_mic.mux_idx = 0;
13242 spec->int_mic.pin = 0x19;
13243 spec->int_mic.mux_idx = 1;
13244 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013245}
13246
Kailang Yanga361d842007-06-05 12:30:55 +020013247/*
13248 * generic initialization of ADC, input mixers and output mixers
13249 */
13250static struct hda_verb alc268_base_init_verbs[] = {
13251 /* Unmute DAC0-1 and set vol = 0 */
13252 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013253 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013254
13255 /*
13256 * Set up output mixers (0x0c - 0x0e)
13257 */
13258 /* set vol=0 to output mixers */
13259 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013260 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13261
13262 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13263 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13264
13265 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13266 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13267 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13268 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13269 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13270 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13271 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13272 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13273
13274 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13275 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13276 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13277 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013278 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013279
13280 /* set PCBEEP vol = 0, mute connections */
13281 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13282 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13283 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013284
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013285 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013286
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013287 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13288 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13289 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13290 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013291
Kailang Yanga361d842007-06-05 12:30:55 +020013292 { }
13293};
13294
13295/*
13296 * generic initialization of ADC, input mixers and output mixers
13297 */
13298static struct hda_verb alc268_volume_init_verbs[] = {
13299 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013300 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13301 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013302
13303 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13304 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13305 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13306 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13307 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13308
Kailang Yanga361d842007-06-05 12:30:55 +020013309 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013310 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13311 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13312
13313 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013315
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013316 /* set PCBEEP vol = 0, mute connections */
13317 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13318 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13319 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013320
13321 { }
13322};
13323
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013324static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13325 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13326 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13327 { } /* end */
13328};
13329
Kailang Yanga361d842007-06-05 12:30:55 +020013330static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13331 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13332 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013333 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013334 { } /* end */
13335};
13336
13337static struct snd_kcontrol_new alc268_capture_mixer[] = {
13338 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13339 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13340 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13341 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013342 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013343 { } /* end */
13344};
13345
13346static struct hda_input_mux alc268_capture_source = {
13347 .num_items = 4,
13348 .items = {
13349 { "Mic", 0x0 },
13350 { "Front Mic", 0x1 },
13351 { "Line", 0x2 },
13352 { "CD", 0x3 },
13353 },
13354};
13355
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013356static struct hda_input_mux alc268_acer_capture_source = {
13357 .num_items = 3,
13358 .items = {
13359 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013360 { "Internal Mic", 0x1 },
13361 { "Line", 0x2 },
13362 },
13363};
13364
13365static struct hda_input_mux alc268_acer_dmic_capture_source = {
13366 .num_items = 3,
13367 .items = {
13368 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013369 { "Internal Mic", 0x6 },
13370 { "Line", 0x2 },
13371 },
13372};
13373
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013374#ifdef CONFIG_SND_DEBUG
13375static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013376 /* Volume widgets */
13377 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13378 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13379 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13380 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13381 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13382 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13383 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13384 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13385 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13386 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13387 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13388 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13389 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013390 /* The below appears problematic on some hardwares */
13391 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013392 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13393 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13394 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13395 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13396
13397 /* Modes for retasking pin widgets */
13398 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13399 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13400 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13401 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13402
13403 /* Controls for GPIO pins, assuming they are configured as outputs */
13404 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13405 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13406 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13407 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13408
13409 /* Switches to allow the digital SPDIF output pin to be enabled.
13410 * The ALC268 does not have an SPDIF input.
13411 */
13412 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13413
13414 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13415 * this output to turn on an external amplifier.
13416 */
13417 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13418 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13419
13420 { } /* end */
13421};
13422#endif
13423
Kailang Yanga361d842007-06-05 12:30:55 +020013424/* create input playback/capture controls for the given pin */
13425static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13426 const char *ctlname, int idx)
13427{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013428 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013429 int err;
13430
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013431 switch (nid) {
13432 case 0x14:
13433 case 0x16:
13434 dac = 0x02;
13435 break;
13436 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013437 case 0x1a: /* ALC259/269 only */
13438 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013439 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013440 dac = 0x03;
13441 break;
13442 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013443 snd_printd(KERN_WARNING "hda_codec: "
13444 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013445 return 0;
13446 }
13447 if (spec->multiout.dac_nids[0] != dac &&
13448 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013449 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013450 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013451 HDA_OUTPUT));
13452 if (err < 0)
13453 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013454 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13455 }
13456
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013457 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013458 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013459 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013460 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013461 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013462 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013463 if (err < 0)
13464 return err;
13465 return 0;
13466}
13467
13468/* add playback controls from the parsed DAC table */
13469static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13470 const struct auto_pin_cfg *cfg)
13471{
13472 hda_nid_t nid;
13473 int err;
13474
Kailang Yanga361d842007-06-05 12:30:55 +020013475 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013476
13477 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013478 if (nid) {
13479 const char *name;
13480 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13481 name = "Speaker";
13482 else
13483 name = "Front";
13484 err = alc268_new_analog_output(spec, nid, name, 0);
13485 if (err < 0)
13486 return err;
13487 }
Kailang Yanga361d842007-06-05 12:30:55 +020013488
13489 nid = cfg->speaker_pins[0];
13490 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013491 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013492 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13493 if (err < 0)
13494 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013495 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013496 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13497 if (err < 0)
13498 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013499 }
13500 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013501 if (nid) {
13502 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13503 if (err < 0)
13504 return err;
13505 }
Kailang Yanga361d842007-06-05 12:30:55 +020013506
13507 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13508 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013509 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013510 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013511 if (err < 0)
13512 return err;
13513 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013514 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013515}
13516
13517/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013518static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013519 const struct auto_pin_cfg *cfg)
13520{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013521 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013522}
13523
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013524static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13525 hda_nid_t nid, int pin_type)
13526{
13527 int idx;
13528
13529 alc_set_pin_output(codec, nid, pin_type);
13530 if (nid == 0x14 || nid == 0x16)
13531 idx = 0;
13532 else
13533 idx = 1;
13534 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13535}
13536
13537static void alc268_auto_init_multi_out(struct hda_codec *codec)
13538{
13539 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013540 int i;
13541
13542 for (i = 0; i < spec->autocfg.line_outs; i++) {
13543 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013544 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13545 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13546 }
13547}
13548
13549static void alc268_auto_init_hp_out(struct hda_codec *codec)
13550{
13551 struct alc_spec *spec = codec->spec;
13552 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013553 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013554
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013555 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13556 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013557 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013558 }
13559 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13560 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013561 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013562 }
13563 if (spec->autocfg.mono_out_pin)
13564 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13565 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013566}
13567
Kailang Yanga361d842007-06-05 12:30:55 +020013568static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13569{
13570 struct alc_spec *spec = codec->spec;
13571 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13572 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13573 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13574 unsigned int dac_vol1, dac_vol2;
13575
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013576 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013577 snd_hda_codec_write(codec, speaker_nid, 0,
13578 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013579 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013580 snd_hda_codec_write(codec, 0x0f, 0,
13581 AC_VERB_SET_AMP_GAIN_MUTE,
13582 AMP_IN_UNMUTE(1));
13583 snd_hda_codec_write(codec, 0x10, 0,
13584 AC_VERB_SET_AMP_GAIN_MUTE,
13585 AMP_IN_UNMUTE(1));
13586 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013587 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013588 snd_hda_codec_write(codec, 0x0f, 0,
13589 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13590 snd_hda_codec_write(codec, 0x10, 0,
13591 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13592 }
13593
13594 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013595 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013596 dac_vol2 = AMP_OUT_ZERO;
13597 else if (line_nid == 0x15)
13598 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013599 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013600 dac_vol2 = AMP_OUT_ZERO;
13601 else if (hp_nid == 0x15)
13602 dac_vol1 = AMP_OUT_ZERO;
13603 if (line_nid != 0x16 || hp_nid != 0x16 ||
13604 spec->autocfg.line_out_pins[1] != 0x16 ||
13605 spec->autocfg.line_out_pins[2] != 0x16)
13606 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13607
13608 snd_hda_codec_write(codec, 0x02, 0,
13609 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13610 snd_hda_codec_write(codec, 0x03, 0,
13611 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13612}
13613
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013614/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013615#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13616#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013617#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013618#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13619
13620/*
13621 * BIOS auto configuration
13622 */
13623static int alc268_parse_auto_config(struct hda_codec *codec)
13624{
13625 struct alc_spec *spec = codec->spec;
13626 int err;
13627 static hda_nid_t alc268_ignore[] = { 0 };
13628
13629 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13630 alc268_ignore);
13631 if (err < 0)
13632 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013633 if (!spec->autocfg.line_outs) {
13634 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13635 spec->multiout.max_channels = 2;
13636 spec->no_analog = 1;
13637 goto dig_only;
13638 }
Kailang Yanga361d842007-06-05 12:30:55 +020013639 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013640 }
Kailang Yanga361d842007-06-05 12:30:55 +020013641 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13642 if (err < 0)
13643 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013644 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013645 if (err < 0)
13646 return err;
13647
13648 spec->multiout.max_channels = 2;
13649
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013650 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013651 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013652 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013653 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013654 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013655
Takashi Iwai892981f2009-03-02 08:04:35 +010013656 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013657 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013658
Takashi Iwaid88897e2008-10-31 15:01:37 +010013659 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013660 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013661 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013662
Takashi Iwai776e1842007-08-29 15:07:11 +020013663 err = alc_auto_add_mic_boost(codec);
13664 if (err < 0)
13665 return err;
13666
Kailang Yang6227cdc2010-02-25 08:36:52 +010013667 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013668
Kailang Yanga361d842007-06-05 12:30:55 +020013669 return 1;
13670}
13671
Kailang Yanga361d842007-06-05 12:30:55 +020013672#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13673
13674/* init callback for auto-configuration model -- overriding the default init */
13675static void alc268_auto_init(struct hda_codec *codec)
13676{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013677 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013678 alc268_auto_init_multi_out(codec);
13679 alc268_auto_init_hp_out(codec);
13680 alc268_auto_init_mono_speaker_out(codec);
13681 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013682 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013683 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013684 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013685}
13686
13687/*
13688 * configuration and preset
13689 */
13690static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013691 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013692 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013693 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013694 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013695 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013696 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013697 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013698 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013699#ifdef CONFIG_SND_DEBUG
13700 [ALC268_TEST] = "test",
13701#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013702 [ALC268_AUTO] = "auto",
13703};
13704
13705static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013706 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013707 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013708 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013709 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013710 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013711 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13712 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013713 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013714 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13715 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013716 /* almost compatible with toshiba but with optional digital outs;
13717 * auto-probing seems working fine
13718 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013719 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013720 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013721 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013722 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013723 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013724 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013725 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013726 {}
13727};
13728
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013729/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13730static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13731 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13732 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13733 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13734 ALC268_TOSHIBA),
13735 {}
13736};
13737
Kailang Yanga361d842007-06-05 12:30:55 +020013738static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013739 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013740 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13741 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013742 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13743 alc267_quanta_il1_verbs },
13744 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13745 .dac_nids = alc268_dac_nids,
13746 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13747 .adc_nids = alc268_adc_nids_alt,
13748 .hp_nid = 0x03,
13749 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13750 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013751 .unsol_event = alc_sku_unsol_event,
13752 .setup = alc267_quanta_il1_setup,
13753 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013754 },
Kailang Yanga361d842007-06-05 12:30:55 +020013755 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013756 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13757 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013758 .init_verbs = { alc268_base_init_verbs },
13759 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13760 .dac_nids = alc268_dac_nids,
13761 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13762 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013763 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013764 .hp_nid = 0x03,
13765 .dig_out_nid = ALC268_DIGOUT_NID,
13766 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13767 .channel_mode = alc268_modes,
13768 .input_mux = &alc268_capture_source,
13769 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013770 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013771 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013772 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013773 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13774 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013775 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13776 .dac_nids = alc268_dac_nids,
13777 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13778 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013779 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013780 .hp_nid = 0x03,
13781 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13782 .channel_mode = alc268_modes,
13783 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013784 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013785 .setup = alc268_toshiba_setup,
13786 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013787 },
13788 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013789 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013790 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013791 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13792 alc268_acer_verbs },
13793 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13794 .dac_nids = alc268_dac_nids,
13795 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13796 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013797 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013798 .hp_nid = 0x02,
13799 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13800 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013801 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013802 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013803 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013804 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013805 [ALC268_ACER_DMIC] = {
13806 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13807 alc268_beep_mixer },
13808 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13809 alc268_acer_verbs },
13810 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13811 .dac_nids = alc268_dac_nids,
13812 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13813 .adc_nids = alc268_adc_nids_alt,
13814 .capsrc_nids = alc268_capsrc_nids,
13815 .hp_nid = 0x02,
13816 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13817 .channel_mode = alc268_modes,
13818 .input_mux = &alc268_acer_dmic_capture_source,
13819 .unsol_event = alc268_acer_unsol_event,
13820 .init_hook = alc268_acer_init_hook,
13821 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013822 [ALC268_ACER_ASPIRE_ONE] = {
13823 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013824 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013825 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013826 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13827 alc268_acer_aspire_one_verbs },
13828 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13829 .dac_nids = alc268_dac_nids,
13830 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13831 .adc_nids = alc268_adc_nids_alt,
13832 .capsrc_nids = alc268_capsrc_nids,
13833 .hp_nid = 0x03,
13834 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13835 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013836 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013837 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013838 .init_hook = alc268_acer_lc_init_hook,
13839 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013840 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013841 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13842 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013843 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13844 alc268_dell_verbs },
13845 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13846 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013847 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13848 .adc_nids = alc268_adc_nids_alt,
13849 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013850 .hp_nid = 0x02,
13851 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13852 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013853 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013854 .setup = alc268_dell_setup,
13855 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013856 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013857 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013858 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13859 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013860 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13861 alc268_toshiba_verbs },
13862 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13863 .dac_nids = alc268_dac_nids,
13864 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13865 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013866 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013867 .hp_nid = 0x03,
13868 .dig_out_nid = ALC268_DIGOUT_NID,
13869 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13870 .channel_mode = alc268_modes,
13871 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013872 .setup = alc268_toshiba_setup,
13873 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013874 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013875#ifdef CONFIG_SND_DEBUG
13876 [ALC268_TEST] = {
13877 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13878 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13879 alc268_volume_init_verbs },
13880 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13881 .dac_nids = alc268_dac_nids,
13882 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13883 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013884 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013885 .hp_nid = 0x03,
13886 .dig_out_nid = ALC268_DIGOUT_NID,
13887 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13888 .channel_mode = alc268_modes,
13889 .input_mux = &alc268_capture_source,
13890 },
13891#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013892};
13893
13894static int patch_alc268(struct hda_codec *codec)
13895{
13896 struct alc_spec *spec;
13897 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013898 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013899
Julia Lawallef86f582009-12-19 08:18:03 +010013900 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013901 if (spec == NULL)
13902 return -ENOMEM;
13903
13904 codec->spec = spec;
13905
13906 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13907 alc268_models,
13908 alc268_cfg_tbl);
13909
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013910 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13911 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013912 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013913
Kailang Yanga361d842007-06-05 12:30:55 +020013914 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013915 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13916 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013917 board_config = ALC268_AUTO;
13918 }
13919
13920 if (board_config == ALC268_AUTO) {
13921 /* automatic parse from the BIOS config */
13922 err = alc268_parse_auto_config(codec);
13923 if (err < 0) {
13924 alc_free(codec);
13925 return err;
13926 } else if (!err) {
13927 printk(KERN_INFO
13928 "hda_codec: Cannot set up configuration "
13929 "from BIOS. Using base mode...\n");
13930 board_config = ALC268_3ST;
13931 }
13932 }
13933
13934 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013935 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013936
Kailang Yanga361d842007-06-05 12:30:55 +020013937 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13938 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013939 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013940
Kailang Yanga361d842007-06-05 12:30:55 +020013941 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13942
Takashi Iwai22971e32009-02-10 11:56:44 +010013943 has_beep = 0;
13944 for (i = 0; i < spec->num_mixers; i++) {
13945 if (spec->mixers[i] == alc268_beep_mixer) {
13946 has_beep = 1;
13947 break;
13948 }
13949 }
13950
13951 if (has_beep) {
13952 err = snd_hda_attach_beep_device(codec, 0x1);
13953 if (err < 0) {
13954 alc_free(codec);
13955 return err;
13956 }
13957 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13958 /* override the amp caps for beep generator */
13959 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013960 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13961 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13962 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13963 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013964 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013965
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013966 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013967 /* check whether NID 0x07 is valid */
13968 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013969 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013970
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013971 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013972 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013973 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013974 if (spec->auto_mic ||
13975 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013976 spec->adc_nids = alc268_adc_nids_alt;
13977 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013978 if (spec->auto_mic)
13979 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013980 if (spec->auto_mic || spec->input_mux->num_items == 1)
13981 add_mixer(spec, alc268_capture_nosrc_mixer);
13982 else
13983 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013984 } else {
13985 spec->adc_nids = alc268_adc_nids;
13986 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013987 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013988 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013989 /* set default input source */
13990 for (i = 0; i < spec->num_adc_nids; i++)
13991 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13992 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013993 i < spec->num_mux_defs ?
13994 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013995 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013996 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013997
13998 spec->vmaster_nid = 0x02;
13999
Kailang Yanga361d842007-06-05 12:30:55 +020014000 codec->patch_ops = alc_patch_ops;
14001 if (board_config == ALC268_AUTO)
14002 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020014003
Kailang Yangbf1b0222010-10-21 08:49:56 +020014004 alc_init_jacks(codec);
14005
Kailang Yanga361d842007-06-05 12:30:55 +020014006 return 0;
14007}
14008
14009/*
Kailang Yangf6a92242007-12-13 16:52:54 +010014010 * ALC269 channel source setting (2 channel)
14011 */
14012#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
14013
14014#define alc269_dac_nids alc260_dac_nids
14015
14016static hda_nid_t alc269_adc_nids[1] = {
14017 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020014018 0x08,
14019};
14020
Takashi Iwaie01bf502008-08-21 16:25:07 +020014021static hda_nid_t alc269_capsrc_nids[1] = {
14022 0x23,
14023};
14024
Kailang Yang84898e82010-02-04 14:16:14 +010014025static hda_nid_t alc269vb_adc_nids[1] = {
14026 /* ADC1 */
14027 0x09,
14028};
14029
14030static hda_nid_t alc269vb_capsrc_nids[1] = {
14031 0x22,
14032};
14033
Takashi Iwai66946352010-03-29 17:21:45 +020014034static hda_nid_t alc269_adc_candidates[] = {
14035 0x08, 0x09, 0x07,
14036};
Takashi Iwaie01bf502008-08-21 16:25:07 +020014037
Kailang Yangf6a92242007-12-13 16:52:54 +010014038#define alc269_modes alc260_modes
14039#define alc269_capture_source alc880_lg_lw_capture_source
14040
14041static struct snd_kcontrol_new alc269_base_mixer[] = {
14042 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14043 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14044 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14045 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14046 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14047 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14048 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14049 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14050 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14051 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14052 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14053 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14054 { } /* end */
14055};
14056
Kailang Yang60db6b52008-08-26 13:13:00 +020014057static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14058 /* output mixer control */
14059 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14060 {
14061 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14062 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014063 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014064 .info = snd_hda_mixer_amp_switch_info,
14065 .get = snd_hda_mixer_amp_switch_get,
14066 .put = alc268_acer_master_sw_put,
14067 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14068 },
14069 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14070 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14071 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14072 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14073 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14074 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014075 { }
14076};
14077
Tony Vroon64154832008-11-06 15:08:49 +000014078static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14079 /* output mixer control */
14080 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14081 {
14082 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14083 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014084 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014085 .info = snd_hda_mixer_amp_switch_info,
14086 .get = snd_hda_mixer_amp_switch_get,
14087 .put = alc268_acer_master_sw_put,
14088 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14089 },
14090 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14091 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14092 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14093 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14094 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14095 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
14096 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14097 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
14098 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014099 { }
14100};
14101
Kailang Yang84898e82010-02-04 14:16:14 +010014102static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014103 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014104 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014105 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014106 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014107 { } /* end */
14108};
14109
Kailang Yang84898e82010-02-04 14:16:14 +010014110static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14111 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14112 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14113 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14114 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14115 { } /* end */
14116};
14117
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014118static struct snd_kcontrol_new alc269_asus_mixer[] = {
14119 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14120 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14121 { } /* end */
14122};
14123
Kailang Yangf6a92242007-12-13 16:52:54 +010014124/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014125static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14126 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14127 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
14128 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14129 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14130 { } /* end */
14131};
14132
14133static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014134 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14135 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014136 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14137 { } /* end */
14138};
14139
Kailang Yang84898e82010-02-04 14:16:14 +010014140static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14141 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14142 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14143 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14144 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14145 { } /* end */
14146};
14147
14148static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14149 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14150 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14151 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14152 { } /* end */
14153};
14154
Takashi Iwai26f5df22008-11-03 17:39:46 +010014155/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014156#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014157
Kailang Yang60db6b52008-08-26 13:13:00 +020014158static struct hda_verb alc269_quanta_fl1_verbs[] = {
14159 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14160 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14161 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14162 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14163 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14164 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14165 { }
14166};
14167
Tony Vroon64154832008-11-06 15:08:49 +000014168static struct hda_verb alc269_lifebook_verbs[] = {
14169 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14170 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14171 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14172 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14173 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14174 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14175 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14176 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14177 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14178 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14179 { }
14180};
14181
Kailang Yang60db6b52008-08-26 13:13:00 +020014182/* toggle speaker-output according to the hp-jack state */
14183static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14184{
14185 unsigned int present;
14186 unsigned char bits;
14187
Wu Fengguang864f92b2009-11-18 12:38:02 +080014188 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014189 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014190 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014191 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014192 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014193 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014194
14195 snd_hda_codec_write(codec, 0x20, 0,
14196 AC_VERB_SET_COEF_INDEX, 0x0c);
14197 snd_hda_codec_write(codec, 0x20, 0,
14198 AC_VERB_SET_PROC_COEF, 0x680);
14199
14200 snd_hda_codec_write(codec, 0x20, 0,
14201 AC_VERB_SET_COEF_INDEX, 0x0c);
14202 snd_hda_codec_write(codec, 0x20, 0,
14203 AC_VERB_SET_PROC_COEF, 0x480);
14204}
14205
Tony Vroon64154832008-11-06 15:08:49 +000014206/* toggle speaker-output according to the hp-jacks state */
14207static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14208{
14209 unsigned int present;
14210 unsigned char bits;
14211
14212 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014213 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014214
14215 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014216 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014217
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014218 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014219 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014220 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014221 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014222 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014223
14224 snd_hda_codec_write(codec, 0x20, 0,
14225 AC_VERB_SET_COEF_INDEX, 0x0c);
14226 snd_hda_codec_write(codec, 0x20, 0,
14227 AC_VERB_SET_PROC_COEF, 0x680);
14228
14229 snd_hda_codec_write(codec, 0x20, 0,
14230 AC_VERB_SET_COEF_INDEX, 0x0c);
14231 snd_hda_codec_write(codec, 0x20, 0,
14232 AC_VERB_SET_PROC_COEF, 0x480);
14233}
14234
Tony Vroon64154832008-11-06 15:08:49 +000014235static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14236{
14237 unsigned int present_laptop;
14238 unsigned int present_dock;
14239
Wu Fengguang864f92b2009-11-18 12:38:02 +080014240 present_laptop = snd_hda_jack_detect(codec, 0x18);
14241 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014242
14243 /* Laptop mic port overrides dock mic port, design decision */
14244 if (present_dock)
14245 snd_hda_codec_write(codec, 0x23, 0,
14246 AC_VERB_SET_CONNECT_SEL, 0x3);
14247 if (present_laptop)
14248 snd_hda_codec_write(codec, 0x23, 0,
14249 AC_VERB_SET_CONNECT_SEL, 0x0);
14250 if (!present_dock && !present_laptop)
14251 snd_hda_codec_write(codec, 0x23, 0,
14252 AC_VERB_SET_CONNECT_SEL, 0x1);
14253}
14254
Kailang Yang60db6b52008-08-26 13:13:00 +020014255static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14256 unsigned int res)
14257{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014258 switch (res >> 26) {
14259 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014260 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014261 break;
14262 case ALC880_MIC_EVENT:
14263 alc_mic_automute(codec);
14264 break;
14265 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014266}
14267
Tony Vroon64154832008-11-06 15:08:49 +000014268static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14269 unsigned int res)
14270{
14271 if ((res >> 26) == ALC880_HP_EVENT)
14272 alc269_lifebook_speaker_automute(codec);
14273 if ((res >> 26) == ALC880_MIC_EVENT)
14274 alc269_lifebook_mic_autoswitch(codec);
14275}
14276
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014277static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14278{
14279 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014280 spec->autocfg.hp_pins[0] = 0x15;
14281 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014282 spec->ext_mic.pin = 0x18;
14283 spec->ext_mic.mux_idx = 0;
14284 spec->int_mic.pin = 0x19;
14285 spec->int_mic.mux_idx = 1;
14286 spec->auto_mic = 1;
14287}
14288
Kailang Yang60db6b52008-08-26 13:13:00 +020014289static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14290{
14291 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014292 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014293}
14294
Tony Vroon64154832008-11-06 15:08:49 +000014295static void alc269_lifebook_init_hook(struct hda_codec *codec)
14296{
14297 alc269_lifebook_speaker_automute(codec);
14298 alc269_lifebook_mic_autoswitch(codec);
14299}
14300
Kailang Yang84898e82010-02-04 14:16:14 +010014301static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014302 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14303 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14304 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14305 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14306 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14307 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14308 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14309 {}
14310};
14311
Kailang Yang84898e82010-02-04 14:16:14 +010014312static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014313 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14314 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14315 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14316 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14317 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14318 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14319 {}
14320};
14321
Kailang Yang84898e82010-02-04 14:16:14 +010014322static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14323 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14324 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14325 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14326 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14327 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14328 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14329 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14330 {}
14331};
14332
14333static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14334 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14335 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14336 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14337 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14338 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14339 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14340 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14341 {}
14342};
14343
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014344static struct hda_verb alc271_acer_dmic_verbs[] = {
14345 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14346 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14347 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14348 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14349 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14350 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14351 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14352 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14353 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14354 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14355 { }
14356};
14357
Kailang Yang60db6b52008-08-26 13:13:00 +020014358/* toggle speaker-output according to the hp-jack state */
14359static void alc269_speaker_automute(struct hda_codec *codec)
14360{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014361 struct alc_spec *spec = codec->spec;
14362 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014363 unsigned int present;
14364 unsigned char bits;
14365
Kailang Yangebb83ee2009-12-17 12:23:00 +010014366 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014367 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014368 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014369 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014370 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014371 HDA_AMP_MUTE, bits);
Kailang Yangbf1b0222010-10-21 08:49:56 +020014372 alc_report_jack(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020014373}
14374
Kailang Yang60db6b52008-08-26 13:13:00 +020014375/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014376static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014377 unsigned int res)
14378{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014379 switch (res >> 26) {
14380 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014381 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014382 break;
14383 case ALC880_MIC_EVENT:
14384 alc_mic_automute(codec);
14385 break;
14386 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014387}
14388
Kailang Yang226b1ec2010-04-09 11:01:20 +020014389static void alc269_laptop_amic_setup(struct hda_codec *codec)
14390{
14391 struct alc_spec *spec = codec->spec;
14392 spec->autocfg.hp_pins[0] = 0x15;
14393 spec->autocfg.speaker_pins[0] = 0x14;
14394 spec->ext_mic.pin = 0x18;
14395 spec->ext_mic.mux_idx = 0;
14396 spec->int_mic.pin = 0x19;
14397 spec->int_mic.mux_idx = 1;
14398 spec->auto_mic = 1;
14399}
14400
Kailang Yang84898e82010-02-04 14:16:14 +010014401static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014402{
14403 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014404 spec->autocfg.hp_pins[0] = 0x15;
14405 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014406 spec->ext_mic.pin = 0x18;
14407 spec->ext_mic.mux_idx = 0;
14408 spec->int_mic.pin = 0x12;
14409 spec->int_mic.mux_idx = 5;
14410 spec->auto_mic = 1;
14411}
14412
Kailang Yang226b1ec2010-04-09 11:01:20 +020014413static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014414{
14415 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014416 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014417 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014418 spec->ext_mic.pin = 0x18;
14419 spec->ext_mic.mux_idx = 0;
14420 spec->int_mic.pin = 0x19;
14421 spec->int_mic.mux_idx = 1;
14422 spec->auto_mic = 1;
14423}
14424
Kailang Yang226b1ec2010-04-09 11:01:20 +020014425static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14426{
14427 struct alc_spec *spec = codec->spec;
14428 spec->autocfg.hp_pins[0] = 0x21;
14429 spec->autocfg.speaker_pins[0] = 0x14;
14430 spec->ext_mic.pin = 0x18;
14431 spec->ext_mic.mux_idx = 0;
14432 spec->int_mic.pin = 0x12;
14433 spec->int_mic.mux_idx = 6;
14434 spec->auto_mic = 1;
14435}
14436
Kailang Yang84898e82010-02-04 14:16:14 +010014437static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014438{
14439 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014440 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014441}
14442
Kailang Yangf6a92242007-12-13 16:52:54 +010014443/*
14444 * generic initialization of ADC, input mixers and output mixers
14445 */
14446static struct hda_verb alc269_init_verbs[] = {
14447 /*
14448 * Unmute ADC0 and set the default input to mic-in
14449 */
Kailang Yang84898e82010-02-04 14:16:14 +010014450 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014451
14452 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014453 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014454 */
14455 /* set vol=0 to output mixers */
14456 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14457 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14458
14459 /* set up input amps for analog loopback */
14460 /* Amp Indices: DAC = 0, mixer = 1 */
14461 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14463 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14464 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14465 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14466 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14467
14468 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14469 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14470 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14471 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14472 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14473 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14474 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14475
14476 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14477 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014478
Kailang Yang84898e82010-02-04 14:16:14 +010014479 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014480 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14481 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014482 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014483
14484 /* set EAPD */
14485 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014486 { }
14487};
14488
14489static struct hda_verb alc269vb_init_verbs[] = {
14490 /*
14491 * Unmute ADC0 and set the default input to mic-in
14492 */
14493 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14494
14495 /*
14496 * Set up output mixers (0x02 - 0x03)
14497 */
14498 /* set vol=0 to output mixers */
14499 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14500 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14501
14502 /* set up input amps for analog loopback */
14503 /* Amp Indices: DAC = 0, mixer = 1 */
14504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14505 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14506 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14507 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14508 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14509 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14510
14511 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14512 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14513 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14514 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14515 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14516 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14517 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14518
14519 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14520 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14521
14522 /* FIXME: use Mux-type input source selection */
14523 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14524 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14525 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14526
14527 /* set EAPD */
14528 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014529 { }
14530};
14531
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014532#define alc269_auto_create_multi_out_ctls \
14533 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014534#define alc269_auto_create_input_ctls \
14535 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014536
14537#ifdef CONFIG_SND_HDA_POWER_SAVE
14538#define alc269_loopbacks alc880_loopbacks
14539#endif
14540
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014541/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014542#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14543#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14544#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14545#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14546
Takashi Iwaif03d3112009-03-05 14:18:16 +010014547static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14548 .substreams = 1,
14549 .channels_min = 2,
14550 .channels_max = 8,
14551 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14552 /* NID is set in alc_build_pcms */
14553 .ops = {
14554 .open = alc880_playback_pcm_open,
14555 .prepare = alc880_playback_pcm_prepare,
14556 .cleanup = alc880_playback_pcm_cleanup
14557 },
14558};
14559
14560static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14561 .substreams = 1,
14562 .channels_min = 2,
14563 .channels_max = 2,
14564 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14565 /* NID is set in alc_build_pcms */
14566};
14567
Takashi Iwaiad358792010-03-30 18:00:59 +020014568#ifdef CONFIG_SND_HDA_POWER_SAVE
14569static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14570{
14571 switch (codec->subsystem_id) {
14572 case 0x103c1586:
14573 return 1;
14574 }
14575 return 0;
14576}
14577
14578static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14579{
14580 /* update mute-LED according to the speaker mute state */
14581 if (nid == 0x01 || nid == 0x14) {
14582 int pinval;
14583 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14584 HDA_AMP_MUTE)
14585 pinval = 0x24;
14586 else
14587 pinval = 0x20;
14588 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014589 snd_hda_codec_update_cache(codec, 0x19, 0,
14590 AC_VERB_SET_PIN_WIDGET_CONTROL,
14591 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014592 }
14593 return alc_check_power_status(codec, nid);
14594}
14595#endif /* CONFIG_SND_HDA_POWER_SAVE */
14596
Takashi Iwai840b64c2010-07-13 22:49:01 +020014597static int alc275_setup_dual_adc(struct hda_codec *codec)
14598{
14599 struct alc_spec *spec = codec->spec;
14600
14601 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14602 return 0;
14603 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14604 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14605 if (spec->ext_mic.pin <= 0x12) {
14606 spec->private_adc_nids[0] = 0x08;
14607 spec->private_adc_nids[1] = 0x11;
14608 spec->private_capsrc_nids[0] = 0x23;
14609 spec->private_capsrc_nids[1] = 0x22;
14610 } else {
14611 spec->private_adc_nids[0] = 0x11;
14612 spec->private_adc_nids[1] = 0x08;
14613 spec->private_capsrc_nids[0] = 0x22;
14614 spec->private_capsrc_nids[1] = 0x23;
14615 }
14616 spec->adc_nids = spec->private_adc_nids;
14617 spec->capsrc_nids = spec->private_capsrc_nids;
14618 spec->num_adc_nids = 2;
14619 spec->dual_adc_switch = 1;
14620 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14621 spec->adc_nids[0], spec->adc_nids[1]);
14622 return 1;
14623 }
14624 return 0;
14625}
14626
Takashi Iwaid433a672010-09-20 15:11:54 +020014627/* different alc269-variants */
14628enum {
14629 ALC269_TYPE_NORMAL,
Kailang Yang48c88e82010-11-23 08:56:16 +010014630 ALC269_TYPE_ALC258,
Takashi Iwaid433a672010-09-20 15:11:54 +020014631 ALC269_TYPE_ALC259,
Kailang Yang48c88e82010-11-23 08:56:16 +010014632 ALC269_TYPE_ALC269VB,
14633 ALC269_TYPE_ALC270,
Takashi Iwaid433a672010-09-20 15:11:54 +020014634 ALC269_TYPE_ALC271X,
14635};
14636
Kailang Yangf6a92242007-12-13 16:52:54 +010014637/*
14638 * BIOS auto configuration
14639 */
14640static int alc269_parse_auto_config(struct hda_codec *codec)
14641{
14642 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014643 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014644 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14645
14646 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14647 alc269_ignore);
14648 if (err < 0)
14649 return err;
14650
14651 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14652 if (err < 0)
14653 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014654 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14655 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14656 else
14657 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14658 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014659 if (err < 0)
14660 return err;
14661
14662 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14663
Takashi Iwai757899a2010-07-30 10:48:14 +020014664 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014665
Takashi Iwai603c4012008-07-30 15:01:44 +020014666 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014667 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014668
Takashi Iwaid433a672010-09-20 15:11:54 +020014669 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014670 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014671 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014672 } else {
14673 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014674 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014675 }
14676
Kailang Yangf6a92242007-12-13 16:52:54 +010014677 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014678 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014679
14680 if (!alc275_setup_dual_adc(codec))
14681 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14682 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014683
Takashi Iwaie01bf502008-08-21 16:25:07 +020014684 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014685 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014686 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14687 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014688
14689 err = alc_auto_add_mic_boost(codec);
14690 if (err < 0)
14691 return err;
14692
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014693 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014694 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014695
Kailang Yangf6a92242007-12-13 16:52:54 +010014696 return 1;
14697}
14698
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014699#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14700#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014701#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14702
14703
14704/* init callback for auto-configuration model -- overriding the default init */
14705static void alc269_auto_init(struct hda_codec *codec)
14706{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014707 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014708 alc269_auto_init_multi_out(codec);
14709 alc269_auto_init_hp_out(codec);
14710 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014711 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014712 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014713 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014714}
14715
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014716#ifdef SND_HDA_NEEDS_RESUME
14717static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14718{
14719 int val = alc_read_coef_idx(codec, 0x04);
14720 if (power_up)
14721 val |= 1 << 11;
14722 else
14723 val &= ~(1 << 11);
14724 alc_write_coef_idx(codec, 0x04, val);
14725}
14726
Kailang Yang977ddd62010-09-15 10:02:29 +020014727#ifdef CONFIG_SND_HDA_POWER_SAVE
14728static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14729{
14730 struct alc_spec *spec = codec->spec;
Kailang Yang977ddd62010-09-15 10:02:29 +020014731
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014732 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14733 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014734 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014735 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014736 msleep(150);
14737 }
14738
14739 alc_shutup(codec);
14740 if (spec && spec->power_hook)
14741 spec->power_hook(codec);
14742 return 0;
14743}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014744#endif /* CONFIG_SND_HDA_POWER_SAVE */
14745
Kailang Yang977ddd62010-09-15 10:02:29 +020014746static int alc269_resume(struct hda_codec *codec)
14747{
Kailang Yang977ddd62010-09-15 10:02:29 +020014748 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014749 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014750 msleep(150);
14751 }
14752
14753 codec->patch_ops.init(codec);
14754
14755 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014756 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014757 msleep(200);
14758 }
14759
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014760 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14761 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014762
14763 snd_hda_codec_resume_amp(codec);
14764 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014765 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014766 return 0;
14767}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014768#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014769
Takashi Iwaiff818c22010-04-12 08:59:25 +020014770enum {
14771 ALC269_FIXUP_SONY_VAIO,
David Henningsson145a9022010-09-16 10:07:53 +020014772 ALC269_FIXUP_DELL_M101Z,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014773};
14774
Takashi Iwaiff818c22010-04-12 08:59:25 +020014775static const struct alc_fixup alc269_fixups[] = {
14776 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020014777 .verbs = (const struct hda_verb[]) {
14778 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14779 {}
14780 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014781 },
David Henningsson145a9022010-09-16 10:07:53 +020014782 [ALC269_FIXUP_DELL_M101Z] = {
14783 .verbs = (const struct hda_verb[]) {
14784 /* Enables internal speaker */
14785 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14786 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14787 {}
14788 }
14789 },
Takashi Iwaiff818c22010-04-12 08:59:25 +020014790};
14791
14792static struct snd_pci_quirk alc269_fixup_tbl[] = {
Takashi Iwaiabdd8f52010-09-21 17:38:14 +020014793 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014794 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014795 {}
14796};
14797
14798
Kailang Yangf6a92242007-12-13 16:52:54 +010014799/*
14800 * configuration and preset
14801 */
14802static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014803 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014804 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014805 [ALC269_AMIC] = "laptop-amic",
14806 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014807 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014808 [ALC269_LIFEBOOK] = "lifebook",
14809 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014810};
14811
14812static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014813 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014814 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014815 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014816 ALC269_AMIC),
14817 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14818 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14819 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14820 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14821 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14822 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14823 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14824 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14825 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14826 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14827 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14828 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14829 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14830 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14831 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14832 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14833 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14834 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14835 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14836 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14837 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14838 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14839 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14840 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14841 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14842 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14843 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14844 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14845 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14846 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14847 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14848 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14849 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14850 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14851 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14852 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014853 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014854 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014855 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014856 ALC269_DMIC),
14857 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14858 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014859 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014860 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014861 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14862 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14863 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14864 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14865 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14866 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014867 {}
14868};
14869
14870static struct alc_config_preset alc269_presets[] = {
14871 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014872 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014873 .init_verbs = { alc269_init_verbs },
14874 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14875 .dac_nids = alc269_dac_nids,
14876 .hp_nid = 0x03,
14877 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14878 .channel_mode = alc269_modes,
14879 .input_mux = &alc269_capture_source,
14880 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014881 [ALC269_QUANTA_FL1] = {
14882 .mixers = { alc269_quanta_fl1_mixer },
14883 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14884 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14885 .dac_nids = alc269_dac_nids,
14886 .hp_nid = 0x03,
14887 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14888 .channel_mode = alc269_modes,
14889 .input_mux = &alc269_capture_source,
14890 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014891 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014892 .init_hook = alc269_quanta_fl1_init_hook,
14893 },
Kailang Yang84898e82010-02-04 14:16:14 +010014894 [ALC269_AMIC] = {
14895 .mixers = { alc269_laptop_mixer },
14896 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014897 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014898 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014899 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14900 .dac_nids = alc269_dac_nids,
14901 .hp_nid = 0x03,
14902 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14903 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014904 .unsol_event = alc269_laptop_unsol_event,
14905 .setup = alc269_laptop_amic_setup,
14906 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014907 },
Kailang Yang84898e82010-02-04 14:16:14 +010014908 [ALC269_DMIC] = {
14909 .mixers = { alc269_laptop_mixer },
14910 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014911 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014912 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014913 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14914 .dac_nids = alc269_dac_nids,
14915 .hp_nid = 0x03,
14916 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14917 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014918 .unsol_event = alc269_laptop_unsol_event,
14919 .setup = alc269_laptop_dmic_setup,
14920 .init_hook = alc269_laptop_inithook,
14921 },
14922 [ALC269VB_AMIC] = {
14923 .mixers = { alc269vb_laptop_mixer },
14924 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14925 .init_verbs = { alc269vb_init_verbs,
14926 alc269vb_laptop_amic_init_verbs },
14927 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14928 .dac_nids = alc269_dac_nids,
14929 .hp_nid = 0x03,
14930 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14931 .channel_mode = alc269_modes,
14932 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014933 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014934 .init_hook = alc269_laptop_inithook,
14935 },
14936 [ALC269VB_DMIC] = {
14937 .mixers = { alc269vb_laptop_mixer },
14938 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14939 .init_verbs = { alc269vb_init_verbs,
14940 alc269vb_laptop_dmic_init_verbs },
14941 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14942 .dac_nids = alc269_dac_nids,
14943 .hp_nid = 0x03,
14944 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14945 .channel_mode = alc269_modes,
14946 .unsol_event = alc269_laptop_unsol_event,
14947 .setup = alc269vb_laptop_dmic_setup,
14948 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014949 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014950 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014951 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014952 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014953 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014954 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014955 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14956 .dac_nids = alc269_dac_nids,
14957 .hp_nid = 0x03,
14958 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14959 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014960 .unsol_event = alc269_laptop_unsol_event,
14961 .setup = alc269_laptop_dmic_setup,
14962 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014963 },
Tony Vroon64154832008-11-06 15:08:49 +000014964 [ALC269_LIFEBOOK] = {
14965 .mixers = { alc269_lifebook_mixer },
14966 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14967 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14968 .dac_nids = alc269_dac_nids,
14969 .hp_nid = 0x03,
14970 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14971 .channel_mode = alc269_modes,
14972 .input_mux = &alc269_capture_source,
14973 .unsol_event = alc269_lifebook_unsol_event,
14974 .init_hook = alc269_lifebook_init_hook,
14975 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014976 [ALC271_ACER] = {
14977 .mixers = { alc269_asus_mixer },
14978 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14979 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
14980 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14981 .dac_nids = alc269_dac_nids,
14982 .adc_nids = alc262_dmic_adc_nids,
14983 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
14984 .capsrc_nids = alc262_dmic_capsrc_nids,
14985 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14986 .channel_mode = alc269_modes,
14987 .input_mux = &alc269_capture_source,
14988 .dig_out_nid = ALC880_DIGOUT_NID,
14989 .unsol_event = alc_sku_unsol_event,
14990 .setup = alc269vb_laptop_dmic_setup,
14991 .init_hook = alc_inithook,
14992 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014993};
14994
Kailang Yang977ddd62010-09-15 10:02:29 +020014995static int alc269_fill_coef(struct hda_codec *codec)
14996{
14997 int val;
14998
14999 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
15000 alc_write_coef_idx(codec, 0xf, 0x960b);
15001 alc_write_coef_idx(codec, 0xe, 0x8817);
15002 }
15003
15004 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
15005 alc_write_coef_idx(codec, 0xf, 0x960b);
15006 alc_write_coef_idx(codec, 0xe, 0x8814);
15007 }
15008
15009 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
15010 val = alc_read_coef_idx(codec, 0x04);
15011 /* Power up output pin */
15012 alc_write_coef_idx(codec, 0x04, val | (1<<11));
15013 }
15014
15015 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
15016 val = alc_read_coef_idx(codec, 0xd);
15017 if ((val & 0x0c00) >> 10 != 0x1) {
15018 /* Capless ramp up clock control */
15019 alc_write_coef_idx(codec, 0xd, val | 1<<10);
15020 }
15021 val = alc_read_coef_idx(codec, 0x17);
15022 if ((val & 0x01c0) >> 6 != 0x4) {
15023 /* Class D power on reset */
15024 alc_write_coef_idx(codec, 0x17, val | 1<<7);
15025 }
15026 }
15027 return 0;
15028}
15029
Kailang Yangf6a92242007-12-13 16:52:54 +010015030static int patch_alc269(struct hda_codec *codec)
15031{
15032 struct alc_spec *spec;
Kailang Yang48c88e82010-11-23 08:56:16 +010015033 int board_config, coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010015034 int err;
15035
15036 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15037 if (spec == NULL)
15038 return -ENOMEM;
15039
15040 codec->spec = spec;
15041
Kailang Yangda00c242010-03-19 11:23:45 +010015042 alc_auto_parse_customize_define(codec);
15043
Kailang Yang48c88e82010-11-23 08:56:16 +010015044 coef = alc_read_coef_idx(codec, 0);
15045 if ((coef & 0x00f0) == 0x0010) {
Kailang Yangc027ddc2010-03-19 11:33:06 +010015046 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
Takashi Iwaid433a672010-09-20 15:11:54 +020015047 spec->cdefine.platform_type == 1) {
Kailang Yangc027ddc2010-03-19 11:33:06 +010015048 alc_codec_rename(codec, "ALC271X");
Takashi Iwaid433a672010-09-20 15:11:54 +020015049 spec->codec_variant = ALC269_TYPE_ALC271X;
Kailang Yang48c88e82010-11-23 08:56:16 +010015050 } else if ((coef & 0xf000) == 0x1000) {
15051 spec->codec_variant = ALC269_TYPE_ALC270;
15052 } else if ((coef & 0xf000) == 0x2000) {
Kailang Yangc027ddc2010-03-19 11:33:06 +010015053 alc_codec_rename(codec, "ALC259");
Takashi Iwaid433a672010-09-20 15:11:54 +020015054 spec->codec_variant = ALC269_TYPE_ALC259;
Kailang Yang48c88e82010-11-23 08:56:16 +010015055 } else if ((coef & 0xf000) == 0x3000) {
15056 alc_codec_rename(codec, "ALC258");
15057 spec->codec_variant = ALC269_TYPE_ALC258;
15058 } else {
15059 alc_codec_rename(codec, "ALC269VB");
15060 spec->codec_variant = ALC269_TYPE_ALC269VB;
Takashi Iwaid433a672010-09-20 15:11:54 +020015061 }
Kailang Yangc027ddc2010-03-19 11:33:06 +010015062 } else
15063 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010015064
Kailang Yang977ddd62010-09-15 10:02:29 +020015065 alc269_fill_coef(codec);
15066
Kailang Yangf6a92242007-12-13 16:52:54 +010015067 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15068 alc269_models,
15069 alc269_cfg_tbl);
15070
15071 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015072 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15073 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015074 board_config = ALC269_AUTO;
15075 }
15076
Takashi Iwaiff818c22010-04-12 08:59:25 +020015077 if (board_config == ALC269_AUTO)
15078 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
15079
Kailang Yangf6a92242007-12-13 16:52:54 +010015080 if (board_config == ALC269_AUTO) {
15081 /* automatic parse from the BIOS config */
15082 err = alc269_parse_auto_config(codec);
15083 if (err < 0) {
15084 alc_free(codec);
15085 return err;
15086 } else if (!err) {
15087 printk(KERN_INFO
15088 "hda_codec: Cannot set up configuration "
15089 "from BIOS. Using base mode...\n");
15090 board_config = ALC269_BASIC;
15091 }
15092 }
15093
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015094 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015095 err = snd_hda_attach_beep_device(codec, 0x1);
15096 if (err < 0) {
15097 alc_free(codec);
15098 return err;
15099 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015100 }
15101
Kailang Yangf6a92242007-12-13 16:52:54 +010015102 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015103 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015104
Kailang Yang84898e82010-02-04 14:16:14 +010015105 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015106 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15107 * fix the sample rate of analog I/O to 44.1kHz
15108 */
15109 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15110 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015111 } else if (spec->dual_adc_switch) {
15112 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15113 /* switch ADC dynamically */
15114 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015115 } else {
15116 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15117 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15118 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015119 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15120 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15121
Takashi Iwai66946352010-03-29 17:21:45 +020015122 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Kailang Yang1657cbd2010-11-23 08:53:32 +010015123 if (spec->codec_variant == ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015124 spec->adc_nids = alc269_adc_nids;
15125 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15126 spec->capsrc_nids = alc269_capsrc_nids;
15127 } else {
15128 spec->adc_nids = alc269vb_adc_nids;
15129 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15130 spec->capsrc_nids = alc269vb_capsrc_nids;
15131 }
Kailang Yang84898e82010-02-04 14:16:14 +010015132 }
15133
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015134 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015135 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015136 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015137 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015138
Takashi Iwaiff818c22010-04-12 08:59:25 +020015139 if (board_config == ALC269_AUTO)
15140 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
15141
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015142 spec->vmaster_nid = 0x02;
15143
Kailang Yangf6a92242007-12-13 16:52:54 +010015144 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015145#ifdef CONFIG_SND_HDA_POWER_SAVE
15146 codec->patch_ops.suspend = alc269_suspend;
15147#endif
15148#ifdef SND_HDA_NEEDS_RESUME
15149 codec->patch_ops.resume = alc269_resume;
15150#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015151 if (board_config == ALC269_AUTO)
15152 spec->init_hook = alc269_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020015153
15154 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010015155#ifdef CONFIG_SND_HDA_POWER_SAVE
15156 if (!spec->loopback.amplist)
15157 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015158 if (alc269_mic2_for_mute_led(codec))
15159 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015160#endif
15161
15162 return 0;
15163}
15164
15165/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015166 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15167 */
15168
15169/*
15170 * set the path ways for 2 channel output
15171 * need to set the codec line out and mic 1 pin widgets to inputs
15172 */
15173static struct hda_verb alc861_threestack_ch2_init[] = {
15174 /* set pin widget 1Ah (line in) for input */
15175 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015176 /* set pin widget 18h (mic1/2) for input, for mic also enable
15177 * the vref
15178 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015179 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15180
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015181 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15182#if 0
15183 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15184 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15185#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015186 { } /* end */
15187};
15188/*
15189 * 6ch mode
15190 * need to set the codec line out and mic 1 pin widgets to outputs
15191 */
15192static struct hda_verb alc861_threestack_ch6_init[] = {
15193 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15194 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15195 /* set pin widget 18h (mic1) for output (CLFE)*/
15196 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15197
15198 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015199 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015200
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015201 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15202#if 0
15203 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15204 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15205#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015206 { } /* end */
15207};
15208
15209static struct hda_channel_mode alc861_threestack_modes[2] = {
15210 { 2, alc861_threestack_ch2_init },
15211 { 6, alc861_threestack_ch6_init },
15212};
Takashi Iwai22309c32006-08-09 16:57:28 +020015213/* Set mic1 as input and unmute the mixer */
15214static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15215 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15216 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15217 { } /* end */
15218};
15219/* Set mic1 as output and mute mixer */
15220static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15221 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15222 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15223 { } /* end */
15224};
15225
15226static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15227 { 2, alc861_uniwill_m31_ch2_init },
15228 { 4, alc861_uniwill_m31_ch4_init },
15229};
Kailang Yangdf694da2005-12-05 19:42:22 +010015230
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015231/* Set mic1 and line-in as input and unmute the mixer */
15232static struct hda_verb alc861_asus_ch2_init[] = {
15233 /* set pin widget 1Ah (line in) for input */
15234 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015235 /* set pin widget 18h (mic1/2) for input, for mic also enable
15236 * the vref
15237 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015238 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15239
15240 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15241#if 0
15242 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15243 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15244#endif
15245 { } /* end */
15246};
15247/* Set mic1 nad line-in as output and mute mixer */
15248static struct hda_verb alc861_asus_ch6_init[] = {
15249 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15250 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15251 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15252 /* set pin widget 18h (mic1) for output (CLFE)*/
15253 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15254 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15255 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15256 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15257
15258 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15259#if 0
15260 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15261 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15262#endif
15263 { } /* end */
15264};
15265
15266static struct hda_channel_mode alc861_asus_modes[2] = {
15267 { 2, alc861_asus_ch2_init },
15268 { 6, alc861_asus_ch6_init },
15269};
15270
Kailang Yangdf694da2005-12-05 19:42:22 +010015271/* patch-ALC861 */
15272
15273static struct snd_kcontrol_new alc861_base_mixer[] = {
15274 /* output mixer control */
15275 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15276 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15277 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15278 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15279 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15280
15281 /*Input mixer control */
15282 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15283 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15284 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15285 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15286 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15287 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15288 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15289 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15290 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15291 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015292
Kailang Yangdf694da2005-12-05 19:42:22 +010015293 { } /* end */
15294};
15295
15296static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15297 /* output mixer control */
15298 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15299 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15300 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15301 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15302 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15303
15304 /* Input mixer control */
15305 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15306 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15307 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15308 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15309 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15310 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15311 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15312 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15313 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15314 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015315
Kailang Yangdf694da2005-12-05 19:42:22 +010015316 {
15317 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15318 .name = "Channel Mode",
15319 .info = alc_ch_mode_info,
15320 .get = alc_ch_mode_get,
15321 .put = alc_ch_mode_put,
15322 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15323 },
15324 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015325};
15326
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015327static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015328 /* output mixer control */
15329 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15330 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15331 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015332
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015333 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015334};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015335
Takashi Iwai22309c32006-08-09 16:57:28 +020015336static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15337 /* output mixer control */
15338 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15339 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15340 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15341 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15342 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15343
15344 /* Input mixer control */
15345 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15346 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15347 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15348 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15349 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15350 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15351 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15352 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15353 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15354 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015355
Takashi Iwai22309c32006-08-09 16:57:28 +020015356 {
15357 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15358 .name = "Channel Mode",
15359 .info = alc_ch_mode_info,
15360 .get = alc_ch_mode_get,
15361 .put = alc_ch_mode_put,
15362 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15363 },
15364 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015365};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015366
15367static struct snd_kcontrol_new alc861_asus_mixer[] = {
15368 /* output mixer control */
15369 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15370 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15371 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15372 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15373 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15374
15375 /* Input mixer control */
15376 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15377 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15378 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15379 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15380 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15381 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15382 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15383 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15384 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015385 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15386
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015387 {
15388 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15389 .name = "Channel Mode",
15390 .info = alc_ch_mode_info,
15391 .get = alc_ch_mode_get,
15392 .put = alc_ch_mode_put,
15393 .private_value = ARRAY_SIZE(alc861_asus_modes),
15394 },
15395 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015396};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015397
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015398/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015399static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015400 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15401 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015402 { }
15403};
15404
Kailang Yangdf694da2005-12-05 19:42:22 +010015405/*
15406 * generic initialization of ADC, input mixers and output mixers
15407 */
15408static struct hda_verb alc861_base_init_verbs[] = {
15409 /*
15410 * Unmute ADC0 and set the default input to mic-in
15411 */
15412 /* port-A for surround (rear panel) */
15413 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15414 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15415 /* port-B for mic-in (rear panel) with vref */
15416 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15417 /* port-C for line-in (rear panel) */
15418 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15419 /* port-D for Front */
15420 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15421 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15422 /* port-E for HP out (front panel) */
15423 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15424 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015425 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015426 /* port-F for mic-in (front panel) with vref */
15427 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15428 /* port-G for CLFE (rear panel) */
15429 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15430 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15431 /* port-H for side (rear panel) */
15432 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15433 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15434 /* CD-in */
15435 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15436 /* route front mic to ADC1*/
15437 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15438 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015439
Kailang Yangdf694da2005-12-05 19:42:22 +010015440 /* Unmute DAC0~3 & spdif out*/
15441 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15442 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15443 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15444 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15445 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015446
Kailang Yangdf694da2005-12-05 19:42:22 +010015447 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15448 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15449 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15450 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15451 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015452
Kailang Yangdf694da2005-12-05 19:42:22 +010015453 /* Unmute Stereo Mixer 15 */
15454 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15455 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15456 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015457 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015458
15459 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15460 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15461 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15462 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15463 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15464 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15465 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15466 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015467 /* hp used DAC 3 (Front) */
15468 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015469 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15470
15471 { }
15472};
15473
15474static struct hda_verb alc861_threestack_init_verbs[] = {
15475 /*
15476 * Unmute ADC0 and set the default input to mic-in
15477 */
15478 /* port-A for surround (rear panel) */
15479 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15480 /* port-B for mic-in (rear panel) with vref */
15481 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15482 /* port-C for line-in (rear panel) */
15483 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15484 /* port-D for Front */
15485 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15486 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15487 /* port-E for HP out (front panel) */
15488 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15489 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015490 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015491 /* port-F for mic-in (front panel) with vref */
15492 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15493 /* port-G for CLFE (rear panel) */
15494 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15495 /* port-H for side (rear panel) */
15496 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15497 /* CD-in */
15498 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15499 /* route front mic to ADC1*/
15500 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15501 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15502 /* Unmute DAC0~3 & spdif out*/
15503 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15504 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15505 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15506 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15507 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015508
Kailang Yangdf694da2005-12-05 19:42:22 +010015509 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15510 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15511 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15512 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15513 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015514
Kailang Yangdf694da2005-12-05 19:42:22 +010015515 /* Unmute Stereo Mixer 15 */
15516 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15517 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15518 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015519 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015520
15521 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15522 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15523 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15524 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15525 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15526 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15527 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15528 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015529 /* hp used DAC 3 (Front) */
15530 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015531 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15532 { }
15533};
Takashi Iwai22309c32006-08-09 16:57:28 +020015534
15535static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15536 /*
15537 * Unmute ADC0 and set the default input to mic-in
15538 */
15539 /* port-A for surround (rear panel) */
15540 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15541 /* port-B for mic-in (rear panel) with vref */
15542 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15543 /* port-C for line-in (rear panel) */
15544 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15545 /* port-D for Front */
15546 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15547 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15548 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015549 /* this has to be set to VREF80 */
15550 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015551 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015552 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015553 /* port-F for mic-in (front panel) with vref */
15554 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15555 /* port-G for CLFE (rear panel) */
15556 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15557 /* port-H for side (rear panel) */
15558 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15559 /* CD-in */
15560 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15561 /* route front mic to ADC1*/
15562 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15563 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15564 /* Unmute DAC0~3 & spdif out*/
15565 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15566 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15567 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15568 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15569 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015570
Takashi Iwai22309c32006-08-09 16:57:28 +020015571 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15572 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15573 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15574 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15575 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015576
Takashi Iwai22309c32006-08-09 16:57:28 +020015577 /* Unmute Stereo Mixer 15 */
15578 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15579 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15580 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015581 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015582
15583 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15584 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15585 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15586 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15587 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15588 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15589 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15590 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015591 /* hp used DAC 3 (Front) */
15592 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015593 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15594 { }
15595};
15596
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015597static struct hda_verb alc861_asus_init_verbs[] = {
15598 /*
15599 * Unmute ADC0 and set the default input to mic-in
15600 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015601 /* port-A for surround (rear panel)
15602 * according to codec#0 this is the HP jack
15603 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015604 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15605 /* route front PCM to HP */
15606 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15607 /* port-B for mic-in (rear panel) with vref */
15608 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15609 /* port-C for line-in (rear panel) */
15610 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15611 /* port-D for Front */
15612 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15613 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15614 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015615 /* this has to be set to VREF80 */
15616 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015617 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015618 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015619 /* port-F for mic-in (front panel) with vref */
15620 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15621 /* port-G for CLFE (rear panel) */
15622 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15623 /* port-H for side (rear panel) */
15624 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15625 /* CD-in */
15626 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15627 /* route front mic to ADC1*/
15628 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15629 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15630 /* Unmute DAC0~3 & spdif out*/
15631 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15632 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15633 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15634 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15635 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15636 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15637 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15638 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15639 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15640 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015641
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015642 /* Unmute Stereo Mixer 15 */
15643 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15644 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15645 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015646 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015647
15648 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15649 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15650 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15651 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15652 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15653 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15654 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15655 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015656 /* hp used DAC 3 (Front) */
15657 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015658 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15659 { }
15660};
15661
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015662/* additional init verbs for ASUS laptops */
15663static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15664 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15665 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15666 { }
15667};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015668
Kailang Yangdf694da2005-12-05 19:42:22 +010015669/*
15670 * generic initialization of ADC, input mixers and output mixers
15671 */
15672static struct hda_verb alc861_auto_init_verbs[] = {
15673 /*
15674 * Unmute ADC0 and set the default input to mic-in
15675 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015676 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015677 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015678
Kailang Yangdf694da2005-12-05 19:42:22 +010015679 /* Unmute DAC0~3 & spdif out*/
15680 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15681 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15682 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15683 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15684 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015685
Kailang Yangdf694da2005-12-05 19:42:22 +010015686 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15687 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15688 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15689 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15690 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015691
Kailang Yangdf694da2005-12-05 19:42:22 +010015692 /* Unmute Stereo Mixer 15 */
15693 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15694 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15695 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15696 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15697
Takashi Iwai1c209302009-07-22 15:17:45 +020015698 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15699 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15700 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15701 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15702 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15703 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15704 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15705 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015706
15707 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15708 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015709 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15710 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015711 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15712 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015713 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15714 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015715
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015716 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015717
15718 { }
15719};
15720
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015721static struct hda_verb alc861_toshiba_init_verbs[] = {
15722 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015723
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015724 { }
15725};
15726
15727/* toggle speaker-output according to the hp-jack state */
15728static void alc861_toshiba_automute(struct hda_codec *codec)
15729{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015730 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015731
Takashi Iwai47fd8302007-08-10 17:11:07 +020015732 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15733 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15734 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15735 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015736}
15737
15738static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15739 unsigned int res)
15740{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015741 if ((res >> 26) == ALC880_HP_EVENT)
15742 alc861_toshiba_automute(codec);
15743}
15744
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015745/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015746#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15747#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15748#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15749#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15750
15751
15752#define ALC861_DIGOUT_NID 0x07
15753
15754static struct hda_channel_mode alc861_8ch_modes[1] = {
15755 { 8, NULL }
15756};
15757
15758static hda_nid_t alc861_dac_nids[4] = {
15759 /* front, surround, clfe, side */
15760 0x03, 0x06, 0x05, 0x04
15761};
15762
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015763static hda_nid_t alc660_dac_nids[3] = {
15764 /* front, clfe, surround */
15765 0x03, 0x05, 0x06
15766};
15767
Kailang Yangdf694da2005-12-05 19:42:22 +010015768static hda_nid_t alc861_adc_nids[1] = {
15769 /* ADC0-2 */
15770 0x08,
15771};
15772
15773static struct hda_input_mux alc861_capture_source = {
15774 .num_items = 5,
15775 .items = {
15776 { "Mic", 0x0 },
15777 { "Front Mic", 0x3 },
15778 { "Line", 0x1 },
15779 { "CD", 0x4 },
15780 { "Mixer", 0x5 },
15781 },
15782};
15783
Takashi Iwai1c209302009-07-22 15:17:45 +020015784static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15785{
15786 struct alc_spec *spec = codec->spec;
15787 hda_nid_t mix, srcs[5];
15788 int i, j, num;
15789
15790 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15791 return 0;
15792 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15793 if (num < 0)
15794 return 0;
15795 for (i = 0; i < num; i++) {
15796 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015797 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015798 if (type != AC_WID_AUD_OUT)
15799 continue;
15800 for (j = 0; j < spec->multiout.num_dacs; j++)
15801 if (spec->multiout.dac_nids[j] == srcs[i])
15802 break;
15803 if (j >= spec->multiout.num_dacs)
15804 return srcs[i];
15805 }
15806 return 0;
15807}
15808
Kailang Yangdf694da2005-12-05 19:42:22 +010015809/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015810static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015811 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015812{
Takashi Iwai1c209302009-07-22 15:17:45 +020015813 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015814 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015815 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015816
15817 spec->multiout.dac_nids = spec->private_dac_nids;
15818 for (i = 0; i < cfg->line_outs; i++) {
15819 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015820 dac = alc861_look_for_dac(codec, nid);
15821 if (!dac)
15822 continue;
15823 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015824 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015825 return 0;
15826}
15827
Takashi Iwai1c209302009-07-22 15:17:45 +020015828static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15829 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015830{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015831 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015832 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15833}
15834
15835/* add playback controls from the parsed DAC table */
15836static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15837 const struct auto_pin_cfg *cfg)
15838{
15839 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015840 static const char *chname[4] = {
15841 "Front", "Surround", NULL /*CLFE*/, "Side"
15842 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015843 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015844 int i, err;
15845
15846 if (cfg->line_outs == 1) {
15847 const char *pfx = NULL;
15848 if (!cfg->hp_outs)
15849 pfx = "Master";
15850 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15851 pfx = "Speaker";
15852 if (pfx) {
15853 nid = spec->multiout.dac_nids[0];
15854 return alc861_create_out_sw(codec, pfx, nid, 3);
15855 }
15856 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015857
15858 for (i = 0; i < cfg->line_outs; i++) {
15859 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015860 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015861 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015862 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015863 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015864 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015865 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015866 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015867 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015868 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015869 return err;
15870 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015871 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015872 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015873 return err;
15874 }
15875 }
15876 return 0;
15877}
15878
Takashi Iwai1c209302009-07-22 15:17:45 +020015879static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015880{
Takashi Iwai1c209302009-07-22 15:17:45 +020015881 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015882 int err;
15883 hda_nid_t nid;
15884
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015885 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015886 return 0;
15887
15888 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015889 nid = alc861_look_for_dac(codec, pin);
15890 if (nid) {
15891 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15892 if (err < 0)
15893 return err;
15894 spec->multiout.hp_nid = nid;
15895 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015896 }
15897 return 0;
15898}
15899
15900/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015901static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015902 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015903{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015904 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015905}
15906
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015907static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15908 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015909 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015910{
Takashi Iwai1c209302009-07-22 15:17:45 +020015911 hda_nid_t mix, srcs[5];
15912 int i, num;
15913
Jacek Luczak564c5be2008-05-03 18:41:23 +020015914 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15915 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015916 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015917 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015918 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15919 return;
15920 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15921 if (num < 0)
15922 return;
15923 for (i = 0; i < num; i++) {
15924 unsigned int mute;
15925 if (srcs[i] == dac || srcs[i] == 0x15)
15926 mute = AMP_IN_UNMUTE(i);
15927 else
15928 mute = AMP_IN_MUTE(i);
15929 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15930 mute);
15931 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015932}
15933
15934static void alc861_auto_init_multi_out(struct hda_codec *codec)
15935{
15936 struct alc_spec *spec = codec->spec;
15937 int i;
15938
15939 for (i = 0; i < spec->autocfg.line_outs; i++) {
15940 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015941 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015942 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015943 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015944 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015945 }
15946}
15947
15948static void alc861_auto_init_hp_out(struct hda_codec *codec)
15949{
15950 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015951
Takashi Iwai15870f02009-10-05 08:25:13 +020015952 if (spec->autocfg.hp_outs)
15953 alc861_auto_set_output_and_unmute(codec,
15954 spec->autocfg.hp_pins[0],
15955 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015956 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015957 if (spec->autocfg.speaker_outs)
15958 alc861_auto_set_output_and_unmute(codec,
15959 spec->autocfg.speaker_pins[0],
15960 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015961 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015962}
15963
15964static void alc861_auto_init_analog_input(struct hda_codec *codec)
15965{
15966 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015967 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010015968 int i;
15969
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015970 for (i = 0; i < cfg->num_inputs; i++) {
15971 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010015972 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020015973 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015974 }
15975}
15976
15977/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015978/* return 1 if successful, 0 if the proper config is not found,
15979 * or a negative error code
15980 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015981static int alc861_parse_auto_config(struct hda_codec *codec)
15982{
15983 struct alc_spec *spec = codec->spec;
15984 int err;
15985 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15986
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015987 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15988 alc861_ignore);
15989 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015990 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015991 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015992 return 0; /* can't find valid BIOS pin config */
15993
Takashi Iwai1c209302009-07-22 15:17:45 +020015994 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015995 if (err < 0)
15996 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015997 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015998 if (err < 0)
15999 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016000 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016001 if (err < 0)
16002 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016003 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016004 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016005 return err;
16006
16007 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16008
Takashi Iwai757899a2010-07-30 10:48:14 +020016009 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016010
Takashi Iwai603c4012008-07-30 15:01:44 +020016011 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016012 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010016013
Takashi Iwaid88897e2008-10-31 15:01:37 +010016014 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010016015
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020016016 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016017 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010016018
16019 spec->adc_nids = alc861_adc_nids;
16020 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016021 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016022
Kailang Yang6227cdc2010-02-25 08:36:52 +010016023 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016024
Kailang Yangdf694da2005-12-05 19:42:22 +010016025 return 1;
16026}
16027
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016028/* additional initialization for auto-configuration model */
16029static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010016030{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016031 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016032 alc861_auto_init_multi_out(codec);
16033 alc861_auto_init_hp_out(codec);
16034 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016035 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016036 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016037 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016038}
16039
Takashi Iwaicb53c622007-08-10 17:21:45 +020016040#ifdef CONFIG_SND_HDA_POWER_SAVE
16041static struct hda_amp_list alc861_loopbacks[] = {
16042 { 0x15, HDA_INPUT, 0 },
16043 { 0x15, HDA_INPUT, 1 },
16044 { 0x15, HDA_INPUT, 2 },
16045 { 0x15, HDA_INPUT, 3 },
16046 { } /* end */
16047};
16048#endif
16049
Kailang Yangdf694da2005-12-05 19:42:22 +010016050
16051/*
16052 * configuration and preset
16053 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016054static const char *alc861_models[ALC861_MODEL_LAST] = {
16055 [ALC861_3ST] = "3stack",
16056 [ALC660_3ST] = "3stack-660",
16057 [ALC861_3ST_DIG] = "3stack-dig",
16058 [ALC861_6ST_DIG] = "6stack-dig",
16059 [ALC861_UNIWILL_M31] = "uniwill-m31",
16060 [ALC861_TOSHIBA] = "toshiba",
16061 [ALC861_ASUS] = "asus",
16062 [ALC861_ASUS_LAPTOP] = "asus-laptop",
16063 [ALC861_AUTO] = "auto",
16064};
16065
16066static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010016067 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016068 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16069 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16070 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016071 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016072 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016073 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016074 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16075 * Any other models that need this preset?
16076 */
16077 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016078 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16079 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016080 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16081 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16082 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16083 /* FIXME: the below seems conflict */
16084 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16085 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16086 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016087 {}
16088};
16089
16090static struct alc_config_preset alc861_presets[] = {
16091 [ALC861_3ST] = {
16092 .mixers = { alc861_3ST_mixer },
16093 .init_verbs = { alc861_threestack_init_verbs },
16094 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16095 .dac_nids = alc861_dac_nids,
16096 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16097 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016098 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016099 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16100 .adc_nids = alc861_adc_nids,
16101 .input_mux = &alc861_capture_source,
16102 },
16103 [ALC861_3ST_DIG] = {
16104 .mixers = { alc861_base_mixer },
16105 .init_verbs = { alc861_threestack_init_verbs },
16106 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16107 .dac_nids = alc861_dac_nids,
16108 .dig_out_nid = ALC861_DIGOUT_NID,
16109 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16110 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016111 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016112 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16113 .adc_nids = alc861_adc_nids,
16114 .input_mux = &alc861_capture_source,
16115 },
16116 [ALC861_6ST_DIG] = {
16117 .mixers = { alc861_base_mixer },
16118 .init_verbs = { alc861_base_init_verbs },
16119 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16120 .dac_nids = alc861_dac_nids,
16121 .dig_out_nid = ALC861_DIGOUT_NID,
16122 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16123 .channel_mode = alc861_8ch_modes,
16124 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16125 .adc_nids = alc861_adc_nids,
16126 .input_mux = &alc861_capture_source,
16127 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016128 [ALC660_3ST] = {
16129 .mixers = { alc861_3ST_mixer },
16130 .init_verbs = { alc861_threestack_init_verbs },
16131 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16132 .dac_nids = alc660_dac_nids,
16133 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16134 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016135 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016136 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16137 .adc_nids = alc861_adc_nids,
16138 .input_mux = &alc861_capture_source,
16139 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016140 [ALC861_UNIWILL_M31] = {
16141 .mixers = { alc861_uniwill_m31_mixer },
16142 .init_verbs = { alc861_uniwill_m31_init_verbs },
16143 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16144 .dac_nids = alc861_dac_nids,
16145 .dig_out_nid = ALC861_DIGOUT_NID,
16146 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16147 .channel_mode = alc861_uniwill_m31_modes,
16148 .need_dac_fix = 1,
16149 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16150 .adc_nids = alc861_adc_nids,
16151 .input_mux = &alc861_capture_source,
16152 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016153 [ALC861_TOSHIBA] = {
16154 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016155 .init_verbs = { alc861_base_init_verbs,
16156 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016157 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16158 .dac_nids = alc861_dac_nids,
16159 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16160 .channel_mode = alc883_3ST_2ch_modes,
16161 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16162 .adc_nids = alc861_adc_nids,
16163 .input_mux = &alc861_capture_source,
16164 .unsol_event = alc861_toshiba_unsol_event,
16165 .init_hook = alc861_toshiba_automute,
16166 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016167 [ALC861_ASUS] = {
16168 .mixers = { alc861_asus_mixer },
16169 .init_verbs = { alc861_asus_init_verbs },
16170 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16171 .dac_nids = alc861_dac_nids,
16172 .dig_out_nid = ALC861_DIGOUT_NID,
16173 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16174 .channel_mode = alc861_asus_modes,
16175 .need_dac_fix = 1,
16176 .hp_nid = 0x06,
16177 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16178 .adc_nids = alc861_adc_nids,
16179 .input_mux = &alc861_capture_source,
16180 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016181 [ALC861_ASUS_LAPTOP] = {
16182 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16183 .init_verbs = { alc861_asus_init_verbs,
16184 alc861_asus_laptop_init_verbs },
16185 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16186 .dac_nids = alc861_dac_nids,
16187 .dig_out_nid = ALC861_DIGOUT_NID,
16188 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16189 .channel_mode = alc883_3ST_2ch_modes,
16190 .need_dac_fix = 1,
16191 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16192 .adc_nids = alc861_adc_nids,
16193 .input_mux = &alc861_capture_source,
16194 },
16195};
Kailang Yangdf694da2005-12-05 19:42:22 +010016196
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016197/* Pin config fixes */
16198enum {
16199 PINFIX_FSC_AMILO_PI1505,
16200};
16201
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016202static const struct alc_fixup alc861_fixups[] = {
16203 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020016204 .pins = (const struct alc_pincfg[]) {
16205 { 0x0b, 0x0221101f }, /* HP */
16206 { 0x0f, 0x90170310 }, /* speaker */
16207 { }
16208 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016209 },
16210};
16211
16212static struct snd_pci_quirk alc861_fixup_tbl[] = {
16213 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16214 {}
16215};
Kailang Yangdf694da2005-12-05 19:42:22 +010016216
16217static int patch_alc861(struct hda_codec *codec)
16218{
16219 struct alc_spec *spec;
16220 int board_config;
16221 int err;
16222
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016223 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016224 if (spec == NULL)
16225 return -ENOMEM;
16226
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016227 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016228
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016229 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16230 alc861_models,
16231 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016232
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016233 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016234 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16235 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016236 board_config = ALC861_AUTO;
16237 }
16238
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016239 if (board_config == ALC861_AUTO)
16240 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016241
Kailang Yangdf694da2005-12-05 19:42:22 +010016242 if (board_config == ALC861_AUTO) {
16243 /* automatic parse from the BIOS config */
16244 err = alc861_parse_auto_config(codec);
16245 if (err < 0) {
16246 alc_free(codec);
16247 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016248 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016249 printk(KERN_INFO
16250 "hda_codec: Cannot set up configuration "
16251 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016252 board_config = ALC861_3ST_DIG;
16253 }
16254 }
16255
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016256 err = snd_hda_attach_beep_device(codec, 0x23);
16257 if (err < 0) {
16258 alc_free(codec);
16259 return err;
16260 }
16261
Kailang Yangdf694da2005-12-05 19:42:22 +010016262 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016263 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016264
Kailang Yangdf694da2005-12-05 19:42:22 +010016265 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16266 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16267
Kailang Yangdf694da2005-12-05 19:42:22 +010016268 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16269 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16270
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016271 if (!spec->cap_mixer)
16272 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016273 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16274
Takashi Iwai2134ea42008-01-10 16:53:55 +010016275 spec->vmaster_nid = 0x03;
16276
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016277 if (board_config == ALC861_AUTO)
16278 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
16279
Kailang Yangdf694da2005-12-05 19:42:22 +010016280 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016281 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016282 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016283#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016284 spec->power_hook = alc_power_eapd;
16285#endif
16286 }
16287#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016288 if (!spec->loopback.amplist)
16289 spec->loopback.amplist = alc861_loopbacks;
16290#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016291
Kailang Yangdf694da2005-12-05 19:42:22 +010016292 return 0;
16293}
16294
16295/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016296 * ALC861-VD support
16297 *
16298 * Based on ALC882
16299 *
16300 * In addition, an independent DAC
16301 */
16302#define ALC861VD_DIGOUT_NID 0x06
16303
16304static hda_nid_t alc861vd_dac_nids[4] = {
16305 /* front, surr, clfe, side surr */
16306 0x02, 0x03, 0x04, 0x05
16307};
16308
16309/* dac_nids for ALC660vd are in a different order - according to
16310 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016311 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016312 * of ALC660vd codecs, but for now there is only 3stack mixer
16313 * - and it is the same as in 861vd.
16314 * adc_nids in ALC660vd are (is) the same as in 861vd
16315 */
16316static hda_nid_t alc660vd_dac_nids[3] = {
16317 /* front, rear, clfe, rear_surr */
16318 0x02, 0x04, 0x03
16319};
16320
16321static hda_nid_t alc861vd_adc_nids[1] = {
16322 /* ADC0 */
16323 0x09,
16324};
16325
Takashi Iwaie1406342008-02-11 18:32:32 +010016326static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16327
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016328/* input MUX */
16329/* FIXME: should be a matrix-type input source selection */
16330static struct hda_input_mux alc861vd_capture_source = {
16331 .num_items = 4,
16332 .items = {
16333 { "Mic", 0x0 },
16334 { "Front Mic", 0x1 },
16335 { "Line", 0x2 },
16336 { "CD", 0x4 },
16337 },
16338};
16339
Kailang Yang272a5272007-05-14 11:00:38 +020016340static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016341 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016342 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010016343 { "Ext Mic", 0x0 },
16344 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016345 },
16346};
16347
Kailang Yangd1a991a2007-08-15 16:21:59 +020016348static struct hda_input_mux alc861vd_hp_capture_source = {
16349 .num_items = 2,
16350 .items = {
16351 { "Front Mic", 0x0 },
16352 { "ATAPI Mic", 0x1 },
16353 },
16354};
16355
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016356/*
16357 * 2ch mode
16358 */
16359static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16360 { 2, NULL }
16361};
16362
16363/*
16364 * 6ch mode
16365 */
16366static struct hda_verb alc861vd_6stack_ch6_init[] = {
16367 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16368 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16369 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16370 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16371 { } /* end */
16372};
16373
16374/*
16375 * 8ch mode
16376 */
16377static struct hda_verb alc861vd_6stack_ch8_init[] = {
16378 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16379 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16380 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16381 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16382 { } /* end */
16383};
16384
16385static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16386 { 6, alc861vd_6stack_ch6_init },
16387 { 8, alc861vd_6stack_ch8_init },
16388};
16389
16390static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16391 {
16392 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16393 .name = "Channel Mode",
16394 .info = alc_ch_mode_info,
16395 .get = alc_ch_mode_get,
16396 .put = alc_ch_mode_put,
16397 },
16398 { } /* end */
16399};
16400
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016401/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16402 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16403 */
16404static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16405 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16406 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16407
16408 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16409 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16410
16411 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16412 HDA_OUTPUT),
16413 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16414 HDA_OUTPUT),
16415 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16416 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16417
16418 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16419 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16420
16421 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16422
16423 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16424 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16425 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16426
16427 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16428 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16429 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16430
16431 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16432 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16433
16434 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16435 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16436
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016437 { } /* end */
16438};
16439
16440static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16441 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16442 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16443
16444 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16445
16446 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16447 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16448 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16449
16450 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16451 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16452 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16453
16454 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16455 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16456
16457 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16458 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16459
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016460 { } /* end */
16461};
16462
Kailang Yangbdd148a2007-05-08 15:19:08 +020016463static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16464 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16465 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16466 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16467
16468 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16469
16470 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16471 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16472 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16473
16474 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16475 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16476 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16477
16478 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16479 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16480
16481 { } /* end */
16482};
16483
Tobin Davisb419f342008-03-07 11:57:51 +010016484/* Pin assignment: Speaker=0x14, HP = 0x15,
16485 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016486 */
16487static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016488 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16489 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016490 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16491 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010016492 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16493 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16494 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16495 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16496 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16497 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016498 { } /* end */
16499};
16500
Kailang Yangd1a991a2007-08-15 16:21:59 +020016501/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16502 * Front Mic=0x18, ATAPI Mic = 0x19,
16503 */
16504static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16505 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16506 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16507 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16508 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16509 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16510 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16511 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16512 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016513
Kailang Yangd1a991a2007-08-15 16:21:59 +020016514 { } /* end */
16515};
16516
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016517/*
16518 * generic initialization of ADC, input mixers and output mixers
16519 */
16520static struct hda_verb alc861vd_volume_init_verbs[] = {
16521 /*
16522 * Unmute ADC0 and set the default input to mic-in
16523 */
16524 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16525 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16526
16527 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16528 * the analog-loopback mixer widget
16529 */
16530 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016531 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16532 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16533 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16534 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16535 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016536
16537 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016538 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16539 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16540 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016541 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016542
16543 /*
16544 * Set up output mixers (0x02 - 0x05)
16545 */
16546 /* set vol=0 to output mixers */
16547 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16548 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16549 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16550 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16551
16552 /* set up input amps for analog loopback */
16553 /* Amp Indices: DAC = 0, mixer = 1 */
16554 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16555 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16556 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16557 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16558 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16559 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16560 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16561 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16562
16563 { }
16564};
16565
16566/*
16567 * 3-stack pin configuration:
16568 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16569 */
16570static struct hda_verb alc861vd_3stack_init_verbs[] = {
16571 /*
16572 * Set pin mode and muting
16573 */
16574 /* set front pin widgets 0x14 for output */
16575 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16576 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16577 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16578
16579 /* Mic (rear) pin: input vref at 80% */
16580 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16581 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16582 /* Front Mic pin: input vref at 80% */
16583 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16584 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16585 /* Line In pin: input */
16586 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16587 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16588 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16589 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16590 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16591 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16592 /* CD pin widget for input */
16593 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16594
16595 { }
16596};
16597
16598/*
16599 * 6-stack pin configuration:
16600 */
16601static struct hda_verb alc861vd_6stack_init_verbs[] = {
16602 /*
16603 * Set pin mode and muting
16604 */
16605 /* set front pin widgets 0x14 for output */
16606 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16607 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16608 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16609
16610 /* Rear Pin: output 1 (0x0d) */
16611 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16612 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16613 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16614 /* CLFE Pin: output 2 (0x0e) */
16615 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16616 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16617 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16618 /* Side Pin: output 3 (0x0f) */
16619 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16620 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16621 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16622
16623 /* Mic (rear) pin: input vref at 80% */
16624 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16625 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16626 /* Front Mic pin: input vref at 80% */
16627 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16628 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16629 /* Line In pin: input */
16630 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16631 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16632 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16633 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16634 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16635 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16636 /* CD pin widget for input */
16637 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16638
16639 { }
16640};
16641
Kailang Yangbdd148a2007-05-08 15:19:08 +020016642static struct hda_verb alc861vd_eapd_verbs[] = {
16643 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16644 { }
16645};
16646
Kailang Yangf9423e72008-05-27 12:32:25 +020016647static struct hda_verb alc660vd_eapd_verbs[] = {
16648 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16649 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16650 { }
16651};
16652
Kailang Yangbdd148a2007-05-08 15:19:08 +020016653static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16654 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16656 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16657 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016658 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016659 {}
16660};
16661
Kailang Yangbdd148a2007-05-08 15:19:08 +020016662static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
16663{
16664 unsigned int present;
16665 unsigned char bits;
16666
Wu Fengguang864f92b2009-11-18 12:38:02 +080016667 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016668 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016669
Takashi Iwai47fd8302007-08-10 17:11:07 +020016670 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
16671 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016672}
16673
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016674static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016675{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016676 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016677 spec->autocfg.hp_pins[0] = 0x1b;
16678 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016679}
16680
16681static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16682{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016683 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016684 alc861vd_lenovo_mic_automute(codec);
16685}
16686
16687static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16688 unsigned int res)
16689{
16690 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016691 case ALC880_MIC_EVENT:
16692 alc861vd_lenovo_mic_automute(codec);
16693 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016694 default:
16695 alc_automute_amp_unsol_event(codec, res);
16696 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016697 }
16698}
16699
Kailang Yang272a5272007-05-14 11:00:38 +020016700static struct hda_verb alc861vd_dallas_verbs[] = {
16701 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16702 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16703 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16704 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16705
16706 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16707 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16708 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16709 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16710 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16711 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16712 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16713 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016714
Kailang Yang272a5272007-05-14 11:00:38 +020016715 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16716 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16717 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16718 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16719 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16720 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16721 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16722 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16723
16724 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16725 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16726 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16727 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16728 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16729 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16730 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16731 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16732
16733 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16734 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16735 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16736 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16737
16738 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016739 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016740 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16741
16742 { } /* end */
16743};
16744
16745/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016746static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016747{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016748 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016749
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016750 spec->autocfg.hp_pins[0] = 0x15;
16751 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016752}
16753
Takashi Iwaicb53c622007-08-10 17:21:45 +020016754#ifdef CONFIG_SND_HDA_POWER_SAVE
16755#define alc861vd_loopbacks alc880_loopbacks
16756#endif
16757
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016758/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016759#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16760#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16761#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16762#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16763
16764/*
16765 * configuration and preset
16766 */
16767static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16768 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016769 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016770 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016771 [ALC861VD_3ST] = "3stack",
16772 [ALC861VD_3ST_DIG] = "3stack-digout",
16773 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016774 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016775 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016776 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016777 [ALC861VD_AUTO] = "auto",
16778};
16779
16780static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016781 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16782 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016783 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016784 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016785 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016786 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016787 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016788 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016789 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016790 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016791 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016792 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016793 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016794 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016795 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016796 {}
16797};
16798
16799static struct alc_config_preset alc861vd_presets[] = {
16800 [ALC660VD_3ST] = {
16801 .mixers = { alc861vd_3st_mixer },
16802 .init_verbs = { alc861vd_volume_init_verbs,
16803 alc861vd_3stack_init_verbs },
16804 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16805 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016806 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16807 .channel_mode = alc861vd_3stack_2ch_modes,
16808 .input_mux = &alc861vd_capture_source,
16809 },
Mike Crash6963f842007-06-25 12:12:51 +020016810 [ALC660VD_3ST_DIG] = {
16811 .mixers = { alc861vd_3st_mixer },
16812 .init_verbs = { alc861vd_volume_init_verbs,
16813 alc861vd_3stack_init_verbs },
16814 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16815 .dac_nids = alc660vd_dac_nids,
16816 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016817 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16818 .channel_mode = alc861vd_3stack_2ch_modes,
16819 .input_mux = &alc861vd_capture_source,
16820 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016821 [ALC861VD_3ST] = {
16822 .mixers = { alc861vd_3st_mixer },
16823 .init_verbs = { alc861vd_volume_init_verbs,
16824 alc861vd_3stack_init_verbs },
16825 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16826 .dac_nids = alc861vd_dac_nids,
16827 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16828 .channel_mode = alc861vd_3stack_2ch_modes,
16829 .input_mux = &alc861vd_capture_source,
16830 },
16831 [ALC861VD_3ST_DIG] = {
16832 .mixers = { alc861vd_3st_mixer },
16833 .init_verbs = { alc861vd_volume_init_verbs,
16834 alc861vd_3stack_init_verbs },
16835 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16836 .dac_nids = alc861vd_dac_nids,
16837 .dig_out_nid = ALC861VD_DIGOUT_NID,
16838 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16839 .channel_mode = alc861vd_3stack_2ch_modes,
16840 .input_mux = &alc861vd_capture_source,
16841 },
16842 [ALC861VD_6ST_DIG] = {
16843 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16844 .init_verbs = { alc861vd_volume_init_verbs,
16845 alc861vd_6stack_init_verbs },
16846 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16847 .dac_nids = alc861vd_dac_nids,
16848 .dig_out_nid = ALC861VD_DIGOUT_NID,
16849 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16850 .channel_mode = alc861vd_6stack_modes,
16851 .input_mux = &alc861vd_capture_source,
16852 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016853 [ALC861VD_LENOVO] = {
16854 .mixers = { alc861vd_lenovo_mixer },
16855 .init_verbs = { alc861vd_volume_init_verbs,
16856 alc861vd_3stack_init_verbs,
16857 alc861vd_eapd_verbs,
16858 alc861vd_lenovo_unsol_verbs },
16859 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16860 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016861 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16862 .channel_mode = alc861vd_3stack_2ch_modes,
16863 .input_mux = &alc861vd_capture_source,
16864 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016865 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016866 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016867 },
Kailang Yang272a5272007-05-14 11:00:38 +020016868 [ALC861VD_DALLAS] = {
16869 .mixers = { alc861vd_dallas_mixer },
16870 .init_verbs = { alc861vd_dallas_verbs },
16871 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16872 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016873 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16874 .channel_mode = alc861vd_3stack_2ch_modes,
16875 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016876 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016877 .setup = alc861vd_dallas_setup,
16878 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016879 },
16880 [ALC861VD_HP] = {
16881 .mixers = { alc861vd_hp_mixer },
16882 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16883 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16884 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016885 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016886 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16887 .channel_mode = alc861vd_3stack_2ch_modes,
16888 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016889 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016890 .setup = alc861vd_dallas_setup,
16891 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016892 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016893 [ALC660VD_ASUS_V1S] = {
16894 .mixers = { alc861vd_lenovo_mixer },
16895 .init_verbs = { alc861vd_volume_init_verbs,
16896 alc861vd_3stack_init_verbs,
16897 alc861vd_eapd_verbs,
16898 alc861vd_lenovo_unsol_verbs },
16899 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16900 .dac_nids = alc660vd_dac_nids,
16901 .dig_out_nid = ALC861VD_DIGOUT_NID,
16902 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16903 .channel_mode = alc861vd_3stack_2ch_modes,
16904 .input_mux = &alc861vd_capture_source,
16905 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016906 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016907 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016908 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016909};
16910
16911/*
16912 * BIOS auto configuration
16913 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016914static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16915 const struct auto_pin_cfg *cfg)
16916{
Herton Ronaldo Krzesinski71675942010-11-25 00:08:01 -020016917 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016918}
16919
16920
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016921static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16922 hda_nid_t nid, int pin_type, int dac_idx)
16923{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016924 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016925}
16926
16927static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16928{
16929 struct alc_spec *spec = codec->spec;
16930 int i;
16931
16932 for (i = 0; i <= HDA_SIDE; i++) {
16933 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016934 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016935 if (nid)
16936 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016937 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016938 }
16939}
16940
16941
16942static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16943{
16944 struct alc_spec *spec = codec->spec;
16945 hda_nid_t pin;
16946
16947 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016948 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016949 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016950 pin = spec->autocfg.speaker_pins[0];
16951 if (pin)
16952 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016953}
16954
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016955#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16956
16957static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16958{
16959 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016960 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016961 int i;
16962
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016963 for (i = 0; i < cfg->num_inputs; i++) {
16964 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016965 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020016966 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016967 if (nid != ALC861VD_PIN_CD_NID &&
16968 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016969 snd_hda_codec_write(codec, nid, 0,
16970 AC_VERB_SET_AMP_GAIN_MUTE,
16971 AMP_OUT_MUTE);
16972 }
16973 }
16974}
16975
Takashi Iwaif511b012008-08-15 16:46:42 +020016976#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16977
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016978#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16979#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16980
16981/* add playback controls from the parsed DAC table */
16982/* Based on ALC880 version. But ALC861VD has separate,
16983 * different NIDs for mute/unmute switch and volume control */
16984static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16985 const struct auto_pin_cfg *cfg)
16986{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016987 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16988 hda_nid_t nid_v, nid_s;
16989 int i, err;
16990
16991 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016992 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016993 continue;
16994 nid_v = alc861vd_idx_to_mixer_vol(
16995 alc880_dac_to_idx(
16996 spec->multiout.dac_nids[i]));
16997 nid_s = alc861vd_idx_to_mixer_switch(
16998 alc880_dac_to_idx(
16999 spec->multiout.dac_nids[i]));
17000
17001 if (i == 2) {
17002 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017003 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17004 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017005 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
17006 HDA_OUTPUT));
17007 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017008 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017009 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17010 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017011 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
17012 HDA_OUTPUT));
17013 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017014 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017015 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17016 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017017 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
17018 HDA_INPUT));
17019 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017020 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017021 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17022 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017023 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
17024 HDA_INPUT));
17025 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017026 return err;
17027 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020017028 const char *pfx;
17029 if (cfg->line_outs == 1 &&
17030 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
17031 if (!cfg->hp_pins)
17032 pfx = "Speaker";
17033 else
17034 pfx = "PCM";
17035 } else
17036 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017037 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017038 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17039 HDA_OUTPUT));
17040 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017041 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020017042 if (cfg->line_outs == 1 &&
17043 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17044 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017045 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017046 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017047 HDA_INPUT));
17048 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017049 return err;
17050 }
17051 }
17052 return 0;
17053}
17054
17055/* add playback controls for speaker and HP outputs */
17056/* Based on ALC880 version. But ALC861VD has separate,
17057 * different NIDs for mute/unmute switch and volume control */
17058static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
17059 hda_nid_t pin, const char *pfx)
17060{
17061 hda_nid_t nid_v, nid_s;
17062 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017063
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017064 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017065 return 0;
17066
17067 if (alc880_is_fixed_pin(pin)) {
17068 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17069 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017070 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017071 spec->multiout.hp_nid = nid_v;
17072 else
17073 spec->multiout.extra_out_nid[0] = nid_v;
17074 /* control HP volume/switch on the output mixer amp */
17075 nid_v = alc861vd_idx_to_mixer_vol(
17076 alc880_fixed_pin_idx(pin));
17077 nid_s = alc861vd_idx_to_mixer_switch(
17078 alc880_fixed_pin_idx(pin));
17079
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017080 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017081 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17082 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017083 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017084 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017085 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17086 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017087 return err;
17088 } else if (alc880_is_multi_pin(pin)) {
17089 /* set manual connection */
17090 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017091 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017092 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17093 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017094 return err;
17095 }
17096 return 0;
17097}
17098
17099/* parse the BIOS configuration and set up the alc_spec
17100 * return 1 if successful, 0 if the proper config is not found,
17101 * or a negative error code
17102 * Based on ALC880 version - had to change it to override
17103 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17104static int alc861vd_parse_auto_config(struct hda_codec *codec)
17105{
17106 struct alc_spec *spec = codec->spec;
17107 int err;
17108 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17109
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017110 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17111 alc861vd_ignore);
17112 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017113 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017114 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017115 return 0; /* can't find valid BIOS pin config */
17116
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017117 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17118 if (err < 0)
17119 return err;
17120 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17121 if (err < 0)
17122 return err;
17123 err = alc861vd_auto_create_extra_out(spec,
17124 spec->autocfg.speaker_pins[0],
17125 "Speaker");
17126 if (err < 0)
17127 return err;
17128 err = alc861vd_auto_create_extra_out(spec,
17129 spec->autocfg.hp_pins[0],
17130 "Headphone");
17131 if (err < 0)
17132 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017133 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017134 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017135 return err;
17136
17137 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17138
Takashi Iwai757899a2010-07-30 10:48:14 +020017139 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017140
Takashi Iwai603c4012008-07-30 15:01:44 +020017141 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017142 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017143
Takashi Iwaid88897e2008-10-31 15:01:37 +010017144 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017145
17146 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017147 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017148
Takashi Iwai776e1842007-08-29 15:07:11 +020017149 err = alc_auto_add_mic_boost(codec);
17150 if (err < 0)
17151 return err;
17152
Kailang Yang6227cdc2010-02-25 08:36:52 +010017153 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017154
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017155 return 1;
17156}
17157
17158/* additional initialization for auto-configuration model */
17159static void alc861vd_auto_init(struct hda_codec *codec)
17160{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017161 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017162 alc861vd_auto_init_multi_out(codec);
17163 alc861vd_auto_init_hp_out(codec);
17164 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017165 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017166 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017167 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017168 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017169}
17170
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017171enum {
17172 ALC660VD_FIX_ASUS_GPIO1
17173};
17174
17175/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017176static const struct alc_fixup alc861vd_fixups[] = {
17177 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020017178 .verbs = (const struct hda_verb[]) {
17179 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17180 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17181 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17182 { }
17183 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017184 },
17185};
17186
17187static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17188 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17189 {}
17190};
17191
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017192static int patch_alc861vd(struct hda_codec *codec)
17193{
17194 struct alc_spec *spec;
17195 int err, board_config;
17196
17197 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17198 if (spec == NULL)
17199 return -ENOMEM;
17200
17201 codec->spec = spec;
17202
17203 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17204 alc861vd_models,
17205 alc861vd_cfg_tbl);
17206
17207 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017208 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17209 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017210 board_config = ALC861VD_AUTO;
17211 }
17212
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017213 if (board_config == ALC861VD_AUTO)
17214 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017215
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017216 if (board_config == ALC861VD_AUTO) {
17217 /* automatic parse from the BIOS config */
17218 err = alc861vd_parse_auto_config(codec);
17219 if (err < 0) {
17220 alc_free(codec);
17221 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017222 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017223 printk(KERN_INFO
17224 "hda_codec: Cannot set up configuration "
17225 "from BIOS. Using base mode...\n");
17226 board_config = ALC861VD_3ST;
17227 }
17228 }
17229
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017230 err = snd_hda_attach_beep_device(codec, 0x23);
17231 if (err < 0) {
17232 alc_free(codec);
17233 return err;
17234 }
17235
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017236 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017237 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017238
Kailang Yang2f893282008-05-27 12:14:47 +020017239 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017240 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017241 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017242 }
17243
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017244 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17245 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17246
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017247 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17248 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17249
Takashi Iwaidd704692009-08-11 08:45:11 +020017250 if (!spec->adc_nids) {
17251 spec->adc_nids = alc861vd_adc_nids;
17252 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17253 }
17254 if (!spec->capsrc_nids)
17255 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017256
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017257 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017258 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017259
Takashi Iwai2134ea42008-01-10 16:53:55 +010017260 spec->vmaster_nid = 0x02;
17261
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017262 if (board_config == ALC861VD_AUTO)
17263 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
17264
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017265 codec->patch_ops = alc_patch_ops;
17266
17267 if (board_config == ALC861VD_AUTO)
17268 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017269#ifdef CONFIG_SND_HDA_POWER_SAVE
17270 if (!spec->loopback.amplist)
17271 spec->loopback.amplist = alc861vd_loopbacks;
17272#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017273
17274 return 0;
17275}
17276
17277/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017278 * ALC662 support
17279 *
17280 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17281 * configuration. Each pin widget can choose any input DACs and a mixer.
17282 * Each ADC is connected from a mixer of all inputs. This makes possible
17283 * 6-channel independent captures.
17284 *
17285 * In addition, an independent DAC for the multi-playback (not used in this
17286 * driver yet).
17287 */
17288#define ALC662_DIGOUT_NID 0x06
17289#define ALC662_DIGIN_NID 0x0a
17290
17291static hda_nid_t alc662_dac_nids[4] = {
17292 /* front, rear, clfe, rear_surr */
17293 0x02, 0x03, 0x04
17294};
17295
Kailang Yang622e84c2009-04-21 07:39:04 +020017296static hda_nid_t alc272_dac_nids[2] = {
17297 0x02, 0x03
17298};
17299
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017300static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017301 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017302 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017303};
Takashi Iwaie1406342008-02-11 18:32:32 +010017304
Kailang Yang622e84c2009-04-21 07:39:04 +020017305static hda_nid_t alc272_adc_nids[1] = {
17306 /* ADC1-2 */
17307 0x08,
17308};
17309
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017310static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017311static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17312
Takashi Iwaie1406342008-02-11 18:32:32 +010017313
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017314/* input MUX */
17315/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017316static struct hda_input_mux alc662_capture_source = {
17317 .num_items = 4,
17318 .items = {
17319 { "Mic", 0x0 },
17320 { "Front Mic", 0x1 },
17321 { "Line", 0x2 },
17322 { "CD", 0x4 },
17323 },
17324};
17325
17326static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17327 .num_items = 2,
17328 .items = {
17329 { "Mic", 0x1 },
17330 { "Line", 0x2 },
17331 },
17332};
Kailang Yang291702f2007-10-16 14:28:03 +020017333
Kailang Yang6dda9f42008-05-27 12:05:31 +020017334static struct hda_input_mux alc663_capture_source = {
17335 .num_items = 3,
17336 .items = {
17337 { "Mic", 0x0 },
17338 { "Front Mic", 0x1 },
17339 { "Line", 0x2 },
17340 },
17341};
17342
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017343#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017344static struct hda_input_mux alc272_nc10_capture_source = {
17345 .num_items = 16,
17346 .items = {
17347 { "Autoselect Mic", 0x0 },
17348 { "Internal Mic", 0x1 },
17349 { "In-0x02", 0x2 },
17350 { "In-0x03", 0x3 },
17351 { "In-0x04", 0x4 },
17352 { "In-0x05", 0x5 },
17353 { "In-0x06", 0x6 },
17354 { "In-0x07", 0x7 },
17355 { "In-0x08", 0x8 },
17356 { "In-0x09", 0x9 },
17357 { "In-0x0a", 0x0a },
17358 { "In-0x0b", 0x0b },
17359 { "In-0x0c", 0x0c },
17360 { "In-0x0d", 0x0d },
17361 { "In-0x0e", 0x0e },
17362 { "In-0x0f", 0x0f },
17363 },
17364};
17365#endif
17366
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017367/*
17368 * 2ch mode
17369 */
17370static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17371 { 2, NULL }
17372};
17373
17374/*
17375 * 2ch mode
17376 */
17377static struct hda_verb alc662_3ST_ch2_init[] = {
17378 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17379 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17380 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17381 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17382 { } /* end */
17383};
17384
17385/*
17386 * 6ch mode
17387 */
17388static struct hda_verb alc662_3ST_ch6_init[] = {
17389 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17390 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17391 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17392 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17393 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17394 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17395 { } /* end */
17396};
17397
17398static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17399 { 2, alc662_3ST_ch2_init },
17400 { 6, alc662_3ST_ch6_init },
17401};
17402
17403/*
17404 * 2ch mode
17405 */
17406static struct hda_verb alc662_sixstack_ch6_init[] = {
17407 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17408 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17409 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17410 { } /* end */
17411};
17412
17413/*
17414 * 6ch mode
17415 */
17416static struct hda_verb alc662_sixstack_ch8_init[] = {
17417 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17418 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17419 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17420 { } /* end */
17421};
17422
17423static struct hda_channel_mode alc662_5stack_modes[2] = {
17424 { 2, alc662_sixstack_ch6_init },
17425 { 6, alc662_sixstack_ch8_init },
17426};
17427
17428/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17429 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17430 */
17431
17432static struct snd_kcontrol_new alc662_base_mixer[] = {
17433 /* output mixer control */
17434 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017435 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017436 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017437 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017438 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17439 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017440 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17441 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017442 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17443
17444 /*Input mixer control */
17445 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17446 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17447 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17448 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17449 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17450 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17451 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17452 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017453 { } /* end */
17454};
17455
17456static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17457 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017458 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017459 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17460 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17461 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17462 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17463 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17464 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17465 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17466 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17467 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017468 { } /* end */
17469};
17470
17471static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17472 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017473 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017474 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017475 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017476 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17477 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017478 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17479 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017480 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17481 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17482 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17483 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17484 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17485 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17486 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17487 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17488 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017489 { } /* end */
17490};
17491
17492static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17493 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17494 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017495 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17496 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017497 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17498 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17499 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17500 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17501 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017502 { } /* end */
17503};
17504
Kailang Yang291702f2007-10-16 14:28:03 +020017505static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017506 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17507 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017508
17509 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
17510 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17511 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17512
17513 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17514 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17515 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17516 { } /* end */
17517};
17518
Kailang Yang8c427222008-01-10 13:03:59 +010017519static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017520 ALC262_HIPPO_MASTER_SWITCH,
17521 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017522 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017523 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17524 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017525 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17526 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17527 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17528 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17529 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17530 { } /* end */
17531};
17532
Kailang Yangf1d4e282008-08-26 14:03:29 +020017533static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17534 .ops = &snd_hda_bind_vol,
17535 .values = {
17536 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17537 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17538 0
17539 },
17540};
17541
17542static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17543 .ops = &snd_hda_bind_sw,
17544 .values = {
17545 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17546 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17547 0
17548 },
17549};
17550
Kailang Yang6dda9f42008-05-27 12:05:31 +020017551static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017552 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17553 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17554 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17555 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17556 { } /* end */
17557};
17558
17559static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17560 .ops = &snd_hda_bind_sw,
17561 .values = {
17562 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17563 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17564 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17565 0
17566 },
17567};
17568
17569static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17570 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17571 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17572 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17573 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17574 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17575 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17576
17577 { } /* end */
17578};
17579
17580static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17581 .ops = &snd_hda_bind_sw,
17582 .values = {
17583 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17584 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17585 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17586 0
17587 },
17588};
17589
17590static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17591 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17592 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17593 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17594 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17595 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17596 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17597 { } /* end */
17598};
17599
17600static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017601 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17602 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017603 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17604 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17605 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17606 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17607 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17608 { } /* end */
17609};
17610
17611static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17612 .ops = &snd_hda_bind_vol,
17613 .values = {
17614 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17615 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17616 0
17617 },
17618};
17619
17620static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17621 .ops = &snd_hda_bind_sw,
17622 .values = {
17623 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17624 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17625 0
17626 },
17627};
17628
17629static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17630 HDA_BIND_VOL("Master Playback Volume",
17631 &alc663_asus_two_bind_master_vol),
17632 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17633 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017634 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17635 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17636 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017637 { } /* end */
17638};
17639
17640static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17641 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17642 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17643 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17644 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17645 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17646 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017647 { } /* end */
17648};
17649
17650static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17651 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17652 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17653 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17654 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17655 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17656
17657 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17658 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17659 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17660 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17661 { } /* end */
17662};
17663
17664static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17665 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17666 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17667 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17668
17669 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17670 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17671 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17672 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17673 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17674 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17675 { } /* end */
17676};
17677
Kailang Yangebb83ee2009-12-17 12:23:00 +010017678static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17679 .ops = &snd_hda_bind_sw,
17680 .values = {
17681 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17682 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17683 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17684 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17685 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17686 0
17687 },
17688};
17689
17690static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17691 .ops = &snd_hda_bind_sw,
17692 .values = {
17693 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17694 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17695 0
17696 },
17697};
17698
17699static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17700 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17701 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17702 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17703 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17704 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17705 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17706 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17709 { } /* end */
17710};
17711
17712static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17713 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17714 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17715 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17716 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17717 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17718 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17719 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17720 { } /* end */
17721};
17722
17723
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017724static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17725 {
17726 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17727 .name = "Channel Mode",
17728 .info = alc_ch_mode_info,
17729 .get = alc_ch_mode_get,
17730 .put = alc_ch_mode_put,
17731 },
17732 { } /* end */
17733};
17734
17735static struct hda_verb alc662_init_verbs[] = {
17736 /* ADC: mute amp left and right */
17737 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17738 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017739
Kailang Yangb60dd392007-09-20 12:50:29 +020017740 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17741 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17742 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17743 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17744 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17745 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017746
17747 /* Front Pin: output 0 (0x0c) */
17748 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17749 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17750
17751 /* Rear Pin: output 1 (0x0d) */
17752 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17753 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17754
17755 /* CLFE Pin: output 2 (0x0e) */
17756 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17757 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17758
17759 /* Mic (rear) pin: input vref at 80% */
17760 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17761 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17762 /* Front Mic pin: input vref at 80% */
17763 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17764 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17765 /* Line In pin: input */
17766 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17767 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17768 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17769 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17770 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17771 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17772 /* CD pin widget for input */
17773 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17774
17775 /* FIXME: use matrix-type input source selection */
17776 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17777 /* Input mixer */
17778 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017779 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017780
17781 /* always trun on EAPD */
17782 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17783 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17784
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017785 { }
17786};
17787
Kailang Yangcec27c82010-02-04 14:18:18 +010017788static struct hda_verb alc663_init_verbs[] = {
17789 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17790 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17791 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17792 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17793 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17794 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17795 { }
17796};
17797
17798static struct hda_verb alc272_init_verbs[] = {
17799 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17800 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17801 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17802 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17803 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17804 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17805 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17806 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17807 { }
17808};
17809
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017810static struct hda_verb alc662_sue_init_verbs[] = {
17811 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17812 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017813 {}
17814};
17815
17816static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17817 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17818 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17819 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017820};
17821
Kailang Yang8c427222008-01-10 13:03:59 +010017822/* Set Unsolicited Event*/
17823static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17824 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17825 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17826 {}
17827};
17828
Kailang Yang6dda9f42008-05-27 12:05:31 +020017829static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017830 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17831 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017832 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17833 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017834 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17835 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17836 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017837 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17838 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17839 {}
17840};
17841
Kailang Yangf1d4e282008-08-26 14:03:29 +020017842static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17843 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17844 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17845 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17846 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17847 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17848 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17849 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17850 {}
17851};
17852
17853static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17854 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17855 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17856 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17857 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17858 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17859 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17860 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17861 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17862 {}
17863};
17864
17865static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17866 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17867 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17868 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17869 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17870 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17871 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17872 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17873 {}
17874};
17875
17876static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17877 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17878 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17879 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17880 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17881 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17882 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17883 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17884 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17885 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17886 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17887 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17888 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17889 {}
17890};
17891
17892static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17893 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17894 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17895 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17896 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17897 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17898 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17899 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17900 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17901 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17902 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17903 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17904 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17905 {}
17906};
17907
Kailang Yang6dda9f42008-05-27 12:05:31 +020017908static struct hda_verb alc663_g71v_init_verbs[] = {
17909 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17910 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17911 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17912
17913 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17914 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17915 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17916
17917 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17918 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17919 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17920 {}
17921};
17922
17923static struct hda_verb alc663_g50v_init_verbs[] = {
17924 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17925 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17926 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17927
17928 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17929 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17930 {}
17931};
17932
Kailang Yangf1d4e282008-08-26 14:03:29 +020017933static struct hda_verb alc662_ecs_init_verbs[] = {
17934 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17935 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17936 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17937 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17938 {}
17939};
17940
Kailang Yang622e84c2009-04-21 07:39:04 +020017941static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17942 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17943 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17944 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17945 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17946 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17947 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17948 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17949 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17950 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17951 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17952 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17953 {}
17954};
17955
17956static struct hda_verb alc272_dell_init_verbs[] = {
17957 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17958 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17959 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17960 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17961 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17962 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17963 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17964 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17965 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17966 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17967 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17968 {}
17969};
17970
Kailang Yangebb83ee2009-12-17 12:23:00 +010017971static struct hda_verb alc663_mode7_init_verbs[] = {
17972 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17973 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17974 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17975 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17976 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17977 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17978 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17979 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17980 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17981 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17982 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17983 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17984 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17985 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17986 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17987 {}
17988};
17989
17990static struct hda_verb alc663_mode8_init_verbs[] = {
17991 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17992 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17993 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17994 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17995 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17996 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17997 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17998 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17999 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18000 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18001 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18002 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18003 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18004 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18005 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18006 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18007 {}
18008};
18009
Kailang Yangf1d4e282008-08-26 14:03:29 +020018010static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
18011 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
18012 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
18013 { } /* end */
18014};
18015
Kailang Yang622e84c2009-04-21 07:39:04 +020018016static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
18017 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18018 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18019 { } /* end */
18020};
18021
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018022static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
18023{
18024 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018025 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018026
Wu Fengguang864f92b2009-11-18 12:38:02 +080018027 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018028 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018029
Takashi Iwai47fd8302007-08-10 17:11:07 +020018030 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18031 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018032}
18033
18034static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
18035{
18036 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018037 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018038
Wu Fengguang864f92b2009-11-18 12:38:02 +080018039 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018040 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018041
Takashi Iwai47fd8302007-08-10 17:11:07 +020018042 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18043 HDA_AMP_MUTE, bits);
18044 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18045 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018046}
18047
18048static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
18049 unsigned int res)
18050{
18051 if ((res >> 26) == ALC880_HP_EVENT)
18052 alc662_lenovo_101e_all_automute(codec);
18053 if ((res >> 26) == ALC880_FRONT_EVENT)
18054 alc662_lenovo_101e_ispeaker_automute(codec);
18055}
18056
Kailang Yang291702f2007-10-16 14:28:03 +020018057/* unsolicited event for HP jack sensing */
18058static void alc662_eeepc_unsol_event(struct hda_codec *codec,
18059 unsigned int res)
18060{
Kailang Yang291702f2007-10-16 14:28:03 +020018061 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018062 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020018063 else
18064 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020018065}
18066
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018067static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020018068{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018069 struct alc_spec *spec = codec->spec;
18070
18071 alc262_hippo1_setup(codec);
18072 spec->ext_mic.pin = 0x18;
18073 spec->ext_mic.mux_idx = 0;
18074 spec->int_mic.pin = 0x19;
18075 spec->int_mic.mux_idx = 1;
18076 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018077}
18078
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018079static void alc662_eeepc_inithook(struct hda_codec *codec)
18080{
18081 alc262_hippo_automute(codec);
18082 alc_mic_automute(codec);
18083}
18084
18085static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018086{
Takashi Iwai42171c12009-05-08 14:11:43 +020018087 struct alc_spec *spec = codec->spec;
18088
18089 spec->autocfg.hp_pins[0] = 0x14;
18090 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010018091}
18092
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018093#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
18094
Kailang Yang6dda9f42008-05-27 12:05:31 +020018095static void alc663_m51va_speaker_automute(struct hda_codec *codec)
18096{
18097 unsigned int present;
18098 unsigned char bits;
18099
Wu Fengguang864f92b2009-11-18 12:38:02 +080018100 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018101 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018102 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018103 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018104 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018105 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018106}
18107
18108static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
18109{
18110 unsigned int present;
18111 unsigned char bits;
18112
Wu Fengguang864f92b2009-11-18 12:38:02 +080018113 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018114 bits = present ? HDA_AMP_MUTE : 0;
18115 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018116 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018117 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018118 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018119 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018120 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018121 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018122 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018123}
18124
18125static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18126{
18127 unsigned int present;
18128 unsigned char bits;
18129
Wu Fengguang864f92b2009-11-18 12:38:02 +080018130 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018131 bits = present ? HDA_AMP_MUTE : 0;
18132 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018133 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018134 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018135 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018136 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018137 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018138 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018139 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018140}
18141
18142static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18143{
18144 unsigned int present;
18145 unsigned char bits;
18146
Wu Fengguang864f92b2009-11-18 12:38:02 +080018147 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018148 bits = present ? 0 : PIN_OUT;
18149 snd_hda_codec_write(codec, 0x14, 0,
18150 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18151}
18152
18153static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18154{
18155 unsigned int present1, present2;
18156
Wu Fengguang864f92b2009-11-18 12:38:02 +080018157 present1 = snd_hda_jack_detect(codec, 0x21);
18158 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018159
18160 if (present1 || present2) {
18161 snd_hda_codec_write_cache(codec, 0x14, 0,
18162 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18163 } else {
18164 snd_hda_codec_write_cache(codec, 0x14, 0,
18165 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18166 }
18167}
18168
18169static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18170{
18171 unsigned int present1, present2;
18172
Wu Fengguang864f92b2009-11-18 12:38:02 +080018173 present1 = snd_hda_jack_detect(codec, 0x1b);
18174 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018175
18176 if (present1 || present2) {
18177 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018178 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018179 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018180 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018181 } else {
18182 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018183 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018184 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018185 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018186 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018187}
18188
Kailang Yangebb83ee2009-12-17 12:23:00 +010018189static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18190{
18191 unsigned int present1, present2;
18192
18193 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18194 AC_VERB_GET_PIN_SENSE, 0)
18195 & AC_PINSENSE_PRESENCE;
18196 present2 = snd_hda_codec_read(codec, 0x21, 0,
18197 AC_VERB_GET_PIN_SENSE, 0)
18198 & AC_PINSENSE_PRESENCE;
18199
18200 if (present1 || present2) {
18201 snd_hda_codec_write_cache(codec, 0x14, 0,
18202 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18203 snd_hda_codec_write_cache(codec, 0x17, 0,
18204 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18205 } else {
18206 snd_hda_codec_write_cache(codec, 0x14, 0,
18207 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18208 snd_hda_codec_write_cache(codec, 0x17, 0,
18209 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18210 }
18211}
18212
18213static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18214{
18215 unsigned int present1, present2;
18216
18217 present1 = snd_hda_codec_read(codec, 0x21, 0,
18218 AC_VERB_GET_PIN_SENSE, 0)
18219 & AC_PINSENSE_PRESENCE;
18220 present2 = snd_hda_codec_read(codec, 0x15, 0,
18221 AC_VERB_GET_PIN_SENSE, 0)
18222 & AC_PINSENSE_PRESENCE;
18223
18224 if (present1 || present2) {
18225 snd_hda_codec_write_cache(codec, 0x14, 0,
18226 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18227 snd_hda_codec_write_cache(codec, 0x17, 0,
18228 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18229 } else {
18230 snd_hda_codec_write_cache(codec, 0x14, 0,
18231 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18232 snd_hda_codec_write_cache(codec, 0x17, 0,
18233 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18234 }
18235}
18236
Kailang Yang6dda9f42008-05-27 12:05:31 +020018237static void alc663_m51va_unsol_event(struct hda_codec *codec,
18238 unsigned int res)
18239{
18240 switch (res >> 26) {
18241 case ALC880_HP_EVENT:
18242 alc663_m51va_speaker_automute(codec);
18243 break;
18244 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018245 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018246 break;
18247 }
18248}
18249
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018250static void alc663_m51va_setup(struct hda_codec *codec)
18251{
18252 struct alc_spec *spec = codec->spec;
18253 spec->ext_mic.pin = 0x18;
18254 spec->ext_mic.mux_idx = 0;
18255 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018256 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018257 spec->auto_mic = 1;
18258}
18259
Kailang Yang6dda9f42008-05-27 12:05:31 +020018260static void alc663_m51va_inithook(struct hda_codec *codec)
18261{
18262 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018263 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018264}
18265
Kailang Yangf1d4e282008-08-26 14:03:29 +020018266/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018267#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018268
18269static void alc663_mode1_setup(struct hda_codec *codec)
18270{
18271 struct alc_spec *spec = codec->spec;
18272 spec->ext_mic.pin = 0x18;
18273 spec->ext_mic.mux_idx = 0;
18274 spec->int_mic.pin = 0x19;
18275 spec->int_mic.mux_idx = 1;
18276 spec->auto_mic = 1;
18277}
18278
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018279#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018280
Kailang Yangf1d4e282008-08-26 14:03:29 +020018281/* ***************** Mode2 ******************************/
18282static void alc662_mode2_unsol_event(struct hda_codec *codec,
18283 unsigned int res)
18284{
18285 switch (res >> 26) {
18286 case ALC880_HP_EVENT:
18287 alc662_f5z_speaker_automute(codec);
18288 break;
18289 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018290 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018291 break;
18292 }
18293}
18294
Kailang Yangebb83ee2009-12-17 12:23:00 +010018295#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018296
Kailang Yangf1d4e282008-08-26 14:03:29 +020018297static void alc662_mode2_inithook(struct hda_codec *codec)
18298{
18299 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018300 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018301}
18302/* ***************** Mode3 ******************************/
18303static void alc663_mode3_unsol_event(struct hda_codec *codec,
18304 unsigned int res)
18305{
18306 switch (res >> 26) {
18307 case ALC880_HP_EVENT:
18308 alc663_two_hp_m1_speaker_automute(codec);
18309 break;
18310 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018311 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018312 break;
18313 }
18314}
18315
Kailang Yangebb83ee2009-12-17 12:23:00 +010018316#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018317
Kailang Yangf1d4e282008-08-26 14:03:29 +020018318static void alc663_mode3_inithook(struct hda_codec *codec)
18319{
18320 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018321 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018322}
18323/* ***************** Mode4 ******************************/
18324static void alc663_mode4_unsol_event(struct hda_codec *codec,
18325 unsigned int res)
18326{
18327 switch (res >> 26) {
18328 case ALC880_HP_EVENT:
18329 alc663_21jd_two_speaker_automute(codec);
18330 break;
18331 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018332 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018333 break;
18334 }
18335}
18336
Kailang Yangebb83ee2009-12-17 12:23:00 +010018337#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018338
Kailang Yangf1d4e282008-08-26 14:03:29 +020018339static void alc663_mode4_inithook(struct hda_codec *codec)
18340{
18341 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018342 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018343}
18344/* ***************** Mode5 ******************************/
18345static void alc663_mode5_unsol_event(struct hda_codec *codec,
18346 unsigned int res)
18347{
18348 switch (res >> 26) {
18349 case ALC880_HP_EVENT:
18350 alc663_15jd_two_speaker_automute(codec);
18351 break;
18352 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018353 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018354 break;
18355 }
18356}
18357
Kailang Yangebb83ee2009-12-17 12:23:00 +010018358#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018359
Kailang Yangf1d4e282008-08-26 14:03:29 +020018360static void alc663_mode5_inithook(struct hda_codec *codec)
18361{
18362 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018363 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018364}
18365/* ***************** Mode6 ******************************/
18366static void alc663_mode6_unsol_event(struct hda_codec *codec,
18367 unsigned int res)
18368{
18369 switch (res >> 26) {
18370 case ALC880_HP_EVENT:
18371 alc663_two_hp_m2_speaker_automute(codec);
18372 break;
18373 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018374 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018375 break;
18376 }
18377}
18378
Kailang Yangebb83ee2009-12-17 12:23:00 +010018379#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018380
Kailang Yangf1d4e282008-08-26 14:03:29 +020018381static void alc663_mode6_inithook(struct hda_codec *codec)
18382{
18383 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018384 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018385}
18386
Kailang Yangebb83ee2009-12-17 12:23:00 +010018387/* ***************** Mode7 ******************************/
18388static void alc663_mode7_unsol_event(struct hda_codec *codec,
18389 unsigned int res)
18390{
18391 switch (res >> 26) {
18392 case ALC880_HP_EVENT:
18393 alc663_two_hp_m7_speaker_automute(codec);
18394 break;
18395 case ALC880_MIC_EVENT:
18396 alc_mic_automute(codec);
18397 break;
18398 }
18399}
18400
18401#define alc663_mode7_setup alc663_mode1_setup
18402
18403static void alc663_mode7_inithook(struct hda_codec *codec)
18404{
18405 alc663_two_hp_m7_speaker_automute(codec);
18406 alc_mic_automute(codec);
18407}
18408
18409/* ***************** Mode8 ******************************/
18410static void alc663_mode8_unsol_event(struct hda_codec *codec,
18411 unsigned int res)
18412{
18413 switch (res >> 26) {
18414 case ALC880_HP_EVENT:
18415 alc663_two_hp_m8_speaker_automute(codec);
18416 break;
18417 case ALC880_MIC_EVENT:
18418 alc_mic_automute(codec);
18419 break;
18420 }
18421}
18422
18423#define alc663_mode8_setup alc663_m51va_setup
18424
18425static void alc663_mode8_inithook(struct hda_codec *codec)
18426{
18427 alc663_two_hp_m8_speaker_automute(codec);
18428 alc_mic_automute(codec);
18429}
18430
Kailang Yang6dda9f42008-05-27 12:05:31 +020018431static void alc663_g71v_hp_automute(struct hda_codec *codec)
18432{
18433 unsigned int present;
18434 unsigned char bits;
18435
Wu Fengguang864f92b2009-11-18 12:38:02 +080018436 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018437 bits = present ? HDA_AMP_MUTE : 0;
18438 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18439 HDA_AMP_MUTE, bits);
18440 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18441 HDA_AMP_MUTE, bits);
18442}
18443
18444static void alc663_g71v_front_automute(struct hda_codec *codec)
18445{
18446 unsigned int present;
18447 unsigned char bits;
18448
Wu Fengguang864f92b2009-11-18 12:38:02 +080018449 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018450 bits = present ? HDA_AMP_MUTE : 0;
18451 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18452 HDA_AMP_MUTE, bits);
18453}
18454
18455static void alc663_g71v_unsol_event(struct hda_codec *codec,
18456 unsigned int res)
18457{
18458 switch (res >> 26) {
18459 case ALC880_HP_EVENT:
18460 alc663_g71v_hp_automute(codec);
18461 break;
18462 case ALC880_FRONT_EVENT:
18463 alc663_g71v_front_automute(codec);
18464 break;
18465 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018466 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018467 break;
18468 }
18469}
18470
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018471#define alc663_g71v_setup alc663_m51va_setup
18472
Kailang Yang6dda9f42008-05-27 12:05:31 +020018473static void alc663_g71v_inithook(struct hda_codec *codec)
18474{
18475 alc663_g71v_front_automute(codec);
18476 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018477 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018478}
18479
18480static void alc663_g50v_unsol_event(struct hda_codec *codec,
18481 unsigned int res)
18482{
18483 switch (res >> 26) {
18484 case ALC880_HP_EVENT:
18485 alc663_m51va_speaker_automute(codec);
18486 break;
18487 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018488 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018489 break;
18490 }
18491}
18492
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018493#define alc663_g50v_setup alc663_m51va_setup
18494
Kailang Yang6dda9f42008-05-27 12:05:31 +020018495static void alc663_g50v_inithook(struct hda_codec *codec)
18496{
18497 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018498 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018499}
18500
Kailang Yangf1d4e282008-08-26 14:03:29 +020018501static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18502 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018503 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018504
18505 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
18506 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18507 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
18508
18509 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
18510 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18511 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18512 { } /* end */
18513};
18514
Chris Pockelé9541ba12009-05-12 08:08:53 +020018515static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18516 /* Master Playback automatically created from Speaker and Headphone */
18517 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18518 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18519 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18520 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18521
18522 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18523 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
18524 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
18525
18526 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18527 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18528 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
18529 { } /* end */
18530};
18531
Takashi Iwaicb53c622007-08-10 17:21:45 +020018532#ifdef CONFIG_SND_HDA_POWER_SAVE
18533#define alc662_loopbacks alc880_loopbacks
18534#endif
18535
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018536
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018537/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018538#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18539#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18540#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18541#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18542
18543/*
18544 * configuration and preset
18545 */
18546static const char *alc662_models[ALC662_MODEL_LAST] = {
18547 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18548 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18549 [ALC662_3ST_6ch] = "3stack-6ch",
18550 [ALC662_5ST_DIG] = "6stack-dig",
18551 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018552 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018553 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018554 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018555 [ALC663_ASUS_M51VA] = "m51va",
18556 [ALC663_ASUS_G71V] = "g71v",
18557 [ALC663_ASUS_H13] = "h13",
18558 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018559 [ALC663_ASUS_MODE1] = "asus-mode1",
18560 [ALC662_ASUS_MODE2] = "asus-mode2",
18561 [ALC663_ASUS_MODE3] = "asus-mode3",
18562 [ALC663_ASUS_MODE4] = "asus-mode4",
18563 [ALC663_ASUS_MODE5] = "asus-mode5",
18564 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018565 [ALC663_ASUS_MODE7] = "asus-mode7",
18566 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018567 [ALC272_DELL] = "dell",
18568 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018569 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018570 [ALC662_AUTO] = "auto",
18571};
18572
18573static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018574 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018575 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18576 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018577 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18578 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018579 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018580 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18581 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18582 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18583 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018584 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18585 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018586 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018587 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18588 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18589 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18590 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18591 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018592 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018593 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18594 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018595 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18596 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18597 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18598 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018599 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018600 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18601 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18602 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018603 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18604 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18605 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18606 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018607 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018608 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18609 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018610 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018611 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18612 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18613 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018614 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018615 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018616 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18617 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018618 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18619 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18620 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018621 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018622 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18623 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018624 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018625 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018626 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018627 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18628 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18629 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018630 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018631 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18632 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018633 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018634 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018635 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018636 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018637 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18638 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018639 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018640 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018641 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18642 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018643 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018644 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018645 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018646 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018647 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018648 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018649 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18650 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018651 {}
18652};
18653
18654static struct alc_config_preset alc662_presets[] = {
18655 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018656 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018657 .init_verbs = { alc662_init_verbs },
18658 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18659 .dac_nids = alc662_dac_nids,
18660 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018661 .dig_in_nid = ALC662_DIGIN_NID,
18662 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18663 .channel_mode = alc662_3ST_2ch_modes,
18664 .input_mux = &alc662_capture_source,
18665 },
18666 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018667 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018668 .init_verbs = { alc662_init_verbs },
18669 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18670 .dac_nids = alc662_dac_nids,
18671 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018672 .dig_in_nid = ALC662_DIGIN_NID,
18673 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18674 .channel_mode = alc662_3ST_6ch_modes,
18675 .need_dac_fix = 1,
18676 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018677 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018678 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018679 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018680 .init_verbs = { alc662_init_verbs },
18681 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18682 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018683 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18684 .channel_mode = alc662_3ST_6ch_modes,
18685 .need_dac_fix = 1,
18686 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018687 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018688 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018689 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018690 .init_verbs = { alc662_init_verbs },
18691 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18692 .dac_nids = alc662_dac_nids,
18693 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018694 .dig_in_nid = ALC662_DIGIN_NID,
18695 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18696 .channel_mode = alc662_5stack_modes,
18697 .input_mux = &alc662_capture_source,
18698 },
18699 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018700 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018701 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18702 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18703 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018704 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18705 .channel_mode = alc662_3ST_2ch_modes,
18706 .input_mux = &alc662_lenovo_101e_capture_source,
18707 .unsol_event = alc662_lenovo_101e_unsol_event,
18708 .init_hook = alc662_lenovo_101e_all_automute,
18709 },
Kailang Yang291702f2007-10-16 14:28:03 +020018710 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018711 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018712 .init_verbs = { alc662_init_verbs,
18713 alc662_eeepc_sue_init_verbs },
18714 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18715 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018716 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18717 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018718 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018719 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018720 .init_hook = alc662_eeepc_inithook,
18721 },
Kailang Yang8c427222008-01-10 13:03:59 +010018722 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018723 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018724 alc662_chmode_mixer },
18725 .init_verbs = { alc662_init_verbs,
18726 alc662_eeepc_ep20_sue_init_verbs },
18727 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18728 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018729 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18730 .channel_mode = alc662_3ST_6ch_modes,
18731 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018732 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018733 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018734 .init_hook = alc662_eeepc_ep20_inithook,
18735 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018736 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018737 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018738 .init_verbs = { alc662_init_verbs,
18739 alc662_ecs_init_verbs },
18740 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18741 .dac_nids = alc662_dac_nids,
18742 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18743 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018744 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018745 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018746 .init_hook = alc662_eeepc_inithook,
18747 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018748 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018749 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018750 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18751 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18752 .dac_nids = alc662_dac_nids,
18753 .dig_out_nid = ALC662_DIGOUT_NID,
18754 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18755 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018756 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018757 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018758 .init_hook = alc663_m51va_inithook,
18759 },
18760 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018761 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018762 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18763 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18764 .dac_nids = alc662_dac_nids,
18765 .dig_out_nid = ALC662_DIGOUT_NID,
18766 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18767 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018768 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018769 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018770 .init_hook = alc663_g71v_inithook,
18771 },
18772 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018773 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018774 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18775 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18776 .dac_nids = alc662_dac_nids,
18777 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18778 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018779 .unsol_event = alc663_m51va_unsol_event,
18780 .init_hook = alc663_m51va_inithook,
18781 },
18782 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018783 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018784 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18785 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18786 .dac_nids = alc662_dac_nids,
18787 .dig_out_nid = ALC662_DIGOUT_NID,
18788 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18789 .channel_mode = alc662_3ST_6ch_modes,
18790 .input_mux = &alc663_capture_source,
18791 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018792 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018793 .init_hook = alc663_g50v_inithook,
18794 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018795 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018796 .mixers = { alc663_m51va_mixer },
18797 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018798 .init_verbs = { alc662_init_verbs,
18799 alc663_21jd_amic_init_verbs },
18800 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18801 .hp_nid = 0x03,
18802 .dac_nids = alc662_dac_nids,
18803 .dig_out_nid = ALC662_DIGOUT_NID,
18804 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18805 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018806 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018807 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018808 .init_hook = alc663_mode1_inithook,
18809 },
18810 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018811 .mixers = { alc662_1bjd_mixer },
18812 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018813 .init_verbs = { alc662_init_verbs,
18814 alc662_1bjd_amic_init_verbs },
18815 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18816 .dac_nids = alc662_dac_nids,
18817 .dig_out_nid = ALC662_DIGOUT_NID,
18818 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18819 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018820 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018821 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018822 .init_hook = alc662_mode2_inithook,
18823 },
18824 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018825 .mixers = { alc663_two_hp_m1_mixer },
18826 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018827 .init_verbs = { alc662_init_verbs,
18828 alc663_two_hp_amic_m1_init_verbs },
18829 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18830 .hp_nid = 0x03,
18831 .dac_nids = alc662_dac_nids,
18832 .dig_out_nid = ALC662_DIGOUT_NID,
18833 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18834 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018835 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018836 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018837 .init_hook = alc663_mode3_inithook,
18838 },
18839 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018840 .mixers = { alc663_asus_21jd_clfe_mixer },
18841 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018842 .init_verbs = { alc662_init_verbs,
18843 alc663_21jd_amic_init_verbs},
18844 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18845 .hp_nid = 0x03,
18846 .dac_nids = alc662_dac_nids,
18847 .dig_out_nid = ALC662_DIGOUT_NID,
18848 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18849 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018850 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018851 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018852 .init_hook = alc663_mode4_inithook,
18853 },
18854 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018855 .mixers = { alc663_asus_15jd_clfe_mixer },
18856 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018857 .init_verbs = { alc662_init_verbs,
18858 alc663_15jd_amic_init_verbs },
18859 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18860 .hp_nid = 0x03,
18861 .dac_nids = alc662_dac_nids,
18862 .dig_out_nid = ALC662_DIGOUT_NID,
18863 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18864 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018865 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018866 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018867 .init_hook = alc663_mode5_inithook,
18868 },
18869 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018870 .mixers = { alc663_two_hp_m2_mixer },
18871 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018872 .init_verbs = { alc662_init_verbs,
18873 alc663_two_hp_amic_m2_init_verbs },
18874 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18875 .hp_nid = 0x03,
18876 .dac_nids = alc662_dac_nids,
18877 .dig_out_nid = ALC662_DIGOUT_NID,
18878 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18879 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018880 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018881 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018882 .init_hook = alc663_mode6_inithook,
18883 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018884 [ALC663_ASUS_MODE7] = {
18885 .mixers = { alc663_mode7_mixer },
18886 .cap_mixer = alc662_auto_capture_mixer,
18887 .init_verbs = { alc662_init_verbs,
18888 alc663_mode7_init_verbs },
18889 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18890 .hp_nid = 0x03,
18891 .dac_nids = alc662_dac_nids,
18892 .dig_out_nid = ALC662_DIGOUT_NID,
18893 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18894 .channel_mode = alc662_3ST_2ch_modes,
18895 .unsol_event = alc663_mode7_unsol_event,
18896 .setup = alc663_mode7_setup,
18897 .init_hook = alc663_mode7_inithook,
18898 },
18899 [ALC663_ASUS_MODE8] = {
18900 .mixers = { alc663_mode8_mixer },
18901 .cap_mixer = alc662_auto_capture_mixer,
18902 .init_verbs = { alc662_init_verbs,
18903 alc663_mode8_init_verbs },
18904 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18905 .hp_nid = 0x03,
18906 .dac_nids = alc662_dac_nids,
18907 .dig_out_nid = ALC662_DIGOUT_NID,
18908 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18909 .channel_mode = alc662_3ST_2ch_modes,
18910 .unsol_event = alc663_mode8_unsol_event,
18911 .setup = alc663_mode8_setup,
18912 .init_hook = alc663_mode8_inithook,
18913 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018914 [ALC272_DELL] = {
18915 .mixers = { alc663_m51va_mixer },
18916 .cap_mixer = alc272_auto_capture_mixer,
18917 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18918 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18919 .dac_nids = alc662_dac_nids,
18920 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18921 .adc_nids = alc272_adc_nids,
18922 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18923 .capsrc_nids = alc272_capsrc_nids,
18924 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018925 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018926 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018927 .init_hook = alc663_m51va_inithook,
18928 },
18929 [ALC272_DELL_ZM1] = {
18930 .mixers = { alc663_m51va_mixer },
18931 .cap_mixer = alc662_auto_capture_mixer,
18932 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18933 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18934 .dac_nids = alc662_dac_nids,
18935 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18936 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018937 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018938 .capsrc_nids = alc662_capsrc_nids,
18939 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018940 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018941 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018942 .init_hook = alc663_m51va_inithook,
18943 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018944 [ALC272_SAMSUNG_NC10] = {
18945 .mixers = { alc272_nc10_mixer },
18946 .init_verbs = { alc662_init_verbs,
18947 alc663_21jd_amic_init_verbs },
18948 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18949 .dac_nids = alc272_dac_nids,
18950 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18951 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018952 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018953 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018954 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018955 .init_hook = alc663_mode4_inithook,
18956 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018957};
18958
18959
18960/*
18961 * BIOS auto configuration
18962 */
18963
Takashi Iwai7085ec12009-10-02 09:03:58 +020018964/* convert from MIX nid to DAC */
18965static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18966{
18967 if (nid == 0x0f)
18968 return 0x02;
18969 else if (nid >= 0x0c && nid <= 0x0e)
18970 return nid - 0x0c + 0x02;
David Henningssoncc1c4522010-11-24 14:17:47 +010018971 else if (nid == 0x26) /* ALC887-VD has this DAC too */
18972 return 0x25;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018973 else
18974 return 0;
18975}
18976
18977/* get MIX nid connected to the given pin targeted to DAC */
18978static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18979 hda_nid_t dac)
18980{
David Henningssoncc1c4522010-11-24 14:17:47 +010018981 hda_nid_t mix[5];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018982 int i, num;
18983
18984 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18985 for (i = 0; i < num; i++) {
18986 if (alc662_mix_to_dac(mix[i]) == dac)
18987 return mix[i];
18988 }
18989 return 0;
18990}
18991
18992/* look for an empty DAC slot */
18993static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18994{
18995 struct alc_spec *spec = codec->spec;
18996 hda_nid_t srcs[5];
18997 int i, j, num;
18998
18999 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
19000 if (num < 0)
19001 return 0;
19002 for (i = 0; i < num; i++) {
19003 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
19004 if (!nid)
19005 continue;
19006 for (j = 0; j < spec->multiout.num_dacs; j++)
19007 if (spec->multiout.dac_nids[j] == nid)
19008 break;
19009 if (j >= spec->multiout.num_dacs)
19010 return nid;
19011 }
19012 return 0;
19013}
19014
19015/* fill in the dac_nids table from the parsed pin configuration */
19016static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
19017 const struct auto_pin_cfg *cfg)
19018{
19019 struct alc_spec *spec = codec->spec;
19020 int i;
19021 hda_nid_t dac;
19022
19023 spec->multiout.dac_nids = spec->private_dac_nids;
19024 for (i = 0; i < cfg->line_outs; i++) {
19025 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
19026 if (!dac)
19027 continue;
19028 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19029 }
19030 return 0;
19031}
19032
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019033static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019034 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019035{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019036 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019037 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
19038}
19039
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019040static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019041 hda_nid_t nid, unsigned int chs)
19042{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019043 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019044 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
19045}
19046
19047#define alc662_add_stereo_vol(spec, pfx, nid) \
19048 alc662_add_vol_ctl(spec, pfx, nid, 3)
19049#define alc662_add_stereo_sw(spec, pfx, nid) \
19050 alc662_add_sw_ctl(spec, pfx, nid, 3)
19051
19052/* add playback controls from the parsed DAC table */
19053static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
19054 const struct auto_pin_cfg *cfg)
19055{
19056 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019057 static const char *chname[4] = {
19058 "Front", "Surround", NULL /*CLFE*/, "Side"
19059 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020019060 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019061 int i, err;
19062
19063 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019064 nid = spec->multiout.dac_nids[i];
19065 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019066 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019067 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
19068 if (!mix)
19069 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019070 if (i == 2) {
19071 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019072 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019073 if (err < 0)
19074 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019075 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019076 if (err < 0)
19077 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019078 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019079 if (err < 0)
19080 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019081 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019082 if (err < 0)
19083 return err;
19084 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019085 const char *pfx;
19086 if (cfg->line_outs == 1 &&
19087 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019088 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019089 pfx = "Speaker";
19090 else
19091 pfx = "PCM";
19092 } else
19093 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019094 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019095 if (err < 0)
19096 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019097 if (cfg->line_outs == 1 &&
19098 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19099 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020019100 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019101 if (err < 0)
19102 return err;
19103 }
19104 }
19105 return 0;
19106}
19107
19108/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019109/* return DAC nid if any new DAC is assigned */
19110static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019111 const char *pfx)
19112{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019113 struct alc_spec *spec = codec->spec;
19114 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019115 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019116
19117 if (!pin)
19118 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019119 nid = alc662_look_for_dac(codec, pin);
19120 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019121 /* the corresponding DAC is already occupied */
19122 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19123 return 0; /* no way */
19124 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019125 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019126 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19127 }
19128
19129 mix = alc662_dac_to_mix(codec, pin, nid);
19130 if (!mix)
19131 return 0;
19132 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19133 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019134 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019135 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19136 if (err < 0)
19137 return err;
19138 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019139}
19140
19141/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019142#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019143 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019144
19145static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19146 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019147 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019148{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019149 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019150 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019151
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019152 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019153 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019154 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19155 if (num <= 1)
19156 return;
19157 for (i = 0; i < num; i++) {
19158 if (alc662_mix_to_dac(srcs[i]) != dac)
19159 continue;
19160 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19161 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019162 }
19163}
19164
19165static void alc662_auto_init_multi_out(struct hda_codec *codec)
19166{
19167 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019168 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019169 int i;
19170
19171 for (i = 0; i <= HDA_SIDE; i++) {
19172 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19173 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019174 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019175 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019176 }
19177}
19178
19179static void alc662_auto_init_hp_out(struct hda_codec *codec)
19180{
19181 struct alc_spec *spec = codec->spec;
19182 hda_nid_t pin;
19183
19184 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019185 if (pin)
19186 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19187 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019188 pin = spec->autocfg.speaker_pins[0];
19189 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019190 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19191 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019192}
19193
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019194#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19195
19196static void alc662_auto_init_analog_input(struct hda_codec *codec)
19197{
19198 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019199 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019200 int i;
19201
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019202 for (i = 0; i < cfg->num_inputs; i++) {
19203 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019204 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019205 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019206 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019207 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019208 snd_hda_codec_write(codec, nid, 0,
19209 AC_VERB_SET_AMP_GAIN_MUTE,
19210 AMP_OUT_MUTE);
19211 }
19212 }
19213}
19214
Takashi Iwaif511b012008-08-15 16:46:42 +020019215#define alc662_auto_init_input_src alc882_auto_init_input_src
19216
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019217static int alc662_parse_auto_config(struct hda_codec *codec)
19218{
19219 struct alc_spec *spec = codec->spec;
19220 int err;
19221 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19222
19223 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19224 alc662_ignore);
19225 if (err < 0)
19226 return err;
19227 if (!spec->autocfg.line_outs)
19228 return 0; /* can't find valid BIOS pin config */
19229
Takashi Iwai7085ec12009-10-02 09:03:58 +020019230 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019231 if (err < 0)
19232 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019233 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019234 if (err < 0)
19235 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019236 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019237 spec->autocfg.speaker_pins[0],
19238 "Speaker");
19239 if (err < 0)
19240 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019241 if (err)
19242 spec->multiout.extra_out_nid[0] = err;
19243 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019244 "Headphone");
19245 if (err < 0)
19246 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019247 if (err)
19248 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019249 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019250 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019251 return err;
19252
19253 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19254
Takashi Iwai757899a2010-07-30 10:48:14 +020019255 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019256
Takashi Iwai603c4012008-07-30 15:01:44 +020019257 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019258 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019259
19260 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019261 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019262
Kailang Yangcec27c82010-02-04 14:18:18 +010019263 add_verb(spec, alc662_init_verbs);
19264 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019265 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019266 add_verb(spec, alc663_init_verbs);
19267
19268 if (codec->vendor_id == 0x10ec0272)
19269 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019270
19271 err = alc_auto_add_mic_boost(codec);
19272 if (err < 0)
19273 return err;
19274
Kailang Yang6227cdc2010-02-25 08:36:52 +010019275 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19276 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19277 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19278 else
19279 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019280
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019281 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019282}
19283
19284/* additional initialization for auto-configuration model */
19285static void alc662_auto_init(struct hda_codec *codec)
19286{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019287 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019288 alc662_auto_init_multi_out(codec);
19289 alc662_auto_init_hp_out(codec);
19290 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019291 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019292 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019293 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019294 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019295}
19296
David Henningsson6cb3b702010-09-09 08:51:44 +020019297enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040019298 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019299 ALC662_FIXUP_IDEAPAD,
19300};
19301
19302static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019303 [ALC662_FIXUP_ASPIRE] = {
19304 .pins = (const struct alc_pincfg[]) {
19305 { 0x15, 0x99130112 }, /* subwoofer */
19306 { }
19307 }
19308 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019309 [ALC662_FIXUP_IDEAPAD] = {
19310 .pins = (const struct alc_pincfg[]) {
19311 { 0x17, 0x99130112 }, /* subwoofer */
19312 { }
19313 }
19314 },
19315};
19316
19317static struct snd_pci_quirk alc662_fixup_tbl[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019318 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050019319 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060019320 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020019321 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
19322 {}
19323};
19324
19325
19326
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019327static int patch_alc662(struct hda_codec *codec)
19328{
19329 struct alc_spec *spec;
19330 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020019331 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019332
19333 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19334 if (!spec)
19335 return -ENOMEM;
19336
19337 codec->spec = spec;
19338
Kailang Yangda00c242010-03-19 11:23:45 +010019339 alc_auto_parse_customize_define(codec);
19340
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019341 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19342
Kailang Yang693194f2010-10-21 08:51:48 +020019343 coef = alc_read_coef_idx(codec, 0);
19344 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019345 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020019346 else if (coef & (1 << 14) &&
19347 codec->bus->pci->subsystem_vendor == 0x1025 &&
19348 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019349 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019350 else if (coef == 0x4011)
19351 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019352
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019353 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19354 alc662_models,
19355 alc662_cfg_tbl);
19356 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019357 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19358 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019359 board_config = ALC662_AUTO;
19360 }
19361
19362 if (board_config == ALC662_AUTO) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019363 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019364 /* automatic parse from the BIOS config */
19365 err = alc662_parse_auto_config(codec);
19366 if (err < 0) {
19367 alc_free(codec);
19368 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019369 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019370 printk(KERN_INFO
19371 "hda_codec: Cannot set up configuration "
19372 "from BIOS. Using base mode...\n");
19373 board_config = ALC662_3ST_2ch_DIG;
19374 }
19375 }
19376
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019377 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019378 err = snd_hda_attach_beep_device(codec, 0x1);
19379 if (err < 0) {
19380 alc_free(codec);
19381 return err;
19382 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019383 }
19384
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019385 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019386 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019387
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019388 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19389 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19390
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019391 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19392 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19393
Takashi Iwaidd704692009-08-11 08:45:11 +020019394 if (!spec->adc_nids) {
19395 spec->adc_nids = alc662_adc_nids;
19396 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19397 }
19398 if (!spec->capsrc_nids)
19399 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019400
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019401 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019402 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019403
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019404 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019405 switch (codec->vendor_id) {
19406 case 0x10ec0662:
19407 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19408 break;
19409 case 0x10ec0272:
19410 case 0x10ec0663:
19411 case 0x10ec0665:
19412 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19413 break;
19414 case 0x10ec0273:
19415 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19416 break;
19417 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019418 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019419 spec->vmaster_nid = 0x02;
19420
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019421 codec->patch_ops = alc_patch_ops;
David Henningsson6cb3b702010-09-09 08:51:44 +020019422 if (board_config == ALC662_AUTO) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019423 spec->init_hook = alc662_auto_init;
David Henningsson6cb3b702010-09-09 08:51:44 +020019424 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 0);
19425 }
19426
Kailang Yangbf1b0222010-10-21 08:49:56 +020019427 alc_init_jacks(codec);
19428
Takashi Iwaicb53c622007-08-10 17:21:45 +020019429#ifdef CONFIG_SND_HDA_POWER_SAVE
19430 if (!spec->loopback.amplist)
19431 spec->loopback.amplist = alc662_loopbacks;
19432#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019433
19434 return 0;
19435}
19436
Kailang Yang274693f2009-12-03 10:07:50 +010019437static int patch_alc888(struct hda_codec *codec)
19438{
19439 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19440 kfree(codec->chip_name);
Kailang Yang01e0f132010-11-22 10:59:36 +010019441 if (codec->vendor_id == 0x10ec0887)
19442 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19443 else
19444 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019445 if (!codec->chip_name) {
19446 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019447 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019448 }
19449 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019450 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019451 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019452}
19453
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019454/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019455 * ALC680 support
19456 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019457#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019458#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19459#define alc680_modes alc260_modes
19460
19461static hda_nid_t alc680_dac_nids[3] = {
19462 /* Lout1, Lout2, hp */
19463 0x02, 0x03, 0x04
19464};
19465
19466static hda_nid_t alc680_adc_nids[3] = {
19467 /* ADC0-2 */
19468 /* DMIC, MIC, Line-in*/
19469 0x07, 0x08, 0x09
19470};
19471
Kailang Yangc69aefa2010-08-17 10:39:22 +020019472/*
19473 * Analog capture ADC cgange
19474 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019475static void alc680_rec_autoswitch(struct hda_codec *codec)
19476{
19477 struct alc_spec *spec = codec->spec;
19478 struct auto_pin_cfg *cfg = &spec->autocfg;
19479 int pin_found = 0;
19480 int type_found = AUTO_PIN_LAST;
19481 hda_nid_t nid;
19482 int i;
19483
19484 for (i = 0; i < cfg->num_inputs; i++) {
19485 nid = cfg->inputs[i].pin;
19486 if (!(snd_hda_query_pin_caps(codec, nid) &
19487 AC_PINCAP_PRES_DETECT))
19488 continue;
19489 if (snd_hda_jack_detect(codec, nid)) {
19490 if (cfg->inputs[i].type < type_found) {
19491 type_found = cfg->inputs[i].type;
19492 pin_found = nid;
19493 }
19494 }
19495 }
19496
19497 nid = 0x07;
19498 if (pin_found)
19499 snd_hda_get_connections(codec, pin_found, &nid, 1);
19500
19501 if (nid != spec->cur_adc)
19502 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19503 spec->cur_adc = nid;
19504 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19505 spec->cur_adc_format);
19506}
19507
Kailang Yangc69aefa2010-08-17 10:39:22 +020019508static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19509 struct hda_codec *codec,
19510 unsigned int stream_tag,
19511 unsigned int format,
19512 struct snd_pcm_substream *substream)
19513{
19514 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019515
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019516 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019517 spec->cur_adc_stream_tag = stream_tag;
19518 spec->cur_adc_format = format;
19519
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019520 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019521 return 0;
19522}
19523
19524static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19525 struct hda_codec *codec,
19526 struct snd_pcm_substream *substream)
19527{
19528 snd_hda_codec_cleanup_stream(codec, 0x07);
19529 snd_hda_codec_cleanup_stream(codec, 0x08);
19530 snd_hda_codec_cleanup_stream(codec, 0x09);
19531 return 0;
19532}
19533
19534static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19535 .substreams = 1, /* can be overridden */
19536 .channels_min = 2,
19537 .channels_max = 2,
19538 /* NID is set in alc_build_pcms */
19539 .ops = {
19540 .prepare = alc680_capture_pcm_prepare,
19541 .cleanup = alc680_capture_pcm_cleanup
19542 },
19543};
19544
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019545static struct snd_kcontrol_new alc680_base_mixer[] = {
19546 /* output mixer control */
19547 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19548 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19549 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19550 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019551 HDA_CODEC_VOLUME("Int Mic Boost", 0x12, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019552 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019553 HDA_CODEC_VOLUME("Line In Boost", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019554 { }
19555};
19556
Kailang Yangc69aefa2010-08-17 10:39:22 +020019557static struct hda_bind_ctls alc680_bind_cap_vol = {
19558 .ops = &snd_hda_bind_vol,
19559 .values = {
19560 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19561 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19562 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19563 0
19564 },
19565};
19566
19567static struct hda_bind_ctls alc680_bind_cap_switch = {
19568 .ops = &snd_hda_bind_sw,
19569 .values = {
19570 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19571 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19572 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19573 0
19574 },
19575};
19576
19577static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19578 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19579 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019580 { } /* end */
19581};
19582
19583/*
19584 * generic initialization of ADC, input mixers and output mixers
19585 */
19586static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019587 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19588 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19589 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019590
Kailang Yangc69aefa2010-08-17 10:39:22 +020019591 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19592 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19593 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19594 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19595 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19596 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019597
19598 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19599 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19600 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19601 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19602 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019603
19604 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19605 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019606 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019607
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019608 { }
19609};
19610
Kailang Yangc69aefa2010-08-17 10:39:22 +020019611/* toggle speaker-output according to the hp-jack state */
19612static void alc680_base_setup(struct hda_codec *codec)
19613{
19614 struct alc_spec *spec = codec->spec;
19615
19616 spec->autocfg.hp_pins[0] = 0x16;
19617 spec->autocfg.speaker_pins[0] = 0x14;
19618 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019619 spec->autocfg.num_inputs = 2;
19620 spec->autocfg.inputs[0].pin = 0x18;
19621 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19622 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019623 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019624}
19625
19626static void alc680_unsol_event(struct hda_codec *codec,
19627 unsigned int res)
19628{
19629 if ((res >> 26) == ALC880_HP_EVENT)
19630 alc_automute_amp(codec);
19631 if ((res >> 26) == ALC880_MIC_EVENT)
19632 alc680_rec_autoswitch(codec);
19633}
19634
19635static void alc680_inithook(struct hda_codec *codec)
19636{
19637 alc_automute_amp(codec);
19638 alc680_rec_autoswitch(codec);
19639}
19640
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019641/* create input playback/capture controls for the given pin */
19642static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19643 const char *ctlname, int idx)
19644{
19645 hda_nid_t dac;
19646 int err;
19647
19648 switch (nid) {
19649 case 0x14:
19650 dac = 0x02;
19651 break;
19652 case 0x15:
19653 dac = 0x03;
19654 break;
19655 case 0x16:
19656 dac = 0x04;
19657 break;
19658 default:
19659 return 0;
19660 }
19661 if (spec->multiout.dac_nids[0] != dac &&
19662 spec->multiout.dac_nids[1] != dac) {
19663 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19664 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19665 HDA_OUTPUT));
19666 if (err < 0)
19667 return err;
19668
19669 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19670 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19671
19672 if (err < 0)
19673 return err;
19674 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19675 }
19676
19677 return 0;
19678}
19679
19680/* add playback controls from the parsed DAC table */
19681static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19682 const struct auto_pin_cfg *cfg)
19683{
19684 hda_nid_t nid;
19685 int err;
19686
19687 spec->multiout.dac_nids = spec->private_dac_nids;
19688
19689 nid = cfg->line_out_pins[0];
19690 if (nid) {
19691 const char *name;
19692 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19693 name = "Speaker";
19694 else
19695 name = "Front";
19696 err = alc680_new_analog_output(spec, nid, name, 0);
19697 if (err < 0)
19698 return err;
19699 }
19700
19701 nid = cfg->speaker_pins[0];
19702 if (nid) {
19703 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19704 if (err < 0)
19705 return err;
19706 }
19707 nid = cfg->hp_pins[0];
19708 if (nid) {
19709 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19710 if (err < 0)
19711 return err;
19712 }
19713
19714 return 0;
19715}
19716
19717static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19718 hda_nid_t nid, int pin_type)
19719{
19720 alc_set_pin_output(codec, nid, pin_type);
19721}
19722
19723static void alc680_auto_init_multi_out(struct hda_codec *codec)
19724{
19725 struct alc_spec *spec = codec->spec;
19726 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19727 if (nid) {
19728 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19729 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19730 }
19731}
19732
19733static void alc680_auto_init_hp_out(struct hda_codec *codec)
19734{
19735 struct alc_spec *spec = codec->spec;
19736 hda_nid_t pin;
19737
19738 pin = spec->autocfg.hp_pins[0];
19739 if (pin)
19740 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19741 pin = spec->autocfg.speaker_pins[0];
19742 if (pin)
19743 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19744}
19745
19746/* pcm configuration: identical with ALC880 */
19747#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19748#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19749#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19750#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019751#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019752
19753/*
19754 * BIOS auto configuration
19755 */
19756static int alc680_parse_auto_config(struct hda_codec *codec)
19757{
19758 struct alc_spec *spec = codec->spec;
19759 int err;
19760 static hda_nid_t alc680_ignore[] = { 0 };
19761
19762 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19763 alc680_ignore);
19764 if (err < 0)
19765 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019766
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019767 if (!spec->autocfg.line_outs) {
19768 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19769 spec->multiout.max_channels = 2;
19770 spec->no_analog = 1;
19771 goto dig_only;
19772 }
19773 return 0; /* can't find valid BIOS pin config */
19774 }
19775 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19776 if (err < 0)
19777 return err;
19778
19779 spec->multiout.max_channels = 2;
19780
19781 dig_only:
19782 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019783 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019784 if (spec->kctls.list)
19785 add_mixer(spec, spec->kctls.list);
19786
19787 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019788
19789 err = alc_auto_add_mic_boost(codec);
19790 if (err < 0)
19791 return err;
19792
19793 return 1;
19794}
19795
19796#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19797
19798/* init callback for auto-configuration model -- overriding the default init */
19799static void alc680_auto_init(struct hda_codec *codec)
19800{
19801 struct alc_spec *spec = codec->spec;
19802 alc680_auto_init_multi_out(codec);
19803 alc680_auto_init_hp_out(codec);
19804 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019805 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019806 if (spec->unsol_event)
19807 alc_inithook(codec);
19808}
19809
19810/*
19811 * configuration and preset
19812 */
19813static const char *alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019814 [ALC680_BASE] = "base",
19815 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019816};
19817
19818static struct snd_pci_quirk alc680_cfg_tbl[] = {
19819 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19820 {}
19821};
19822
19823static struct alc_config_preset alc680_presets[] = {
19824 [ALC680_BASE] = {
19825 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019826 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019827 .init_verbs = { alc680_init_verbs },
19828 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19829 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019830 .dig_out_nid = ALC680_DIGOUT_NID,
19831 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19832 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019833 .unsol_event = alc680_unsol_event,
19834 .setup = alc680_base_setup,
19835 .init_hook = alc680_inithook,
19836
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019837 },
19838};
19839
19840static int patch_alc680(struct hda_codec *codec)
19841{
19842 struct alc_spec *spec;
19843 int board_config;
19844 int err;
19845
19846 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19847 if (spec == NULL)
19848 return -ENOMEM;
19849
19850 codec->spec = spec;
19851
19852 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19853 alc680_models,
19854 alc680_cfg_tbl);
19855
19856 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19857 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19858 codec->chip_name);
19859 board_config = ALC680_AUTO;
19860 }
19861
19862 if (board_config == ALC680_AUTO) {
19863 /* automatic parse from the BIOS config */
19864 err = alc680_parse_auto_config(codec);
19865 if (err < 0) {
19866 alc_free(codec);
19867 return err;
19868 } else if (!err) {
19869 printk(KERN_INFO
19870 "hda_codec: Cannot set up configuration "
19871 "from BIOS. Using base mode...\n");
19872 board_config = ALC680_BASE;
19873 }
19874 }
19875
19876 if (board_config != ALC680_AUTO)
19877 setup_preset(codec, &alc680_presets[board_config]);
19878
19879 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019880 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019881 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019882 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019883
19884 if (!spec->adc_nids) {
19885 spec->adc_nids = alc680_adc_nids;
19886 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
19887 }
19888
19889 if (!spec->cap_mixer)
19890 set_capture_mixer(codec);
19891
19892 spec->vmaster_nid = 0x02;
19893
19894 codec->patch_ops = alc_patch_ops;
19895 if (board_config == ALC680_AUTO)
19896 spec->init_hook = alc680_auto_init;
19897
19898 return 0;
19899}
19900
19901/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019902 * patch entries
19903 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019904static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070019905 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019906 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019907 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020019908 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019909 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019910 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020019911 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019912 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019913 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019914 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019915 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
19916 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
19917 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019918 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019919 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019920 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
19921 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020019922 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010019923 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010019924 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019925 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019926 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019927 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019928 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020019929 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019930 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020019931 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019932 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019933 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yang01e0f132010-11-22 10:59:36 +010019934 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
Kailang Yang44426082008-10-15 11:18:05 +020019935 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019936 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019937 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019938 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019939 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019940 {} /* terminator */
19941};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019942
19943MODULE_ALIAS("snd-hda-codec-id:10ec*");
19944
19945MODULE_LICENSE("GPL");
19946MODULE_DESCRIPTION("Realtek HD-audio codec");
19947
19948static struct hda_codec_preset_list realtek_list = {
19949 .preset = snd_hda_preset_realtek,
19950 .owner = THIS_MODULE,
19951};
19952
19953static int __init patch_realtek_init(void)
19954{
19955 return snd_hda_add_codec_preset(&realtek_list);
19956}
19957
19958static void __exit patch_realtek_exit(void)
19959{
19960 snd_hda_delete_codec_preset(&realtek_list);
19961}
19962
19963module_init(patch_realtek_init)
19964module_exit(patch_realtek_exit)