blob: 0ac6aed0c889f7cb1c029b08430e83e0e9eac770 [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,
Kailang Yangea1fb292008-08-26 12:58:38 +0200234 ALC883_MEDION_MD2,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200235 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100236 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200237 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200238 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200239 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200240 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200241 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200242 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100243 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100244 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430245 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100246 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100247 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800248 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200249 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200250 ALC889A_INTEL,
251 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200252 ALC888_ASUS_M90V,
253 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200254 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100255 ALC1200_ASUS_P5Q,
Guido Günther3e1647c52009-06-05 00:47:26 +0200256 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200257 ALC882_AUTO,
258 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200259};
260
Takashi Iwaid4a86d82010-06-23 17:51:26 +0200261/* ALC680 models */
262enum {
263 ALC680_BASE,
264 ALC680_AUTO,
265 ALC680_MODEL_LAST,
266};
267
Kailang Yangdf694da2005-12-05 19:42:22 +0100268/* for GPIO Poll */
269#define GPIO_MASK 0x03
270
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200271/* extra amp-initialization sequence types */
272enum {
273 ALC_INIT_NONE,
274 ALC_INIT_DEFAULT,
275 ALC_INIT_GPIO1,
276 ALC_INIT_GPIO2,
277 ALC_INIT_GPIO3,
278};
279
Takashi Iwai6c819492009-08-10 18:47:44 +0200280struct alc_mic_route {
281 hda_nid_t pin;
282 unsigned char mux_idx;
283 unsigned char amix_idx;
284};
285
Kailang Yang9ad0e492010-09-14 23:22:00 +0200286struct alc_jack {
287 hda_nid_t nid;
288 int type;
289 struct snd_jack *jack;
290};
291
Takashi Iwai6c819492009-08-10 18:47:44 +0200292#define MUX_IDX_UNDEF ((unsigned char)-1)
293
Kailang Yangda00c242010-03-19 11:23:45 +0100294struct alc_customize_define {
295 unsigned int sku_cfg;
296 unsigned char port_connectivity;
297 unsigned char check_sum;
298 unsigned char customization;
299 unsigned char external_amp;
300 unsigned int enable_pcbeep:1;
301 unsigned int platform_type:1;
302 unsigned int swap:1;
303 unsigned int override:1;
David Henningsson90622912010-10-14 14:50:18 +0200304 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
Kailang Yangda00c242010-03-19 11:23:45 +0100305};
306
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307struct alc_spec {
308 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100309 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100311 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100312 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200314 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200315 * don't forget NULL
316 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200317 */
318 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200320 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 struct hda_pcm_stream *stream_analog_playback;
322 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100323 struct hda_pcm_stream *stream_analog_alt_playback;
324 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200326 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 struct hda_pcm_stream *stream_digital_playback;
328 struct hda_pcm_stream *stream_digital_capture;
329
330 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200331 struct hda_multi_out multiout; /* playback set-up
332 * max_channels, dacs must be set
333 * dig_out_nid and hp_nid are optional
334 */
Takashi Iwai63300792008-01-24 15:31:36 +0100335 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100336 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100337 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338
339 /* capture */
340 unsigned int num_adc_nids;
341 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100342 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200343 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344
Takashi Iwai840b64c2010-07-13 22:49:01 +0200345 /* capture setup for dynamic dual-adc switch */
346 unsigned int cur_adc_idx;
347 hda_nid_t cur_adc;
348 unsigned int cur_adc_stream_tag;
349 unsigned int cur_adc_format;
350
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200352 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 const struct hda_input_mux *input_mux;
354 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200355 struct alc_mic_route ext_mic;
356 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357
358 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100359 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200361 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200362 int const_channel_count;
363 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364
365 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100366 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200367
Kailang Yang9ad0e492010-09-14 23:22:00 +0200368 /* jack detection */
369 struct snd_array jacks;
370
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200371 /* dynamic controls, init_verbs and input_mux */
372 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100373 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200374 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200375 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200376 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200377 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
378 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100379
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100380 /* hooks */
381 void (*init_hook)(struct hda_codec *codec);
382 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100383#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500384 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100385#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100386
Takashi Iwai834be882006-03-01 14:16:17 +0100387 /* for pin sensing */
388 unsigned int sense_updated: 1;
389 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100390 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200391 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200392
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100393 /* other flags */
394 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai840b64c2010-07-13 22:49:01 +0200395 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200396 int init_amp;
Takashi Iwaid433a672010-09-20 15:11:54 +0200397 int codec_variant; /* flag for other variants */
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100398
Takashi Iwai2134ea42008-01-10 16:53:55 +0100399 /* for virtual master */
400 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200401#ifdef CONFIG_SND_HDA_POWER_SAVE
402 struct hda_loopback_check loopback;
403#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200404
405 /* for PLL fix */
406 hda_nid_t pll_nid;
407 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100408};
409
410/*
411 * configuration template - to be copied to the spec instance
412 */
413struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200414 struct snd_kcontrol_new *mixers[5]; /* should be identical size
415 * with spec
416 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100417 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100418 const struct hda_verb *init_verbs[5];
419 unsigned int num_dacs;
420 hda_nid_t *dac_nids;
421 hda_nid_t dig_out_nid; /* optional */
422 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800423 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100424 unsigned int num_adc_nids;
425 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100426 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100427 hda_nid_t dig_in_nid;
428 unsigned int num_channel_mode;
429 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200430 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200431 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200432 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100433 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100434 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200435 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100436 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200437#ifdef CONFIG_SND_HDA_POWER_SAVE
438 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500439 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200440#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441};
442
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443
444/*
445 * input MUX handling
446 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200447static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
448 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449{
450 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
451 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200452 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
453 if (mux_idx >= spec->num_mux_defs)
454 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100455 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
456 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200457 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458}
459
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200460static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
461 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462{
463 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
464 struct alc_spec *spec = codec->spec;
465 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
466
467 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
468 return 0;
469}
470
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200471static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
472 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473{
474 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
475 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100476 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100478 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100479 hda_nid_t nid = spec->capsrc_nids ?
480 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200481 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482
Takashi Iwaicd896c32008-11-18 12:36:33 +0100483 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
484 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100485 if (!imux->num_items && mux_idx > 0)
486 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100487
Takashi Iwaia22d5432009-07-27 12:54:26 +0200488 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200489 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100490 /* Matrix-mixer style (e.g. ALC882) */
491 unsigned int *cur_val = &spec->cur_mux[adc_idx];
492 unsigned int i, idx;
493
494 idx = ucontrol->value.enumerated.item[0];
495 if (idx >= imux->num_items)
496 idx = imux->num_items - 1;
497 if (*cur_val == idx)
498 return 0;
499 for (i = 0; i < imux->num_items; i++) {
500 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
501 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
502 imux->items[i].index,
503 HDA_AMP_MUTE, v);
504 }
505 *cur_val = idx;
506 return 1;
507 } else {
508 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100509 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100510 &spec->cur_mux[adc_idx]);
511 }
512}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200513
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514/*
515 * channel mode setting
516 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200517static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
518 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519{
520 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
521 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100522 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
523 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524}
525
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200526static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
527 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528{
529 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
530 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100531 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200532 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200533 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534}
535
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200536static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
537 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538{
539 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
540 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200541 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
542 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200543 &spec->ext_channel_count);
544 if (err >= 0 && !spec->const_channel_count) {
545 spec->multiout.max_channels = spec->ext_channel_count;
546 if (spec->need_dac_fix)
547 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
548 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200549 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550}
551
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100553 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200554 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100555 * being part of a format specifier. Maximum allowed length of a value is
556 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100557 *
558 * Note: some retasking pin complexes seem to ignore requests for input
559 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
560 * are requested. Therefore order this list so that this behaviour will not
561 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200562 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
563 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200564 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100565static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100566 "Mic 50pc bias", "Mic 80pc bias",
567 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100568};
569static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100570 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100571};
572/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200573 * in the pin being assumed to be exclusively an input or an output pin. In
574 * addition, "input" pins may or may not process the mic bias option
575 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
576 * accept requests for bias as of chip versions up to March 2006) and/or
577 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100578 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200579#define ALC_PIN_DIR_IN 0x00
580#define ALC_PIN_DIR_OUT 0x01
581#define ALC_PIN_DIR_INOUT 0x02
582#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
583#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100584
Kailang Yangea1fb292008-08-26 12:58:38 +0200585/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100586 * For each direction the minimum and maximum values are given.
587 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200588static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100589 { 0, 2 }, /* ALC_PIN_DIR_IN */
590 { 3, 4 }, /* ALC_PIN_DIR_OUT */
591 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200592 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
593 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100594};
595#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
596#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
597#define alc_pin_mode_n_items(_dir) \
598 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
599
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200600static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
601 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200602{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100603 unsigned int item_num = uinfo->value.enumerated.item;
604 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
605
606 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200607 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100608 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
609
610 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
611 item_num = alc_pin_mode_min(dir);
612 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200613 return 0;
614}
615
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200616static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
617 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200618{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100619 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200620 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
621 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100622 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200623 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200624 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
625 AC_VERB_GET_PIN_WIDGET_CONTROL,
626 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200627
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100628 /* Find enumerated value for current pinctl setting */
629 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200630 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100631 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200632 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100633 return 0;
634}
635
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200636static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
637 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100638{
639 signed int change;
640 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
641 hda_nid_t nid = kcontrol->private_value & 0xffff;
642 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
643 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200644 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
645 AC_VERB_GET_PIN_WIDGET_CONTROL,
646 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100647
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200648 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100649 val = alc_pin_mode_min(dir);
650
651 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100652 if (change) {
653 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200654 snd_hda_codec_write_cache(codec, nid, 0,
655 AC_VERB_SET_PIN_WIDGET_CONTROL,
656 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100657
Kailang Yangea1fb292008-08-26 12:58:38 +0200658 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100659 * for the requested pin mode. Enum values of 2 or less are
660 * input modes.
661 *
662 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200663 * reduces noise slightly (particularly on input) so we'll
664 * do it. However, having both input and output buffers
665 * enabled simultaneously doesn't seem to be problematic if
666 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100667 */
668 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200669 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
670 HDA_AMP_MUTE, HDA_AMP_MUTE);
671 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
672 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100673 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200674 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
675 HDA_AMP_MUTE, HDA_AMP_MUTE);
676 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
677 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100678 }
679 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200680 return change;
681}
682
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100683#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200684 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100685 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100686 .info = alc_pin_mode_info, \
687 .get = alc_pin_mode_get, \
688 .put = alc_pin_mode_put, \
689 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100690
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100691/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
692 * together using a mask with more than one bit set. This control is
693 * currently used only by the ALC260 test model. At this stage they are not
694 * needed for any "production" models.
695 */
696#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200697#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200698
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200699static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
700 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100701{
702 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
703 hda_nid_t nid = kcontrol->private_value & 0xffff;
704 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
705 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200706 unsigned int val = snd_hda_codec_read(codec, nid, 0,
707 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100708
709 *valp = (val & mask) != 0;
710 return 0;
711}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200712static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
713 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100714{
715 signed int change;
716 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
717 hda_nid_t nid = kcontrol->private_value & 0xffff;
718 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
719 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200720 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
721 AC_VERB_GET_GPIO_DATA,
722 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100723
724 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200725 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
726 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100727 gpio_data &= ~mask;
728 else
729 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200730 snd_hda_codec_write_cache(codec, nid, 0,
731 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100732
733 return change;
734}
735#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
736 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100737 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100738 .info = alc_gpio_data_info, \
739 .get = alc_gpio_data_get, \
740 .put = alc_gpio_data_put, \
741 .private_value = nid | (mask<<16) }
742#endif /* CONFIG_SND_DEBUG */
743
Jonathan Woithe92621f12006-02-28 11:47:47 +0100744/* A switch control to allow the enabling of the digital IO pins on the
745 * ALC260. This is incredibly simplistic; the intention of this control is
746 * to provide something in the test model allowing digital outputs to be
747 * identified if present. If models are found which can utilise these
748 * outputs a more complete mixer control can be devised for those models if
749 * necessary.
750 */
751#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200752#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200753
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200754static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
755 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100756{
757 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
758 hda_nid_t nid = kcontrol->private_value & 0xffff;
759 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
760 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200761 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100762 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100763
764 *valp = (val & mask) != 0;
765 return 0;
766}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200767static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
768 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100769{
770 signed int change;
771 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
772 hda_nid_t nid = kcontrol->private_value & 0xffff;
773 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
774 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200775 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100776 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200777 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100778
779 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200780 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100781 if (val==0)
782 ctrl_data &= ~mask;
783 else
784 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200785 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
786 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100787
788 return change;
789}
790#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
791 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100792 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100793 .info = alc_spdif_ctrl_info, \
794 .get = alc_spdif_ctrl_get, \
795 .put = alc_spdif_ctrl_put, \
796 .private_value = nid | (mask<<16) }
797#endif /* CONFIG_SND_DEBUG */
798
Jonathan Woithef8225f62008-01-08 12:16:54 +0100799/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
800 * Again, this is only used in the ALC26x test models to help identify when
801 * the EAPD line must be asserted for features to work.
802 */
803#ifdef CONFIG_SND_DEBUG
804#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
805
806static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
807 struct snd_ctl_elem_value *ucontrol)
808{
809 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
810 hda_nid_t nid = kcontrol->private_value & 0xffff;
811 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
812 long *valp = ucontrol->value.integer.value;
813 unsigned int val = snd_hda_codec_read(codec, nid, 0,
814 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
815
816 *valp = (val & mask) != 0;
817 return 0;
818}
819
820static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
821 struct snd_ctl_elem_value *ucontrol)
822{
823 int change;
824 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
825 hda_nid_t nid = kcontrol->private_value & 0xffff;
826 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
827 long val = *ucontrol->value.integer.value;
828 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
829 AC_VERB_GET_EAPD_BTLENABLE,
830 0x00);
831
832 /* Set/unset the masked control bit(s) as needed */
833 change = (!val ? 0 : mask) != (ctrl_data & mask);
834 if (!val)
835 ctrl_data &= ~mask;
836 else
837 ctrl_data |= mask;
838 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
839 ctrl_data);
840
841 return change;
842}
843
844#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
845 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100846 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100847 .info = alc_eapd_ctrl_info, \
848 .get = alc_eapd_ctrl_get, \
849 .put = alc_eapd_ctrl_put, \
850 .private_value = nid | (mask<<16) }
851#endif /* CONFIG_SND_DEBUG */
852
Kailang Yangdf694da2005-12-05 19:42:22 +0100853/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100854 * set up the input pin config (depending on the given auto-pin type)
855 */
856static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
857 int auto_pin_type)
858{
859 unsigned int val = PIN_IN;
860
Takashi Iwai86e29592010-09-09 14:50:17 +0200861 if (auto_pin_type == AUTO_PIN_MIC) {
Takashi Iwai23f0c042009-02-26 13:03:58 +0100862 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200863 unsigned int oldval;
864 oldval = snd_hda_codec_read(codec, nid, 0,
865 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100866 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100867 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200868 /* if the default pin setup is vref50, we give it priority */
869 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100870 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200871 else if (pincap & AC_PINCAP_VREF_50)
872 val = PIN_VREF50;
873 else if (pincap & AC_PINCAP_VREF_100)
874 val = PIN_VREF100;
875 else if (pincap & AC_PINCAP_VREF_GRD)
876 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100877 }
878 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
879}
880
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200881static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
882{
883 struct alc_spec *spec = codec->spec;
884 struct auto_pin_cfg *cfg = &spec->autocfg;
885
886 if (!cfg->line_outs) {
887 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
888 cfg->line_out_pins[cfg->line_outs])
889 cfg->line_outs++;
890 }
891 if (!cfg->speaker_outs) {
892 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
893 cfg->speaker_pins[cfg->speaker_outs])
894 cfg->speaker_outs++;
895 }
896 if (!cfg->hp_outs) {
897 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
898 cfg->hp_pins[cfg->hp_outs])
899 cfg->hp_outs++;
900 }
901}
902
Takashi Iwai23f0c042009-02-26 13:03:58 +0100903/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100904 */
905static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
906{
907 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
908 return;
909 spec->mixers[spec->num_mixers++] = mix;
910}
911
912static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
913{
914 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
915 return;
916 spec->init_verbs[spec->num_init_verbs++] = verb;
917}
918
919/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100920 * set up from the preset table
921 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200922static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200923 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100924{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200925 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100926 int i;
927
928 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100929 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100930 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200931 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
932 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100933 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200934
Kailang Yangdf694da2005-12-05 19:42:22 +0100935 spec->channel_mode = preset->channel_mode;
936 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200937 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200938 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100939
Hector Martin3b315d72009-06-02 10:54:19 +0200940 if (preset->const_channel_count)
941 spec->multiout.max_channels = preset->const_channel_count;
942 else
943 spec->multiout.max_channels = spec->channel_mode[0].channels;
944 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100945
946 spec->multiout.num_dacs = preset->num_dacs;
947 spec->multiout.dac_nids = preset->dac_nids;
948 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800949 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100950 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200951
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200952 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200953 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200954 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100955 spec->input_mux = preset->input_mux;
956
957 spec->num_adc_nids = preset->num_adc_nids;
958 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100959 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100960 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100961
962 spec->unsol_event = preset->unsol_event;
963 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200964#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100965 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200966 spec->loopback.amplist = preset->loopbacks;
967#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200968
969 if (preset->setup)
970 preset->setup(codec);
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200971
972 alc_fixup_autocfg_pin_nums(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100973}
974
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200975/* Enable GPIO mask and set output */
976static struct hda_verb alc_gpio1_init_verbs[] = {
977 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
978 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
979 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
980 { }
981};
982
983static struct hda_verb alc_gpio2_init_verbs[] = {
984 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
985 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
986 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
987 { }
988};
989
Kailang Yangbdd148a2007-05-08 15:19:08 +0200990static struct hda_verb alc_gpio3_init_verbs[] = {
991 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
992 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
993 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
994 { }
995};
996
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200997/*
998 * Fix hardware PLL issue
999 * On some codecs, the analog PLL gating control must be off while
1000 * the default value is 1.
1001 */
1002static void alc_fix_pll(struct hda_codec *codec)
1003{
1004 struct alc_spec *spec = codec->spec;
1005 unsigned int val;
1006
1007 if (!spec->pll_nid)
1008 return;
1009 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1010 spec->pll_coef_idx);
1011 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1012 AC_VERB_GET_PROC_COEF, 0);
1013 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1014 spec->pll_coef_idx);
1015 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1016 val & ~(1 << spec->pll_coef_bit));
1017}
1018
1019static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1020 unsigned int coef_idx, unsigned int coef_bit)
1021{
1022 struct alc_spec *spec = codec->spec;
1023 spec->pll_nid = nid;
1024 spec->pll_coef_idx = coef_idx;
1025 spec->pll_coef_bit = coef_bit;
1026 alc_fix_pll(codec);
1027}
1028
Kailang Yang9ad0e492010-09-14 23:22:00 +02001029#ifdef CONFIG_SND_HDA_INPUT_JACK
1030static void alc_free_jack_priv(struct snd_jack *jack)
1031{
1032 struct alc_jack *jacks = jack->private_data;
1033 jacks->nid = 0;
1034 jacks->jack = NULL;
1035}
1036
1037static int alc_add_jack(struct hda_codec *codec,
1038 hda_nid_t nid, int type)
1039{
1040 struct alc_spec *spec;
1041 struct alc_jack *jack;
1042 const char *name;
1043 int err;
1044
1045 spec = codec->spec;
1046 snd_array_init(&spec->jacks, sizeof(*jack), 32);
1047 jack = snd_array_new(&spec->jacks);
1048 if (!jack)
1049 return -ENOMEM;
1050
1051 jack->nid = nid;
1052 jack->type = type;
1053 name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
1054
1055 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
1056 if (err < 0)
1057 return err;
1058 jack->jack->private_data = jack;
1059 jack->jack->private_free = alc_free_jack_priv;
1060 return 0;
1061}
1062
1063static void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1064{
1065 struct alc_spec *spec = codec->spec;
1066 struct alc_jack *jacks = spec->jacks.list;
1067
1068 if (jacks) {
1069 int i;
1070 for (i = 0; i < spec->jacks.used; i++) {
1071 if (jacks->nid == nid) {
1072 unsigned int present;
1073 present = snd_hda_jack_detect(codec, nid);
1074
1075 present = (present) ? jacks->type : 0;
1076
1077 snd_jack_report(jacks->jack, present);
1078 }
1079 jacks++;
1080 }
1081 }
1082}
1083
1084static int alc_init_jacks(struct hda_codec *codec)
1085{
1086 struct alc_spec *spec = codec->spec;
1087 int err;
1088 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1089 unsigned int mic_nid = spec->ext_mic.pin;
1090
Takashi Iwai265a0242010-09-21 11:26:21 +02001091 if (hp_nid) {
1092 err = alc_add_jack(codec, hp_nid, SND_JACK_HEADPHONE);
1093 if (err < 0)
1094 return err;
1095 alc_report_jack(codec, hp_nid);
1096 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001097
Takashi Iwai265a0242010-09-21 11:26:21 +02001098 if (mic_nid) {
1099 err = alc_add_jack(codec, mic_nid, SND_JACK_MICROPHONE);
1100 if (err < 0)
1101 return err;
1102 alc_report_jack(codec, mic_nid);
1103 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001104
1105 return 0;
1106}
1107#else
1108static inline void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1109{
1110}
1111
1112static inline int alc_init_jacks(struct hda_codec *codec)
1113{
1114 return 0;
1115}
1116#endif
1117
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001118static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
Kailang Yangc9b58002007-10-16 14:30:01 +02001119{
1120 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001121 unsigned int mute;
1122 hda_nid_t nid;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001123 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +02001124
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001125 spec->jack_present = 0;
1126 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1127 nid = spec->autocfg.hp_pins[i];
1128 if (!nid)
1129 break;
1130 if (snd_hda_jack_detect(codec, nid)) {
1131 spec->jack_present = 1;
1132 break;
1133 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001134 alc_report_jack(codec, spec->autocfg.hp_pins[i]);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001135 }
1136
1137 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1138 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001139 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1140 nid = spec->autocfg.speaker_pins[i];
1141 if (!nid)
1142 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001143 if (pinctl) {
1144 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001145 AC_VERB_SET_PIN_WIDGET_CONTROL,
1146 spec->jack_present ? 0 : PIN_OUT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001147 } else {
1148 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1149 HDA_AMP_MUTE, mute);
1150 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001151 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001152}
1153
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001154static void alc_automute_pin(struct hda_codec *codec)
1155{
1156 alc_automute_speaker(codec, 1);
1157}
1158
Takashi Iwai6c819492009-08-10 18:47:44 +02001159static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1160 hda_nid_t nid)
1161{
1162 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1163 int i, nums;
1164
1165 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1166 for (i = 0; i < nums; i++)
1167 if (conn[i] == nid)
1168 return i;
1169 return -1;
1170}
1171
Takashi Iwai840b64c2010-07-13 22:49:01 +02001172/* switch the current ADC according to the jack state */
1173static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1174{
1175 struct alc_spec *spec = codec->spec;
1176 unsigned int present;
1177 hda_nid_t new_adc;
1178
1179 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1180 if (present)
1181 spec->cur_adc_idx = 1;
1182 else
1183 spec->cur_adc_idx = 0;
1184 new_adc = spec->adc_nids[spec->cur_adc_idx];
1185 if (spec->cur_adc && spec->cur_adc != new_adc) {
1186 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001187 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001188 spec->cur_adc = new_adc;
1189 snd_hda_codec_setup_stream(codec, new_adc,
1190 spec->cur_adc_stream_tag, 0,
1191 spec->cur_adc_format);
1192 }
1193}
1194
Kailang Yang7fb0d782008-10-15 11:12:35 +02001195static void alc_mic_automute(struct hda_codec *codec)
1196{
1197 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001198 struct alc_mic_route *dead, *alive;
1199 unsigned int present, type;
1200 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001201
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001202 if (!spec->auto_mic)
1203 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001204 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1205 return;
1206 if (snd_BUG_ON(!spec->adc_nids))
1207 return;
1208
Takashi Iwai840b64c2010-07-13 22:49:01 +02001209 if (spec->dual_adc_switch) {
1210 alc_dual_mic_adc_auto_switch(codec);
1211 return;
1212 }
1213
Takashi Iwai6c819492009-08-10 18:47:44 +02001214 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1215
Wu Fengguang864f92b2009-11-18 12:38:02 +08001216 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001217 if (present) {
1218 alive = &spec->ext_mic;
1219 dead = &spec->int_mic;
1220 } else {
1221 alive = &spec->int_mic;
1222 dead = &spec->ext_mic;
1223 }
1224
Takashi Iwai6c819492009-08-10 18:47:44 +02001225 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1226 if (type == AC_WID_AUD_MIX) {
1227 /* Matrix-mixer style (e.g. ALC882) */
1228 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1229 alive->mux_idx,
1230 HDA_AMP_MUTE, 0);
1231 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1232 dead->mux_idx,
1233 HDA_AMP_MUTE, HDA_AMP_MUTE);
1234 } else {
1235 /* MUX style (e.g. ALC880) */
1236 snd_hda_codec_write_cache(codec, cap_nid, 0,
1237 AC_VERB_SET_CONNECT_SEL,
1238 alive->mux_idx);
1239 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001240 alc_report_jack(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001241
1242 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001243}
1244
Kailang Yangc9b58002007-10-16 14:30:01 +02001245/* unsolicited event for HP jack sensing */
1246static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1247{
1248 if (codec->vendor_id == 0x10ec0880)
1249 res >>= 28;
1250 else
1251 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001252 switch (res) {
1253 case ALC880_HP_EVENT:
1254 alc_automute_pin(codec);
1255 break;
1256 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001257 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001258 break;
1259 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001260}
1261
1262static void alc_inithook(struct hda_codec *codec)
1263{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001264 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001265 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001266}
1267
Kailang Yangf9423e72008-05-27 12:32:25 +02001268/* additional initialization for ALC888 variants */
1269static void alc888_coef_init(struct hda_codec *codec)
1270{
1271 unsigned int tmp;
1272
1273 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1274 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1275 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001276 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001277 /* alc888S-VC */
1278 snd_hda_codec_read(codec, 0x20, 0,
1279 AC_VERB_SET_PROC_COEF, 0x830);
1280 else
1281 /* alc888-VB */
1282 snd_hda_codec_read(codec, 0x20, 0,
1283 AC_VERB_SET_PROC_COEF, 0x3030);
1284}
1285
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001286static void alc889_coef_init(struct hda_codec *codec)
1287{
1288 unsigned int tmp;
1289
1290 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1291 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1292 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1293 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1294}
1295
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001296/* turn on/off EAPD control (only if available) */
1297static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1298{
1299 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1300 return;
1301 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1302 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1303 on ? 2 : 0);
1304}
1305
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001306static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001307{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001308 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001309
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001310 switch (type) {
1311 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001312 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1313 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001314 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001315 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1316 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001317 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001318 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1319 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001320 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001321 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001322 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001323 set_eapd(codec, 0x0f, 1);
1324 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001325 break;
1326 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001327 case 0x10ec0267:
1328 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001329 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001330 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001331 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001332 case 0x10ec0660:
1333 case 0x10ec0662:
1334 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001335 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001336 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001337 set_eapd(codec, 0x14, 1);
1338 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001339 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001340 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001341 switch (codec->vendor_id) {
1342 case 0x10ec0260:
1343 snd_hda_codec_write(codec, 0x1a, 0,
1344 AC_VERB_SET_COEF_INDEX, 7);
1345 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1346 AC_VERB_GET_PROC_COEF, 0);
1347 snd_hda_codec_write(codec, 0x1a, 0,
1348 AC_VERB_SET_COEF_INDEX, 7);
1349 snd_hda_codec_write(codec, 0x1a, 0,
1350 AC_VERB_SET_PROC_COEF,
1351 tmp | 0x2010);
1352 break;
1353 case 0x10ec0262:
1354 case 0x10ec0880:
1355 case 0x10ec0882:
1356 case 0x10ec0883:
1357 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001358 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001359 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001360 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001361 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001362 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001363 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001364 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001365#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001366 case 0x10ec0267:
1367 case 0x10ec0268:
1368 snd_hda_codec_write(codec, 0x20, 0,
1369 AC_VERB_SET_COEF_INDEX, 7);
1370 tmp = snd_hda_codec_read(codec, 0x20, 0,
1371 AC_VERB_GET_PROC_COEF, 0);
1372 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001373 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001374 snd_hda_codec_write(codec, 0x20, 0,
1375 AC_VERB_SET_PROC_COEF,
1376 tmp | 0x3000);
1377 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001378#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001379 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001380 break;
1381 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001382}
Kailang Yangea1fb292008-08-26 12:58:38 +02001383
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001384static void alc_init_auto_hp(struct hda_codec *codec)
1385{
1386 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001387 struct auto_pin_cfg *cfg = &spec->autocfg;
1388 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001389
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001390 if (!cfg->hp_pins[0]) {
1391 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001392 return;
1393 }
1394
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001395 if (!cfg->speaker_pins[0]) {
1396 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1397 return;
1398 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1399 sizeof(cfg->speaker_pins));
1400 cfg->speaker_outs = cfg->line_outs;
1401 }
1402
1403 if (!cfg->hp_pins[0]) {
1404 memcpy(cfg->hp_pins, cfg->line_out_pins,
1405 sizeof(cfg->hp_pins));
1406 cfg->hp_outs = cfg->line_outs;
1407 }
1408
1409 for (i = 0; i < cfg->hp_outs; i++) {
1410 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1411 cfg->hp_pins[i]);
1412 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001413 AC_VERB_SET_UNSOLICITED_ENABLE,
1414 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001415 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001416 spec->unsol_event = alc_sku_unsol_event;
1417}
1418
Takashi Iwai6c819492009-08-10 18:47:44 +02001419static void alc_init_auto_mic(struct hda_codec *codec)
1420{
1421 struct alc_spec *spec = codec->spec;
1422 struct auto_pin_cfg *cfg = &spec->autocfg;
1423 hda_nid_t fixed, ext;
1424 int i;
1425
1426 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001427 for (i = 0; i < cfg->num_inputs; i++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001428 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
Takashi Iwai6c819492009-08-10 18:47:44 +02001429 return;
1430
1431 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001432 for (i = 0; i < cfg->num_inputs; i++) {
1433 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001434 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001435 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001436 switch (snd_hda_get_input_pin_attr(defcfg)) {
1437 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001438 if (fixed)
1439 return; /* already occupied */
1440 fixed = nid;
1441 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001442 case INPUT_PIN_ATTR_UNUSED:
1443 return; /* invalid entry */
1444 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001445 if (ext)
1446 return; /* already occupied */
1447 ext = nid;
1448 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001449 }
1450 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001451 if (!ext || !fixed)
1452 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001453 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1454 return; /* no unsol support */
1455 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1456 ext, fixed);
1457 spec->ext_mic.pin = ext;
1458 spec->int_mic.pin = fixed;
1459 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1460 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1461 spec->auto_mic = 1;
1462 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1463 AC_VERB_SET_UNSOLICITED_ENABLE,
1464 AC_USRSP_EN | ALC880_MIC_EVENT);
1465 spec->unsol_event = alc_sku_unsol_event;
1466}
1467
David Henningsson90622912010-10-14 14:50:18 +02001468/* Could be any non-zero and even value. When used as fixup, tells
1469 * the driver to ignore any present sku defines.
1470 */
1471#define ALC_FIXUP_SKU_IGNORE (2)
1472
Kailang Yangda00c242010-03-19 11:23:45 +01001473static int alc_auto_parse_customize_define(struct hda_codec *codec)
1474{
1475 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001476 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001477 struct alc_spec *spec = codec->spec;
1478
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001479 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1480
David Henningsson90622912010-10-14 14:50:18 +02001481 if (spec->cdefine.fixup) {
1482 ass = spec->cdefine.sku_cfg;
1483 if (ass == ALC_FIXUP_SKU_IGNORE)
1484 return -1;
1485 goto do_sku;
1486 }
1487
Kailang Yangda00c242010-03-19 11:23:45 +01001488 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001489 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001490 goto do_sku;
1491
1492 nid = 0x1d;
1493 if (codec->vendor_id == 0x10ec0260)
1494 nid = 0x17;
1495 ass = snd_hda_codec_get_pincfg(codec, nid);
1496
1497 if (!(ass & 1)) {
1498 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1499 codec->chip_name, ass);
1500 return -1;
1501 }
1502
1503 /* check sum */
1504 tmp = 0;
1505 for (i = 1; i < 16; i++) {
1506 if ((ass >> i) & 1)
1507 tmp++;
1508 }
1509 if (((ass >> 16) & 0xf) != tmp)
1510 return -1;
1511
1512 spec->cdefine.port_connectivity = ass >> 30;
1513 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1514 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1515 spec->cdefine.customization = ass >> 8;
1516do_sku:
1517 spec->cdefine.sku_cfg = ass;
1518 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1519 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1520 spec->cdefine.swap = (ass & 0x2) >> 1;
1521 spec->cdefine.override = ass & 0x1;
1522
1523 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1524 nid, spec->cdefine.sku_cfg);
1525 snd_printd("SKU: port_connectivity=0x%x\n",
1526 spec->cdefine.port_connectivity);
1527 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1528 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1529 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1530 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1531 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1532 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1533 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1534
1535 return 0;
1536}
1537
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001538/* check subsystem ID and set up device-specific initialization;
1539 * return 1 if initialized, 0 if invalid SSID
1540 */
1541/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1542 * 31 ~ 16 : Manufacture ID
1543 * 15 ~ 8 : SKU ID
1544 * 7 ~ 0 : Assembly ID
1545 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1546 */
1547static int alc_subsystem_id(struct hda_codec *codec,
1548 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001549 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001550{
1551 unsigned int ass, tmp, i;
1552 unsigned nid;
1553 struct alc_spec *spec = codec->spec;
1554
David Henningsson90622912010-10-14 14:50:18 +02001555 if (spec->cdefine.fixup) {
1556 ass = spec->cdefine.sku_cfg;
1557 if (ass == ALC_FIXUP_SKU_IGNORE)
1558 return 0;
1559 goto do_sku;
1560 }
1561
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001562 ass = codec->subsystem_id & 0xffff;
1563 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1564 goto do_sku;
1565
1566 /* invalid SSID, check the special NID pin defcfg instead */
1567 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001568 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001569 * 29~21 : reserve
1570 * 20 : PCBEEP input
1571 * 19~16 : Check sum (15:1)
1572 * 15~1 : Custom
1573 * 0 : override
1574 */
1575 nid = 0x1d;
1576 if (codec->vendor_id == 0x10ec0260)
1577 nid = 0x17;
1578 ass = snd_hda_codec_get_pincfg(codec, nid);
1579 snd_printd("realtek: No valid SSID, "
1580 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001581 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001582 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001583 return 0;
1584 if ((ass >> 30) != 1) /* no physical connection */
1585 return 0;
1586
1587 /* check sum */
1588 tmp = 0;
1589 for (i = 1; i < 16; i++) {
1590 if ((ass >> i) & 1)
1591 tmp++;
1592 }
1593 if (((ass >> 16) & 0xf) != tmp)
1594 return 0;
1595do_sku:
1596 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1597 ass & 0xffff, codec->vendor_id);
1598 /*
1599 * 0 : override
1600 * 1 : Swap Jack
1601 * 2 : 0 --> Desktop, 1 --> Laptop
1602 * 3~5 : External Amplifier control
1603 * 7~6 : Reserved
1604 */
1605 tmp = (ass & 0x38) >> 3; /* external Amp control */
1606 switch (tmp) {
1607 case 1:
1608 spec->init_amp = ALC_INIT_GPIO1;
1609 break;
1610 case 3:
1611 spec->init_amp = ALC_INIT_GPIO2;
1612 break;
1613 case 7:
1614 spec->init_amp = ALC_INIT_GPIO3;
1615 break;
1616 case 5:
1617 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;
1684};
1685
1686static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001687 const struct snd_pci_quirk *quirk,
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001688 const struct alc_fixup *fix,
1689 int pre_init)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001690{
1691 const struct alc_pincfg *cfg;
David Henningsson90622912010-10-14 14:50:18 +02001692 struct alc_spec *spec;
Takashi Iwaif95474e2007-07-10 00:47:43 +02001693
1694 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1695 if (!quirk)
1696 return;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001697 fix += quirk->value;
1698 cfg = fix->pins;
David Henningsson90622912010-10-14 14:50:18 +02001699 if (pre_init && fix->sku) {
1700#ifdef CONFIG_SND_DEBUG_VERBOSE
1701 snd_printdd(KERN_INFO "hda_codec: %s: Apply sku override for %s\n",
1702 codec->chip_name, quirk->name);
1703#endif
1704 spec = codec->spec;
1705 spec->cdefine.sku_cfg = fix->sku;
1706 spec->cdefine.fixup = 1;
1707 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001708 if (pre_init && cfg) {
1709#ifdef CONFIG_SND_DEBUG_VERBOSE
1710 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1711 codec->chip_name, quirk->name);
1712#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001713 for (; cfg->nid; cfg++)
1714 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1715 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001716 if (!pre_init && fix->verbs) {
1717#ifdef CONFIG_SND_DEBUG_VERBOSE
1718 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1719 codec->chip_name, quirk->name);
1720#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001721 add_verb(codec->spec, fix->verbs);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001722 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001723}
1724
Kailang Yang274693f2009-12-03 10:07:50 +01001725static int alc_read_coef_idx(struct hda_codec *codec,
1726 unsigned int coef_idx)
1727{
1728 unsigned int val;
1729 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1730 coef_idx);
1731 val = snd_hda_codec_read(codec, 0x20, 0,
1732 AC_VERB_GET_PROC_COEF, 0);
1733 return val;
1734}
1735
Kailang Yang977ddd62010-09-15 10:02:29 +02001736static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1737 unsigned int coef_val)
1738{
1739 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1740 coef_idx);
1741 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1742 coef_val);
1743}
1744
Takashi Iwai757899a2010-07-30 10:48:14 +02001745/* set right pin controls for digital I/O */
1746static void alc_auto_init_digital(struct hda_codec *codec)
1747{
1748 struct alc_spec *spec = codec->spec;
1749 int i;
1750 hda_nid_t pin;
1751
1752 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1753 pin = spec->autocfg.dig_out_pins[i];
1754 if (pin) {
1755 snd_hda_codec_write(codec, pin, 0,
1756 AC_VERB_SET_PIN_WIDGET_CONTROL,
1757 PIN_OUT);
1758 }
1759 }
1760 pin = spec->autocfg.dig_in_pin;
1761 if (pin)
1762 snd_hda_codec_write(codec, pin, 0,
1763 AC_VERB_SET_PIN_WIDGET_CONTROL,
1764 PIN_IN);
1765}
1766
1767/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1768static void alc_auto_parse_digital(struct hda_codec *codec)
1769{
1770 struct alc_spec *spec = codec->spec;
1771 int i, err;
1772 hda_nid_t dig_nid;
1773
1774 /* support multiple SPDIFs; the secondary is set up as a slave */
1775 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1776 err = snd_hda_get_connections(codec,
1777 spec->autocfg.dig_out_pins[i],
1778 &dig_nid, 1);
1779 if (err < 0)
1780 continue;
1781 if (!i) {
1782 spec->multiout.dig_out_nid = dig_nid;
1783 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1784 } else {
1785 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1786 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1787 break;
1788 spec->slave_dig_outs[i - 1] = dig_nid;
1789 }
1790 }
1791
1792 if (spec->autocfg.dig_in_pin) {
Takashi Iwai01fdf182010-09-24 09:09:42 +02001793 dig_nid = codec->start_nid;
1794 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1795 unsigned int wcaps = get_wcaps(codec, dig_nid);
1796 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1797 continue;
1798 if (!(wcaps & AC_WCAP_DIGITAL))
1799 continue;
1800 if (!(wcaps & AC_WCAP_CONN_LIST))
1801 continue;
1802 err = get_connection_index(codec, dig_nid,
1803 spec->autocfg.dig_in_pin);
1804 if (err >= 0) {
1805 spec->dig_in_nid = dig_nid;
1806 break;
1807 }
1808 }
Takashi Iwai757899a2010-07-30 10:48:14 +02001809 }
1810}
1811
Takashi Iwaif95474e2007-07-10 00:47:43 +02001812/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001813 * ALC888
1814 */
1815
1816/*
1817 * 2ch mode
1818 */
1819static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1820/* Mic-in jack as mic in */
1821 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1822 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1823/* Line-in jack as Line in */
1824 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1825 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1826/* Line-Out as Front */
1827 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1828 { } /* end */
1829};
1830
1831/*
1832 * 4ch mode
1833 */
1834static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1835/* Mic-in jack as mic in */
1836 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1837 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1838/* Line-in jack as Surround */
1839 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1840 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1841/* Line-Out as Front */
1842 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1843 { } /* end */
1844};
1845
1846/*
1847 * 6ch mode
1848 */
1849static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1850/* Mic-in jack as CLFE */
1851 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1852 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1853/* Line-in jack as Surround */
1854 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1855 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1856/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1857 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1858 { } /* end */
1859};
1860
1861/*
1862 * 8ch mode
1863 */
1864static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1865/* Mic-in jack as CLFE */
1866 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1867 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1868/* Line-in jack as Surround */
1869 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1870 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1871/* Line-Out as Side */
1872 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1873 { } /* end */
1874};
1875
1876static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1877 { 2, alc888_4ST_ch2_intel_init },
1878 { 4, alc888_4ST_ch4_intel_init },
1879 { 6, alc888_4ST_ch6_intel_init },
1880 { 8, alc888_4ST_ch8_intel_init },
1881};
1882
1883/*
1884 * ALC888 Fujitsu Siemens Amillo xa3530
1885 */
1886
1887static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1888/* Front Mic: set to PIN_IN (empty by default) */
1889 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1890/* Connect Internal HP to Front */
1891 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1892 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1893 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1894/* Connect Bass HP to Front */
1895 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1896 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1897 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1898/* Connect Line-Out side jack (SPDIF) to Side */
1899 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1900 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1901 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1902/* Connect Mic jack to CLFE */
1903 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1904 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1905 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1906/* Connect Line-in jack to Surround */
1907 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1908 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1909 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1910/* Connect HP out jack to Front */
1911 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1912 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1913 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1914/* Enable unsolicited event for HP jack and Line-out jack */
1915 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1916 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1917 {}
1918};
1919
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001920static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001921{
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001922 alc_automute_speaker(codec, 0);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001923}
1924
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001925static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1926 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001927{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001928 if (codec->vendor_id == 0x10ec0880)
1929 res >>= 28;
1930 else
1931 res >>= 26;
1932 if (res == ALC880_HP_EVENT)
1933 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001934}
1935
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001936static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001937{
1938 struct alc_spec *spec = codec->spec;
1939
1940 spec->autocfg.hp_pins[0] = 0x15;
1941 spec->autocfg.speaker_pins[0] = 0x14;
1942 spec->autocfg.speaker_pins[1] = 0x16;
1943 spec->autocfg.speaker_pins[2] = 0x17;
1944 spec->autocfg.speaker_pins[3] = 0x19;
1945 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001946}
1947
1948static void alc889_intel_init_hook(struct hda_codec *codec)
1949{
1950 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001951 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001952}
1953
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001954static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001955{
1956 struct alc_spec *spec = codec->spec;
1957
1958 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1959 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1960 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1961 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001962}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001963
1964/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001965 * ALC888 Acer Aspire 4930G model
1966 */
1967
1968static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1969/* Front Mic: set to PIN_IN (empty by default) */
1970 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1971/* Unselect Front Mic by default in input mixer 3 */
1972 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001973/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001974 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1975/* Connect Internal HP to front */
1976 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1977 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1978 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1979/* Connect HP out to front */
1980 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1981 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1982 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1983 { }
1984};
1985
Hector Martin3b315d72009-06-02 10:54:19 +02001986/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001987 * ALC888 Acer Aspire 6530G model
1988 */
1989
1990static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01001991/* Route to built-in subwoofer as well as speakers */
1992 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1993 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1994 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1995 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001996/* Bias voltage on for external mic port */
1997 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001998/* Front Mic: set to PIN_IN (empty by default) */
1999 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2000/* Unselect Front Mic by default in input mixer 3 */
2001 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002002/* Enable unsolicited event for HP jack */
2003 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2004/* Enable speaker output */
2005 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2006 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01002007 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002008/* Enable headphone output */
2009 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2010 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2011 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01002012 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002013 { }
2014};
2015
2016/*
Hector Martin018df412009-06-04 00:13:40 +02002017 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02002018 */
2019
Hector Martin018df412009-06-04 00:13:40 +02002020static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02002021/* Front Mic: set to PIN_IN (empty by default) */
2022 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2023/* Unselect Front Mic by default in input mixer 3 */
2024 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2025/* Enable unsolicited event for HP jack */
2026 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2027/* Connect Internal Front to Front */
2028 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2029 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2030 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2031/* Connect Internal Rear to Rear */
2032 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2033 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2034 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
2035/* Connect Internal CLFE to CLFE */
2036 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2037 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2038 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2039/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02002040 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02002041 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2042 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2043/* Enable all DACs */
2044/* DAC DISABLE/MUTE 1? */
2045/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2046 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2047 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2048/* DAC DISABLE/MUTE 2? */
2049/* some bit here disables the other DACs. Init=0x4900 */
2050 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2051 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002052/* DMIC fix
2053 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2054 * which makes the stereo useless. However, either the mic or the ALC889
2055 * makes the signal become a difference/sum signal instead of standard
2056 * stereo, which is annoying. So instead we flip this bit which makes the
2057 * codec replicate the sum signal to both channels, turning it into a
2058 * normal mono mic.
2059 */
2060/* DMIC_CONTROL? Init value = 0x0001 */
2061 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2062 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002063 { }
2064};
2065
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002066static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002067 /* Front mic only available on one ADC */
2068 {
2069 .num_items = 4,
2070 .items = {
2071 { "Mic", 0x0 },
2072 { "Line", 0x2 },
2073 { "CD", 0x4 },
2074 { "Front Mic", 0xb },
2075 },
2076 },
2077 {
2078 .num_items = 3,
2079 .items = {
2080 { "Mic", 0x0 },
2081 { "Line", 0x2 },
2082 { "CD", 0x4 },
2083 },
2084 }
2085};
2086
Tony Vroond2fd4b02009-06-21 00:40:10 +01002087static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2088 /* Interal mic only available on one ADC */
2089 {
Tony Vroon684a8842009-06-26 09:27:50 +01002090 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002091 .items = {
2092 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002093 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002094 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002095 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002096 { "Int Mic", 0xb },
2097 },
2098 },
2099 {
Tony Vroon684a8842009-06-26 09:27:50 +01002100 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002101 .items = {
2102 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002103 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002104 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002105 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002106 },
2107 }
2108};
2109
Hector Martin018df412009-06-04 00:13:40 +02002110static struct hda_input_mux alc889_capture_sources[3] = {
2111 /* Digital mic only available on first "ADC" */
2112 {
2113 .num_items = 5,
2114 .items = {
2115 { "Mic", 0x0 },
2116 { "Line", 0x2 },
2117 { "CD", 0x4 },
2118 { "Front Mic", 0xb },
2119 { "Input Mix", 0xa },
2120 },
2121 },
2122 {
2123 .num_items = 4,
2124 .items = {
2125 { "Mic", 0x0 },
2126 { "Line", 0x2 },
2127 { "CD", 0x4 },
2128 { "Input Mix", 0xa },
2129 },
2130 },
2131 {
2132 .num_items = 4,
2133 .items = {
2134 { "Mic", 0x0 },
2135 { "Line", 0x2 },
2136 { "CD", 0x4 },
2137 { "Input Mix", 0xa },
2138 },
2139 }
2140};
2141
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002142static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002143 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2144 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2145 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2146 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2147 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2148 HDA_OUTPUT),
2149 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2150 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2151 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2152 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2153 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2154 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2155 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2156 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2157 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2158 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2159 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2160 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002161 { } /* end */
2162};
2163
Hector Martin556eea92009-12-20 22:51:23 +01002164static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2165 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2166 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2167 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2168 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2169 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2170 HDA_OUTPUT),
2171 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2172 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2173 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2174 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2175 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2176 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2177 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2179 { } /* end */
2180};
2181
2182
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002183static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002184{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002185 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002186
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002187 spec->autocfg.hp_pins[0] = 0x15;
2188 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002189 spec->autocfg.speaker_pins[1] = 0x16;
2190 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002191}
2192
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002193static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002194{
2195 struct alc_spec *spec = codec->spec;
2196
2197 spec->autocfg.hp_pins[0] = 0x15;
2198 spec->autocfg.speaker_pins[0] = 0x14;
2199 spec->autocfg.speaker_pins[1] = 0x16;
2200 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002201}
2202
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002203static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002204{
2205 struct alc_spec *spec = codec->spec;
2206
2207 spec->autocfg.hp_pins[0] = 0x15;
2208 spec->autocfg.speaker_pins[0] = 0x14;
2209 spec->autocfg.speaker_pins[1] = 0x16;
2210 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002211}
2212
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002213/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002214 * ALC880 3-stack model
2215 *
2216 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002217 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2218 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002219 */
2220
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002221static hda_nid_t alc880_dac_nids[4] = {
2222 /* front, rear, clfe, rear_surr */
2223 0x02, 0x05, 0x04, 0x03
2224};
2225
2226static hda_nid_t alc880_adc_nids[3] = {
2227 /* ADC0-2 */
2228 0x07, 0x08, 0x09,
2229};
2230
2231/* The datasheet says the node 0x07 is connected from inputs,
2232 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002233 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002234 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002235static hda_nid_t alc880_adc_nids_alt[2] = {
2236 /* ADC1-2 */
2237 0x08, 0x09,
2238};
2239
2240#define ALC880_DIGOUT_NID 0x06
2241#define ALC880_DIGIN_NID 0x0a
2242
2243static struct hda_input_mux alc880_capture_source = {
2244 .num_items = 4,
2245 .items = {
2246 { "Mic", 0x0 },
2247 { "Front Mic", 0x3 },
2248 { "Line", 0x2 },
2249 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002250 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002251};
2252
2253/* channel source setting (2/6 channel selection for 3-stack) */
2254/* 2ch mode */
2255static struct hda_verb alc880_threestack_ch2_init[] = {
2256 /* set line-in to input, mute it */
2257 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2258 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2259 /* set mic-in to input vref 80%, mute it */
2260 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2261 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002262 { } /* end */
2263};
2264
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002265/* 6ch mode */
2266static struct hda_verb alc880_threestack_ch6_init[] = {
2267 /* set line-in to output, unmute it */
2268 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2269 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2270 /* set mic-in to output, unmute it */
2271 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2272 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2273 { } /* end */
2274};
2275
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002276static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002277 { 2, alc880_threestack_ch2_init },
2278 { 6, alc880_threestack_ch6_init },
2279};
2280
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002281static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002282 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002283 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002284 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002285 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002286 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2287 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002288 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2289 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002290 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2291 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2292 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2293 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2294 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2295 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2296 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2297 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002298 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002299 {
2300 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2301 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002302 .info = alc_ch_mode_info,
2303 .get = alc_ch_mode_get,
2304 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002305 },
2306 { } /* end */
2307};
2308
2309/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002310static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2311 struct snd_ctl_elem_info *uinfo)
2312{
2313 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2314 struct alc_spec *spec = codec->spec;
2315 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002316
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002317 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002318 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2319 HDA_INPUT);
2320 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002321 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002322 return err;
2323}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002324
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002325static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2326 unsigned int size, unsigned int __user *tlv)
2327{
2328 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2329 struct alc_spec *spec = codec->spec;
2330 int err;
2331
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002332 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002333 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2334 HDA_INPUT);
2335 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002336 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002337 return err;
2338}
2339
2340typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2341 struct snd_ctl_elem_value *ucontrol);
2342
2343static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2344 struct snd_ctl_elem_value *ucontrol,
2345 getput_call_t func)
2346{
2347 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2348 struct alc_spec *spec = codec->spec;
2349 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2350 int err;
2351
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002352 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002353 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2354 3, 0, HDA_INPUT);
2355 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002356 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002357 return err;
2358}
2359
2360static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2361 struct snd_ctl_elem_value *ucontrol)
2362{
2363 return alc_cap_getput_caller(kcontrol, ucontrol,
2364 snd_hda_mixer_amp_volume_get);
2365}
2366
2367static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2368 struct snd_ctl_elem_value *ucontrol)
2369{
2370 return alc_cap_getput_caller(kcontrol, ucontrol,
2371 snd_hda_mixer_amp_volume_put);
2372}
2373
2374/* capture mixer elements */
2375#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2376
2377static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2378 struct snd_ctl_elem_value *ucontrol)
2379{
2380 return alc_cap_getput_caller(kcontrol, ucontrol,
2381 snd_hda_mixer_amp_switch_get);
2382}
2383
2384static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2385 struct snd_ctl_elem_value *ucontrol)
2386{
2387 return alc_cap_getput_caller(kcontrol, ucontrol,
2388 snd_hda_mixer_amp_switch_put);
2389}
2390
Takashi Iwaia23b6882009-03-23 15:21:36 +01002391#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002392 { \
2393 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2394 .name = "Capture Switch", \
2395 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2396 .count = num, \
2397 .info = alc_cap_sw_info, \
2398 .get = alc_cap_sw_get, \
2399 .put = alc_cap_sw_put, \
2400 }, \
2401 { \
2402 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2403 .name = "Capture Volume", \
2404 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2405 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2406 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2407 .count = num, \
2408 .info = alc_cap_vol_info, \
2409 .get = alc_cap_vol_get, \
2410 .put = alc_cap_vol_put, \
2411 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002412 }
2413
2414#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002415 { \
2416 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2417 /* .name = "Capture Source", */ \
2418 .name = "Input Source", \
2419 .count = num, \
2420 .info = alc_mux_enum_info, \
2421 .get = alc_mux_enum_get, \
2422 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002423 }
2424
2425#define DEFINE_CAPMIX(num) \
2426static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2427 _DEFINE_CAPMIX(num), \
2428 _DEFINE_CAPSRC(num), \
2429 { } /* end */ \
2430}
2431
2432#define DEFINE_CAPMIX_NOSRC(num) \
2433static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2434 _DEFINE_CAPMIX(num), \
2435 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002436}
2437
2438/* up to three ADCs */
2439DEFINE_CAPMIX(1);
2440DEFINE_CAPMIX(2);
2441DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002442DEFINE_CAPMIX_NOSRC(1);
2443DEFINE_CAPMIX_NOSRC(2);
2444DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002445
2446/*
2447 * ALC880 5-stack model
2448 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002449 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2450 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002451 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2452 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2453 */
2454
2455/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002456static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002457 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002458 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002459 { } /* end */
2460};
2461
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002462/* channel source setting (6/8 channel selection for 5-stack) */
2463/* 6ch mode */
2464static struct hda_verb alc880_fivestack_ch6_init[] = {
2465 /* set line-in to input, mute it */
2466 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2467 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002468 { } /* end */
2469};
2470
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002471/* 8ch mode */
2472static struct hda_verb alc880_fivestack_ch8_init[] = {
2473 /* set line-in to output, unmute it */
2474 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2475 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2476 { } /* end */
2477};
2478
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002479static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002480 { 6, alc880_fivestack_ch6_init },
2481 { 8, alc880_fivestack_ch8_init },
2482};
2483
2484
2485/*
2486 * ALC880 6-stack model
2487 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002488 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2489 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002490 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2491 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2492 */
2493
2494static hda_nid_t alc880_6st_dac_nids[4] = {
2495 /* front, rear, clfe, rear_surr */
2496 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002497};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002498
2499static struct hda_input_mux alc880_6stack_capture_source = {
2500 .num_items = 4,
2501 .items = {
2502 { "Mic", 0x0 },
2503 { "Front Mic", 0x1 },
2504 { "Line", 0x2 },
2505 { "CD", 0x4 },
2506 },
2507};
2508
2509/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002510static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002511 { 8, NULL },
2512};
2513
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002514static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002515 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002516 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002517 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002518 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002519 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2520 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002521 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2522 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002523 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002524 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002525 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2526 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2527 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2528 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2529 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2530 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2531 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2532 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002533 {
2534 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2535 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002536 .info = alc_ch_mode_info,
2537 .get = alc_ch_mode_get,
2538 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002539 },
2540 { } /* end */
2541};
2542
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002543
2544/*
2545 * ALC880 W810 model
2546 *
2547 * W810 has rear IO for:
2548 * Front (DAC 02)
2549 * Surround (DAC 03)
2550 * Center/LFE (DAC 04)
2551 * Digital out (06)
2552 *
2553 * The system also has a pair of internal speakers, and a headphone jack.
2554 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002555 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002556 * There is a variable resistor to control the speaker or headphone
2557 * volume. This is a hardware-only device without a software API.
2558 *
2559 * Plugging headphones in will disable the internal speakers. This is
2560 * implemented in hardware, not via the driver using jack sense. In
2561 * a similar fashion, plugging into the rear socket marked "front" will
2562 * disable both the speakers and headphones.
2563 *
2564 * For input, there's a microphone jack, and an "audio in" jack.
2565 * These may not do anything useful with this driver yet, because I
2566 * haven't setup any initialization verbs for these yet...
2567 */
2568
2569static hda_nid_t alc880_w810_dac_nids[3] = {
2570 /* front, rear/surround, clfe */
2571 0x02, 0x03, 0x04
2572};
2573
2574/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002575static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002576 { 6, NULL }
2577};
2578
2579/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002580static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002581 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002582 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002583 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002584 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002585 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2586 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002587 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2588 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002589 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2590 { } /* end */
2591};
2592
2593
2594/*
2595 * Z710V model
2596 *
2597 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002598 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2599 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002600 */
2601
2602static hda_nid_t alc880_z71v_dac_nids[1] = {
2603 0x02
2604};
2605#define ALC880_Z71V_HP_DAC 0x03
2606
2607/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002608static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002609 { 2, NULL }
2610};
2611
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002612static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002613 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002614 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002615 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002616 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002617 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2618 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2619 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2620 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2621 { } /* end */
2622};
2623
2624
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002625/*
2626 * ALC880 F1734 model
2627 *
2628 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2629 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2630 */
2631
2632static hda_nid_t alc880_f1734_dac_nids[1] = {
2633 0x03
2634};
2635#define ALC880_F1734_HP_DAC 0x02
2636
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002637static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002638 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002639 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002640 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2641 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002642 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2643 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002644 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2645 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002646 { } /* end */
2647};
2648
Takashi Iwai937b4162008-02-11 14:52:36 +01002649static struct hda_input_mux alc880_f1734_capture_source = {
2650 .num_items = 2,
2651 .items = {
2652 { "Mic", 0x1 },
2653 { "CD", 0x4 },
2654 },
2655};
2656
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002657
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002658/*
2659 * ALC880 ASUS model
2660 *
2661 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2662 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2663 * Mic = 0x18, Line = 0x1a
2664 */
2665
2666#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2667#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2668
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002669static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002670 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002671 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002672 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002673 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002674 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2675 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002676 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2677 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002678 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2679 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2680 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2681 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2682 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2683 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002684 {
2685 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2686 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002687 .info = alc_ch_mode_info,
2688 .get = alc_ch_mode_get,
2689 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002690 },
2691 { } /* end */
2692};
2693
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002694/*
2695 * ALC880 ASUS W1V model
2696 *
2697 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2698 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2699 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2700 */
2701
2702/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002703static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002704 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2705 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002706 { } /* end */
2707};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002708
Kailang Yangdf694da2005-12-05 19:42:22 +01002709/* TCL S700 */
2710static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2711 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2712 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2713 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2714 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2715 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2716 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2717 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2718 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2719 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002720 { } /* end */
2721};
2722
Kailang Yangccc656c2006-10-17 12:32:26 +02002723/* Uniwill */
2724static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002725 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2726 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2727 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2728 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002729 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2730 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2731 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2732 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2733 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2734 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2735 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2736 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2737 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2738 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2739 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2740 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002741 {
2742 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2743 .name = "Channel Mode",
2744 .info = alc_ch_mode_info,
2745 .get = alc_ch_mode_get,
2746 .put = alc_ch_mode_put,
2747 },
2748 { } /* end */
2749};
2750
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002751static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2752 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2753 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2754 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2755 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2756 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2757 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2758 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2759 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2760 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2761 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2762 { } /* end */
2763};
2764
Kailang Yangccc656c2006-10-17 12:32:26 +02002765static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002766 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2767 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2768 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2769 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002770 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2771 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2772 { } /* end */
2773};
2774
Linus Torvalds1da177e2005-04-16 15:20:36 -07002775/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002776 * virtual master controls
2777 */
2778
2779/*
2780 * slave controls for virtual master
2781 */
2782static const char *alc_slave_vols[] = {
2783 "Front Playback Volume",
2784 "Surround Playback Volume",
2785 "Center Playback Volume",
2786 "LFE Playback Volume",
2787 "Side Playback Volume",
2788 "Headphone Playback Volume",
2789 "Speaker Playback Volume",
2790 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002791 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002792 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002793 NULL,
2794};
2795
2796static const char *alc_slave_sws[] = {
2797 "Front Playback Switch",
2798 "Surround Playback Switch",
2799 "Center Playback Switch",
2800 "LFE Playback Switch",
2801 "Side Playback Switch",
2802 "Headphone Playback Switch",
2803 "Speaker Playback Switch",
2804 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002805 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002806 "Line-Out Playback Switch",
2807 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002808 NULL,
2809};
2810
2811/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002812 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002813 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002814
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002815#define NID_MAPPING (-1)
2816
2817#define SUBDEV_SPEAKER_ (0 << 6)
2818#define SUBDEV_HP_ (1 << 6)
2819#define SUBDEV_LINE_ (2 << 6)
2820#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2821#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2822#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2823
Takashi Iwai603c4012008-07-30 15:01:44 +02002824static void alc_free_kctls(struct hda_codec *codec);
2825
Takashi Iwai67d634c2009-11-16 15:35:59 +01002826#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002827/* additional beep mixers; the actual parameters are overwritten at build */
2828static struct snd_kcontrol_new alc_beep_mixer[] = {
2829 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002830 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002831 { } /* end */
2832};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002833#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002834
Linus Torvalds1da177e2005-04-16 15:20:36 -07002835static int alc_build_controls(struct hda_codec *codec)
2836{
2837 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002838 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002839 struct snd_kcontrol_new *knew;
2840 int i, j, err;
2841 unsigned int u;
2842 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002843
2844 for (i = 0; i < spec->num_mixers; i++) {
2845 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2846 if (err < 0)
2847 return err;
2848 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002849 if (spec->cap_mixer) {
2850 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2851 if (err < 0)
2852 return err;
2853 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002854 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002855 err = snd_hda_create_spdif_out_ctls(codec,
2856 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002857 if (err < 0)
2858 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002859 if (!spec->no_analog) {
2860 err = snd_hda_create_spdif_share_sw(codec,
2861 &spec->multiout);
2862 if (err < 0)
2863 return err;
2864 spec->multiout.share_spdif = 1;
2865 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002866 }
2867 if (spec->dig_in_nid) {
2868 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2869 if (err < 0)
2870 return err;
2871 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002872
Takashi Iwai67d634c2009-11-16 15:35:59 +01002873#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002874 /* create beep controls if needed */
2875 if (spec->beep_amp) {
2876 struct snd_kcontrol_new *knew;
2877 for (knew = alc_beep_mixer; knew->name; knew++) {
2878 struct snd_kcontrol *kctl;
2879 kctl = snd_ctl_new1(knew, codec);
2880 if (!kctl)
2881 return -ENOMEM;
2882 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002883 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002884 if (err < 0)
2885 return err;
2886 }
2887 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002888#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002889
Takashi Iwai2134ea42008-01-10 16:53:55 +01002890 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002891 if (!spec->no_analog &&
2892 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002893 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002894 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002895 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002896 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002897 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002898 if (err < 0)
2899 return err;
2900 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002901 if (!spec->no_analog &&
2902 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002903 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2904 NULL, alc_slave_sws);
2905 if (err < 0)
2906 return err;
2907 }
2908
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002909 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002910 if (spec->capsrc_nids || spec->adc_nids) {
2911 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2912 if (!kctl)
2913 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2914 for (i = 0; kctl && i < kctl->count; i++) {
2915 hda_nid_t *nids = spec->capsrc_nids;
2916 if (!nids)
2917 nids = spec->adc_nids;
2918 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
2919 if (err < 0)
2920 return err;
2921 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002922 }
2923 if (spec->cap_mixer) {
2924 const char *kname = kctl ? kctl->id.name : NULL;
2925 for (knew = spec->cap_mixer; knew->name; knew++) {
2926 if (kname && strcmp(knew->name, kname) == 0)
2927 continue;
2928 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2929 for (i = 0; kctl && i < kctl->count; i++) {
2930 err = snd_hda_add_nid(codec, kctl, i,
2931 spec->adc_nids[i]);
2932 if (err < 0)
2933 return err;
2934 }
2935 }
2936 }
2937
2938 /* other nid->control mapping */
2939 for (i = 0; i < spec->num_mixers; i++) {
2940 for (knew = spec->mixers[i]; knew->name; knew++) {
2941 if (knew->iface != NID_MAPPING)
2942 continue;
2943 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2944 if (kctl == NULL)
2945 continue;
2946 u = knew->subdevice;
2947 for (j = 0; j < 4; j++, u >>= 8) {
2948 nid = u & 0x3f;
2949 if (nid == 0)
2950 continue;
2951 switch (u & 0xc0) {
2952 case SUBDEV_SPEAKER_:
2953 nid = spec->autocfg.speaker_pins[nid];
2954 break;
2955 case SUBDEV_LINE_:
2956 nid = spec->autocfg.line_out_pins[nid];
2957 break;
2958 case SUBDEV_HP_:
2959 nid = spec->autocfg.hp_pins[nid];
2960 break;
2961 default:
2962 continue;
2963 }
2964 err = snd_hda_add_nid(codec, kctl, 0, nid);
2965 if (err < 0)
2966 return err;
2967 }
2968 u = knew->private_value;
2969 for (j = 0; j < 4; j++, u >>= 8) {
2970 nid = u & 0xff;
2971 if (nid == 0)
2972 continue;
2973 err = snd_hda_add_nid(codec, kctl, 0, nid);
2974 if (err < 0)
2975 return err;
2976 }
2977 }
2978 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01002979
2980 alc_free_kctls(codec); /* no longer needed */
2981
Linus Torvalds1da177e2005-04-16 15:20:36 -07002982 return 0;
2983}
2984
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002985
Linus Torvalds1da177e2005-04-16 15:20:36 -07002986/*
2987 * initialize the codec volumes, etc
2988 */
2989
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002990/*
2991 * generic initialization of ADC, input mixers and output mixers
2992 */
2993static struct hda_verb alc880_volume_init_verbs[] = {
2994 /*
2995 * Unmute ADC0-2 and set the default input to mic-in
2996 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002997 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002998 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002999 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003000 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003001 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003002 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003003
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003004 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3005 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003006 * Note: PASD motherboards uses the Line In 2 as the input for front
3007 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003008 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003009 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003010 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3011 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3012 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3013 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3014 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3015 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3016 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003017
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003018 /*
3019 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003020 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003021 /* set vol=0 to output mixers */
3022 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3023 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3024 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3025 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3026 /* set up input amps for analog loopback */
3027 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003028 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3029 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003030 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3031 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003032 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3033 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003034 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3035 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003036
3037 { }
3038};
3039
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003040/*
3041 * 3-stack pin configuration:
3042 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3043 */
3044static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3045 /*
3046 * preset connection lists of input pins
3047 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3048 */
3049 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3050 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3051 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3052
3053 /*
3054 * Set pin mode and muting
3055 */
3056 /* set front pin widgets 0x14 for output */
3057 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3058 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3059 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3060 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3061 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3062 /* Mic2 (as headphone out) for HP output */
3063 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3064 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3065 /* Line In pin widget for input */
3066 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3067 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3068 /* Line2 (as front mic) pin widget for input and vref at 80% */
3069 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3070 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3071 /* CD pin widget for input */
3072 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3073
3074 { }
3075};
3076
3077/*
3078 * 5-stack pin configuration:
3079 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3080 * line-in/side = 0x1a, f-mic = 0x1b
3081 */
3082static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3083 /*
3084 * preset connection lists of input pins
3085 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3086 */
3087 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3088 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3089
3090 /*
3091 * Set pin mode and muting
3092 */
3093 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003094 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3095 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3096 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3097 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003098 /* unmute pins for output (no gain on this amp) */
3099 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3100 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3101 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3102 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3103
Linus Torvalds1da177e2005-04-16 15:20:36 -07003104 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003105 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003106 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3107 /* Mic2 (as headphone out) for HP output */
3108 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003109 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003110 /* Line In pin widget for input */
3111 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3112 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3113 /* Line2 (as front mic) pin widget for input and vref at 80% */
3114 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3115 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3116 /* CD pin widget for input */
3117 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003118
3119 { }
3120};
3121
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003122/*
3123 * W810 pin configuration:
3124 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3125 */
3126static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003127 /* hphone/speaker input selector: front DAC */
3128 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3129
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003130 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3131 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3132 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3133 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3134 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3135 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3136
3137 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003138 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003139
Linus Torvalds1da177e2005-04-16 15:20:36 -07003140 { }
3141};
3142
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003143/*
3144 * Z71V pin configuration:
3145 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3146 */
3147static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003148 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003149 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003150 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003151 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003152
Takashi Iwai16ded522005-06-10 19:58:24 +02003153 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003154 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003155 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003156 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003157
3158 { }
3159};
3160
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003161/*
3162 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003163 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3164 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003165 */
3166static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3167 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3168
Takashi Iwai16ded522005-06-10 19:58:24 +02003169 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003170 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003171 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003172 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003173 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003174 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003175 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003176 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3177
Takashi Iwai16ded522005-06-10 19:58:24 +02003178 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003179 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003180 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003181 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003182 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003183 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003184 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003185 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003186 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003187
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003188 { }
3189};
Takashi Iwai16ded522005-06-10 19:58:24 +02003190
Kailang Yangccc656c2006-10-17 12:32:26 +02003191/*
3192 * Uniwill pin configuration:
3193 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3194 * line = 0x1a
3195 */
3196static struct hda_verb alc880_uniwill_init_verbs[] = {
3197 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3198
3199 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3200 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3201 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3202 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3203 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3204 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3205 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3206 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3207 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3208 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3209 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3210 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3211 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3212 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3213
3214 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3215 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3216 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3217 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3218 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3219 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3220 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3221 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3222 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3223
3224 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3225 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3226
3227 { }
3228};
3229
3230/*
3231* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003232* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003233 */
3234static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3235 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3236
3237 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3238 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3239 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3241 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3242 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3243 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3244 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3245 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3246 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3247 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3248 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3249
3250 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3251 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3252 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3253 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3254 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3255 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3256
3257 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3258 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3259
3260 { }
3261};
3262
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003263static struct hda_verb alc880_beep_init_verbs[] = {
3264 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3265 { }
3266};
3267
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003268/* auto-toggle front mic */
3269static void alc880_uniwill_mic_automute(struct hda_codec *codec)
3270{
3271 unsigned int present;
3272 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003273
Wu Fengguang864f92b2009-11-18 12:38:02 +08003274 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003275 bits = present ? HDA_AMP_MUTE : 0;
3276 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003277}
3278
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003279static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003280{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003281 struct alc_spec *spec = codec->spec;
3282
3283 spec->autocfg.hp_pins[0] = 0x14;
3284 spec->autocfg.speaker_pins[0] = 0x15;
3285 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003286}
3287
3288static void alc880_uniwill_init_hook(struct hda_codec *codec)
3289{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003290 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003291 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003292}
3293
3294static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3295 unsigned int res)
3296{
3297 /* Looks like the unsol event is incompatible with the standard
3298 * definition. 4bit tag is placed at 28 bit!
3299 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003300 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003301 case ALC880_MIC_EVENT:
3302 alc880_uniwill_mic_automute(codec);
3303 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003304 default:
3305 alc_automute_amp_unsol_event(codec, res);
3306 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003307 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003308}
3309
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003310static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003311{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003312 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003313
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003314 spec->autocfg.hp_pins[0] = 0x14;
3315 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003316}
3317
3318static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3319{
3320 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003321
Kailang Yangccc656c2006-10-17 12:32:26 +02003322 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003323 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3324 present &= HDA_AMP_VOLMASK;
3325 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3326 HDA_AMP_VOLMASK, present);
3327 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3328 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003329}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003330
Kailang Yangccc656c2006-10-17 12:32:26 +02003331static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3332 unsigned int res)
3333{
3334 /* Looks like the unsol event is incompatible with the standard
3335 * definition. 4bit tag is placed at 28 bit!
3336 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003337 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003338 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003339 else
3340 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003341}
3342
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003343/*
3344 * F1734 pin configuration:
3345 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3346 */
3347static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003348 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003349 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3350 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3351 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3352 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3353
3354 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3355 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3356 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3357 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3358
3359 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3360 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003361 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003362 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3363 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3364 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3365 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3366 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3367 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003368
Takashi Iwai937b4162008-02-11 14:52:36 +01003369 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3370 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3371
Takashi Iwai16ded522005-06-10 19:58:24 +02003372 { }
3373};
3374
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003375/*
3376 * ASUS pin configuration:
3377 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3378 */
3379static struct hda_verb alc880_pin_asus_init_verbs[] = {
3380 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3381 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3382 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3383 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3384
3385 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3386 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3387 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3388 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3389 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3390 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3391 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3392 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3393
3394 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3395 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3396 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3397 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3398 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3399 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3400 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3401 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3402 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003403
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003404 { }
3405};
3406
3407/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003408#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3409#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003410#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003411
Kailang Yangdf694da2005-12-05 19:42:22 +01003412/* Clevo m520g init */
3413static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3414 /* headphone output */
3415 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3416 /* line-out */
3417 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3418 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3419 /* Line-in */
3420 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3421 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3422 /* CD */
3423 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3424 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3425 /* Mic1 (rear panel) */
3426 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3427 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3428 /* Mic2 (front panel) */
3429 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3430 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3431 /* headphone */
3432 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3433 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3434 /* change to EAPD mode */
3435 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3436 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3437
3438 { }
3439};
3440
3441static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003442 /* change to EAPD mode */
3443 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3444 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3445
Kailang Yangdf694da2005-12-05 19:42:22 +01003446 /* Headphone output */
3447 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3448 /* Front output*/
3449 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3450 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3451
3452 /* Line In pin widget for input */
3453 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3454 /* CD pin widget for input */
3455 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3456 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3457 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3458
3459 /* change to EAPD mode */
3460 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3461 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3462
3463 { }
3464};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003465
3466/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003467 * LG m1 express dual
3468 *
3469 * Pin assignment:
3470 * Rear Line-In/Out (blue): 0x14
3471 * Build-in Mic-In: 0x15
3472 * Speaker-out: 0x17
3473 * HP-Out (green): 0x1b
3474 * Mic-In/Out (red): 0x19
3475 * SPDIF-Out: 0x1e
3476 */
3477
3478/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3479static hda_nid_t alc880_lg_dac_nids[3] = {
3480 0x05, 0x02, 0x03
3481};
3482
3483/* seems analog CD is not working */
3484static struct hda_input_mux alc880_lg_capture_source = {
3485 .num_items = 3,
3486 .items = {
3487 { "Mic", 0x1 },
3488 { "Line", 0x5 },
3489 { "Internal Mic", 0x6 },
3490 },
3491};
3492
3493/* 2,4,6 channel modes */
3494static struct hda_verb alc880_lg_ch2_init[] = {
3495 /* set line-in and mic-in to input */
3496 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3497 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3498 { }
3499};
3500
3501static struct hda_verb alc880_lg_ch4_init[] = {
3502 /* set line-in to out and mic-in to input */
3503 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3504 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3505 { }
3506};
3507
3508static struct hda_verb alc880_lg_ch6_init[] = {
3509 /* set line-in and mic-in to output */
3510 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3511 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3512 { }
3513};
3514
3515static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3516 { 2, alc880_lg_ch2_init },
3517 { 4, alc880_lg_ch4_init },
3518 { 6, alc880_lg_ch6_init },
3519};
3520
3521static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003522 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3523 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003524 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3525 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3526 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3527 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3528 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3529 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3530 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3531 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3532 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3533 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3534 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3535 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3536 {
3537 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3538 .name = "Channel Mode",
3539 .info = alc_ch_mode_info,
3540 .get = alc_ch_mode_get,
3541 .put = alc_ch_mode_put,
3542 },
3543 { } /* end */
3544};
3545
3546static struct hda_verb alc880_lg_init_verbs[] = {
3547 /* set capture source to mic-in */
3548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3549 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3550 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3551 /* mute all amp mixer inputs */
3552 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003553 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3554 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003555 /* line-in to input */
3556 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3557 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3558 /* built-in mic */
3559 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3560 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3561 /* speaker-out */
3562 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3563 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3564 /* mic-in to input */
3565 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3566 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3567 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3568 /* HP-out */
3569 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3570 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3571 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3572 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003573 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003574 { }
3575};
3576
3577/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003578static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003579{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003580 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003581
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003582 spec->autocfg.hp_pins[0] = 0x1b;
3583 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003584}
3585
3586/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003587 * LG LW20
3588 *
3589 * Pin assignment:
3590 * Speaker-out: 0x14
3591 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003592 * Built-in Mic-In: 0x19
3593 * Line-In: 0x1b
3594 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003595 * SPDIF-Out: 0x1e
3596 */
3597
Takashi Iwaid6815182006-03-23 16:06:23 +01003598static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003599 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003600 .items = {
3601 { "Mic", 0x0 },
3602 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003603 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003604 },
3605};
3606
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003607#define alc880_lg_lw_modes alc880_threestack_modes
3608
Takashi Iwaid6815182006-03-23 16:06:23 +01003609static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003610 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3611 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3612 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3613 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3614 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3615 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3616 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3617 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3618 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3619 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003620 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3621 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3622 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3623 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003624 {
3625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3626 .name = "Channel Mode",
3627 .info = alc_ch_mode_info,
3628 .get = alc_ch_mode_get,
3629 .put = alc_ch_mode_put,
3630 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003631 { } /* end */
3632};
3633
3634static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003635 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3636 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3637 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3638
Takashi Iwaid6815182006-03-23 16:06:23 +01003639 /* set capture source to mic-in */
3640 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3641 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3642 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003644 /* speaker-out */
3645 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3646 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3647 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003648 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3649 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3650 /* mic-in to input */
3651 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3652 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3653 /* built-in mic */
3654 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3655 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3656 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003657 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003658 { }
3659};
3660
3661/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003662static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003663{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003664 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003665
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003666 spec->autocfg.hp_pins[0] = 0x1b;
3667 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003668}
3669
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003670static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3671 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3672 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3673 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3674 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3675 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3676 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3677 { } /* end */
3678};
3679
3680static struct hda_input_mux alc880_medion_rim_capture_source = {
3681 .num_items = 2,
3682 .items = {
3683 { "Mic", 0x0 },
3684 { "Internal Mic", 0x1 },
3685 },
3686};
3687
3688static struct hda_verb alc880_medion_rim_init_verbs[] = {
3689 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3690
3691 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3692 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3693
3694 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3695 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3696 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3697 /* Mic2 (as headphone out) for HP output */
3698 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3699 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3700 /* Internal Speaker */
3701 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3702 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3703
3704 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3705 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3706
3707 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3708 { }
3709};
3710
3711/* toggle speaker-output according to the hp-jack state */
3712static void alc880_medion_rim_automute(struct hda_codec *codec)
3713{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003714 struct alc_spec *spec = codec->spec;
3715 alc_automute_amp(codec);
3716 /* toggle EAPD */
3717 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003718 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3719 else
3720 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3721}
3722
3723static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3724 unsigned int res)
3725{
3726 /* Looks like the unsol event is incompatible with the standard
3727 * definition. 4bit tag is placed at 28 bit!
3728 */
3729 if ((res >> 28) == ALC880_HP_EVENT)
3730 alc880_medion_rim_automute(codec);
3731}
3732
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003733static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003734{
3735 struct alc_spec *spec = codec->spec;
3736
3737 spec->autocfg.hp_pins[0] = 0x14;
3738 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003739}
3740
Takashi Iwaicb53c622007-08-10 17:21:45 +02003741#ifdef CONFIG_SND_HDA_POWER_SAVE
3742static struct hda_amp_list alc880_loopbacks[] = {
3743 { 0x0b, HDA_INPUT, 0 },
3744 { 0x0b, HDA_INPUT, 1 },
3745 { 0x0b, HDA_INPUT, 2 },
3746 { 0x0b, HDA_INPUT, 3 },
3747 { 0x0b, HDA_INPUT, 4 },
3748 { } /* end */
3749};
3750
3751static struct hda_amp_list alc880_lg_loopbacks[] = {
3752 { 0x0b, HDA_INPUT, 1 },
3753 { 0x0b, HDA_INPUT, 6 },
3754 { 0x0b, HDA_INPUT, 7 },
3755 { } /* end */
3756};
3757#endif
3758
Takashi Iwaid6815182006-03-23 16:06:23 +01003759/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003760 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003761 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003762
Linus Torvalds1da177e2005-04-16 15:20:36 -07003763static int alc_init(struct hda_codec *codec)
3764{
3765 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003766 unsigned int i;
3767
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003768 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003769 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003770
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003771 for (i = 0; i < spec->num_init_verbs; i++)
3772 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003773
3774 if (spec->init_hook)
3775 spec->init_hook(codec);
3776
Takashi Iwai9e5341b2010-09-21 09:57:06 +02003777 hda_call_check_power_status(codec, 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003778 return 0;
3779}
3780
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003781static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3782{
3783 struct alc_spec *spec = codec->spec;
3784
3785 if (spec->unsol_event)
3786 spec->unsol_event(codec, res);
3787}
3788
Takashi Iwaicb53c622007-08-10 17:21:45 +02003789#ifdef CONFIG_SND_HDA_POWER_SAVE
3790static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3791{
3792 struct alc_spec *spec = codec->spec;
3793 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3794}
3795#endif
3796
Linus Torvalds1da177e2005-04-16 15:20:36 -07003797/*
3798 * Analog playback callbacks
3799 */
3800static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3801 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003802 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003803{
3804 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003805 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3806 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003807}
3808
3809static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3810 struct hda_codec *codec,
3811 unsigned int stream_tag,
3812 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003813 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003814{
3815 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003816 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3817 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003818}
3819
3820static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3821 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003822 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003823{
3824 struct alc_spec *spec = codec->spec;
3825 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3826}
3827
3828/*
3829 * Digital out
3830 */
3831static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3832 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003833 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003834{
3835 struct alc_spec *spec = codec->spec;
3836 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3837}
3838
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003839static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3840 struct hda_codec *codec,
3841 unsigned int stream_tag,
3842 unsigned int format,
3843 struct snd_pcm_substream *substream)
3844{
3845 struct alc_spec *spec = codec->spec;
3846 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3847 stream_tag, format, substream);
3848}
3849
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003850static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3851 struct hda_codec *codec,
3852 struct snd_pcm_substream *substream)
3853{
3854 struct alc_spec *spec = codec->spec;
3855 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3856}
3857
Linus Torvalds1da177e2005-04-16 15:20:36 -07003858static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3859 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003860 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003861{
3862 struct alc_spec *spec = codec->spec;
3863 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3864}
3865
3866/*
3867 * Analog capture
3868 */
Takashi Iwai63300792008-01-24 15:31:36 +01003869static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003870 struct hda_codec *codec,
3871 unsigned int stream_tag,
3872 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003873 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003874{
3875 struct alc_spec *spec = codec->spec;
3876
Takashi Iwai63300792008-01-24 15:31:36 +01003877 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003878 stream_tag, 0, format);
3879 return 0;
3880}
3881
Takashi Iwai63300792008-01-24 15:31:36 +01003882static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003883 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003884 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003885{
3886 struct alc_spec *spec = codec->spec;
3887
Takashi Iwai888afa12008-03-18 09:57:50 +01003888 snd_hda_codec_cleanup_stream(codec,
3889 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003890 return 0;
3891}
3892
Takashi Iwai840b64c2010-07-13 22:49:01 +02003893/* analog capture with dynamic dual-adc changes */
3894static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3895 struct hda_codec *codec,
3896 unsigned int stream_tag,
3897 unsigned int format,
3898 struct snd_pcm_substream *substream)
3899{
3900 struct alc_spec *spec = codec->spec;
3901 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3902 spec->cur_adc_stream_tag = stream_tag;
3903 spec->cur_adc_format = format;
3904 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3905 return 0;
3906}
3907
3908static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3909 struct hda_codec *codec,
3910 struct snd_pcm_substream *substream)
3911{
3912 struct alc_spec *spec = codec->spec;
3913 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
3914 spec->cur_adc = 0;
3915 return 0;
3916}
3917
3918static struct hda_pcm_stream dualmic_pcm_analog_capture = {
3919 .substreams = 1,
3920 .channels_min = 2,
3921 .channels_max = 2,
3922 .nid = 0, /* fill later */
3923 .ops = {
3924 .prepare = dualmic_capture_pcm_prepare,
3925 .cleanup = dualmic_capture_pcm_cleanup
3926 },
3927};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003928
3929/*
3930 */
3931static struct hda_pcm_stream alc880_pcm_analog_playback = {
3932 .substreams = 1,
3933 .channels_min = 2,
3934 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003935 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003936 .ops = {
3937 .open = alc880_playback_pcm_open,
3938 .prepare = alc880_playback_pcm_prepare,
3939 .cleanup = alc880_playback_pcm_cleanup
3940 },
3941};
3942
3943static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003944 .substreams = 1,
3945 .channels_min = 2,
3946 .channels_max = 2,
3947 /* NID is set in alc_build_pcms */
3948};
3949
3950static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3951 .substreams = 1,
3952 .channels_min = 2,
3953 .channels_max = 2,
3954 /* NID is set in alc_build_pcms */
3955};
3956
3957static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3958 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003959 .channels_min = 2,
3960 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003961 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003962 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003963 .prepare = alc880_alt_capture_pcm_prepare,
3964 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003965 },
3966};
3967
3968static struct hda_pcm_stream alc880_pcm_digital_playback = {
3969 .substreams = 1,
3970 .channels_min = 2,
3971 .channels_max = 2,
3972 /* NID is set in alc_build_pcms */
3973 .ops = {
3974 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003975 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003976 .prepare = alc880_dig_playback_pcm_prepare,
3977 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003978 },
3979};
3980
3981static struct hda_pcm_stream alc880_pcm_digital_capture = {
3982 .substreams = 1,
3983 .channels_min = 2,
3984 .channels_max = 2,
3985 /* NID is set in alc_build_pcms */
3986};
3987
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003988/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003989static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003990 .substreams = 0,
3991 .channels_min = 0,
3992 .channels_max = 0,
3993};
3994
Linus Torvalds1da177e2005-04-16 15:20:36 -07003995static int alc_build_pcms(struct hda_codec *codec)
3996{
3997 struct alc_spec *spec = codec->spec;
3998 struct hda_pcm *info = spec->pcm_rec;
3999 int i;
4000
4001 codec->num_pcms = 1;
4002 codec->pcm_info = info;
4003
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004004 if (spec->no_analog)
4005 goto skip_analog;
4006
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004007 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
4008 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004009 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01004010
Takashi Iwai4a471b72005-12-07 13:56:29 +01004011 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004012 if (snd_BUG_ON(!spec->multiout.dac_nids))
4013 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004014 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
4015 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
4016 }
4017 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004018 if (snd_BUG_ON(!spec->adc_nids))
4019 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004020 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
4021 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
4022 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004023
Takashi Iwai4a471b72005-12-07 13:56:29 +01004024 if (spec->channel_mode) {
4025 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
4026 for (i = 0; i < spec->num_channel_mode; i++) {
4027 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
4028 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
4029 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004030 }
4031 }
4032
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004033 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02004034 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004035 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004036 snprintf(spec->stream_name_digital,
4037 sizeof(spec->stream_name_digital),
4038 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02004039 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08004040 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004041 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004042 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004043 if (spec->dig_out_type)
4044 info->pcm_type = spec->dig_out_type;
4045 else
4046 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004047 if (spec->multiout.dig_out_nid &&
4048 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004049 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4050 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4051 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004052 if (spec->dig_in_nid &&
4053 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004054 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4055 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4056 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004057 /* FIXME: do we need this for all Realtek codec models? */
4058 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004059 }
4060
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004061 if (spec->no_analog)
4062 return 0;
4063
Takashi Iwaie08a0072006-09-07 17:52:14 +02004064 /* If the use of more than one ADC is requested for the current
4065 * model, configure a second analog capture-only PCM.
4066 */
4067 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004068 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4069 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004070 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004071 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004072 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004073 if (spec->alt_dac_nid) {
4074 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4075 *spec->stream_analog_alt_playback;
4076 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4077 spec->alt_dac_nid;
4078 } else {
4079 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4080 alc_pcm_null_stream;
4081 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4082 }
4083 if (spec->num_adc_nids > 1) {
4084 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4085 *spec->stream_analog_alt_capture;
4086 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4087 spec->adc_nids[1];
4088 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4089 spec->num_adc_nids - 1;
4090 } else {
4091 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4092 alc_pcm_null_stream;
4093 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004094 }
4095 }
4096
Linus Torvalds1da177e2005-04-16 15:20:36 -07004097 return 0;
4098}
4099
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004100static inline void alc_shutup(struct hda_codec *codec)
4101{
4102 snd_hda_shutup_pins(codec);
4103}
4104
Takashi Iwai603c4012008-07-30 15:01:44 +02004105static void alc_free_kctls(struct hda_codec *codec)
4106{
4107 struct alc_spec *spec = codec->spec;
4108
4109 if (spec->kctls.list) {
4110 struct snd_kcontrol_new *kctl = spec->kctls.list;
4111 int i;
4112 for (i = 0; i < spec->kctls.used; i++)
4113 kfree(kctl[i].name);
4114 }
4115 snd_array_free(&spec->kctls);
4116}
4117
Linus Torvalds1da177e2005-04-16 15:20:36 -07004118static void alc_free(struct hda_codec *codec)
4119{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004120 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004121
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004122 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004123 return;
4124
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004125 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004126 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004127 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004128 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004129}
4130
Hector Martinf5de24b2009-12-20 22:51:31 +01004131#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004132static void alc_power_eapd(struct hda_codec *codec)
4133{
4134 /* We currently only handle front, HP */
4135 switch (codec->vendor_id) {
4136 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004137 set_eapd(codec, 0x0f, 0);
4138 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004139 break;
4140 case 0x10ec0262:
4141 case 0x10ec0267:
4142 case 0x10ec0268:
4143 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004144 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05004145 case 0x10ec0272:
4146 case 0x10ec0660:
4147 case 0x10ec0662:
4148 case 0x10ec0663:
4149 case 0x10ec0862:
4150 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004151 set_eapd(codec, 0x14, 0);
4152 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004153 break;
4154 }
4155}
4156
Hector Martinf5de24b2009-12-20 22:51:31 +01004157static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4158{
4159 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004160 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004161 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004162 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004163 return 0;
4164}
4165#endif
4166
Takashi Iwaie044c392008-10-27 16:56:24 +01004167#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004168static int alc_resume(struct hda_codec *codec)
4169{
Takashi Iwaie044c392008-10-27 16:56:24 +01004170 codec->patch_ops.init(codec);
4171 snd_hda_codec_resume_amp(codec);
4172 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004173 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +01004174 return 0;
4175}
Takashi Iwaie044c392008-10-27 16:56:24 +01004176#endif
4177
Linus Torvalds1da177e2005-04-16 15:20:36 -07004178/*
4179 */
4180static struct hda_codec_ops alc_patch_ops = {
4181 .build_controls = alc_build_controls,
4182 .build_pcms = alc_build_pcms,
4183 .init = alc_init,
4184 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004185 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004186#ifdef SND_HDA_NEEDS_RESUME
4187 .resume = alc_resume,
4188#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004189#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004190 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004191 .check_power_status = alc_check_power_status,
4192#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004193 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004194};
4195
Kailang Yangc027ddc2010-03-19 11:33:06 +01004196/* replace the codec chip_name with the given string */
4197static int alc_codec_rename(struct hda_codec *codec, const char *name)
4198{
4199 kfree(codec->chip_name);
4200 codec->chip_name = kstrdup(name, GFP_KERNEL);
4201 if (!codec->chip_name) {
4202 alc_free(codec);
4203 return -ENOMEM;
4204 }
4205 return 0;
4206}
4207
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004208/*
4209 * Test configuration for debugging
4210 *
4211 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4212 * enum controls.
4213 */
4214#ifdef CONFIG_SND_DEBUG
4215static hda_nid_t alc880_test_dac_nids[4] = {
4216 0x02, 0x03, 0x04, 0x05
4217};
4218
4219static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004220 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004221 .items = {
4222 { "In-1", 0x0 },
4223 { "In-2", 0x1 },
4224 { "In-3", 0x2 },
4225 { "In-4", 0x3 },
4226 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004227 { "Front", 0x5 },
4228 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004229 },
4230};
4231
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004232static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004233 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004234 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004235 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004236 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004237};
4238
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004239static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4240 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004241{
4242 static char *texts[] = {
4243 "N/A", "Line Out", "HP Out",
4244 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4245 };
4246 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4247 uinfo->count = 1;
4248 uinfo->value.enumerated.items = 8;
4249 if (uinfo->value.enumerated.item >= 8)
4250 uinfo->value.enumerated.item = 7;
4251 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4252 return 0;
4253}
4254
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004255static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4256 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004257{
4258 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4259 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4260 unsigned int pin_ctl, item = 0;
4261
4262 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4263 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4264 if (pin_ctl & AC_PINCTL_OUT_EN) {
4265 if (pin_ctl & AC_PINCTL_HP_EN)
4266 item = 2;
4267 else
4268 item = 1;
4269 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4270 switch (pin_ctl & AC_PINCTL_VREFEN) {
4271 case AC_PINCTL_VREF_HIZ: item = 3; break;
4272 case AC_PINCTL_VREF_50: item = 4; break;
4273 case AC_PINCTL_VREF_GRD: item = 5; break;
4274 case AC_PINCTL_VREF_80: item = 6; break;
4275 case AC_PINCTL_VREF_100: item = 7; break;
4276 }
4277 }
4278 ucontrol->value.enumerated.item[0] = item;
4279 return 0;
4280}
4281
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004282static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4283 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004284{
4285 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4286 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4287 static unsigned int ctls[] = {
4288 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4289 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4290 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4291 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4292 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4293 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4294 };
4295 unsigned int old_ctl, new_ctl;
4296
4297 old_ctl = snd_hda_codec_read(codec, nid, 0,
4298 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4299 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4300 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004301 int val;
4302 snd_hda_codec_write_cache(codec, nid, 0,
4303 AC_VERB_SET_PIN_WIDGET_CONTROL,
4304 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004305 val = ucontrol->value.enumerated.item[0] >= 3 ?
4306 HDA_AMP_MUTE : 0;
4307 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4308 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004309 return 1;
4310 }
4311 return 0;
4312}
4313
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004314static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4315 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004316{
4317 static char *texts[] = {
4318 "Front", "Surround", "CLFE", "Side"
4319 };
4320 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4321 uinfo->count = 1;
4322 uinfo->value.enumerated.items = 4;
4323 if (uinfo->value.enumerated.item >= 4)
4324 uinfo->value.enumerated.item = 3;
4325 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4326 return 0;
4327}
4328
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004329static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4330 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004331{
4332 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4333 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4334 unsigned int sel;
4335
4336 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4337 ucontrol->value.enumerated.item[0] = sel & 3;
4338 return 0;
4339}
4340
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004341static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4342 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004343{
4344 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4345 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4346 unsigned int sel;
4347
4348 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4349 if (ucontrol->value.enumerated.item[0] != sel) {
4350 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004351 snd_hda_codec_write_cache(codec, nid, 0,
4352 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004353 return 1;
4354 }
4355 return 0;
4356}
4357
4358#define PIN_CTL_TEST(xname,nid) { \
4359 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4360 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004361 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004362 .info = alc_test_pin_ctl_info, \
4363 .get = alc_test_pin_ctl_get, \
4364 .put = alc_test_pin_ctl_put, \
4365 .private_value = nid \
4366 }
4367
4368#define PIN_SRC_TEST(xname,nid) { \
4369 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4370 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004371 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004372 .info = alc_test_pin_src_info, \
4373 .get = alc_test_pin_src_get, \
4374 .put = alc_test_pin_src_put, \
4375 .private_value = nid \
4376 }
4377
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004378static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004379 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4380 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4381 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4382 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004383 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4384 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4385 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4386 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004387 PIN_CTL_TEST("Front Pin Mode", 0x14),
4388 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4389 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4390 PIN_CTL_TEST("Side Pin Mode", 0x17),
4391 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4392 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4393 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4394 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4395 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4396 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4397 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4398 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4399 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4400 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4401 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4402 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4403 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4404 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4405 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4406 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4407 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4408 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004409 {
4410 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4411 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004412 .info = alc_ch_mode_info,
4413 .get = alc_ch_mode_get,
4414 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004415 },
4416 { } /* end */
4417};
4418
4419static struct hda_verb alc880_test_init_verbs[] = {
4420 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004421 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4422 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4423 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4424 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4425 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4426 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4427 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4428 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004429 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004430 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4431 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4432 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4433 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004434 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004435 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4436 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4437 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4438 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004439 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004440 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4441 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4442 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4443 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004444 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004445 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4446 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004447 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4448 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4449 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004450 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004451 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4452 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4453 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4454 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004455 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004456 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004457 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004458 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004459 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004460 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004461 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004462 /* Analog input/passthru */
4463 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4464 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4465 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4466 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4467 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004468 { }
4469};
4470#endif
4471
Linus Torvalds1da177e2005-04-16 15:20:36 -07004472/*
4473 */
4474
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004475static const char *alc880_models[ALC880_MODEL_LAST] = {
4476 [ALC880_3ST] = "3stack",
4477 [ALC880_TCL_S700] = "tcl",
4478 [ALC880_3ST_DIG] = "3stack-digout",
4479 [ALC880_CLEVO] = "clevo",
4480 [ALC880_5ST] = "5stack",
4481 [ALC880_5ST_DIG] = "5stack-digout",
4482 [ALC880_W810] = "w810",
4483 [ALC880_Z71V] = "z71v",
4484 [ALC880_6ST] = "6stack",
4485 [ALC880_6ST_DIG] = "6stack-digout",
4486 [ALC880_ASUS] = "asus",
4487 [ALC880_ASUS_W1V] = "asus-w1v",
4488 [ALC880_ASUS_DIG] = "asus-dig",
4489 [ALC880_ASUS_DIG2] = "asus-dig2",
4490 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004491 [ALC880_UNIWILL_P53] = "uniwill-p53",
4492 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004493 [ALC880_F1734] = "F1734",
4494 [ALC880_LG] = "lg",
4495 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004496 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004497#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004498 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004499#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004500 [ALC880_AUTO] = "auto",
4501};
4502
4503static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004504 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004505 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4506 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4507 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4508 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4509 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4510 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4511 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4512 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004513 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4514 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004515 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4516 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4517 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4518 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4519 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4520 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4521 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4522 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4523 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4524 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004525 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004526 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4527 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4528 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004529 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004530 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004531 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4532 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004533 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4534 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004535 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4536 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4537 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4538 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004539 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4540 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004541 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004542 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004543 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004544 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004545 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4546 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004547 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004548 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004549 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004550 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004551 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004552 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004553 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004554 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004555 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004556 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4557 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004558 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004559 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4560 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4561 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4562 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004563 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4564 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004565 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004566 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004567 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4568 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004569 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4570 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4571 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004572 /* default Intel */
4573 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004574 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4575 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004576 {}
4577};
4578
Takashi Iwai16ded522005-06-10 19:58:24 +02004579/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004580 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004581 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004582static struct alc_config_preset alc880_presets[] = {
4583 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004584 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004585 .init_verbs = { alc880_volume_init_verbs,
4586 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004587 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004588 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004589 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4590 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004591 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004592 .input_mux = &alc880_capture_source,
4593 },
4594 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004595 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004596 .init_verbs = { alc880_volume_init_verbs,
4597 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004598 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004599 .dac_nids = alc880_dac_nids,
4600 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004601 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4602 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004603 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004604 .input_mux = &alc880_capture_source,
4605 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004606 [ALC880_TCL_S700] = {
4607 .mixers = { alc880_tcl_s700_mixer },
4608 .init_verbs = { alc880_volume_init_verbs,
4609 alc880_pin_tcl_S700_init_verbs,
4610 alc880_gpio2_init_verbs },
4611 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4612 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004613 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4614 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004615 .hp_nid = 0x03,
4616 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4617 .channel_mode = alc880_2_jack_modes,
4618 .input_mux = &alc880_capture_source,
4619 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004620 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004621 .mixers = { alc880_three_stack_mixer,
4622 alc880_five_stack_mixer},
4623 .init_verbs = { alc880_volume_init_verbs,
4624 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004625 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4626 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004627 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4628 .channel_mode = alc880_fivestack_modes,
4629 .input_mux = &alc880_capture_source,
4630 },
4631 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004632 .mixers = { alc880_three_stack_mixer,
4633 alc880_five_stack_mixer },
4634 .init_verbs = { alc880_volume_init_verbs,
4635 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004636 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4637 .dac_nids = alc880_dac_nids,
4638 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004639 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4640 .channel_mode = alc880_fivestack_modes,
4641 .input_mux = &alc880_capture_source,
4642 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004643 [ALC880_6ST] = {
4644 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004645 .init_verbs = { alc880_volume_init_verbs,
4646 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004647 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4648 .dac_nids = alc880_6st_dac_nids,
4649 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4650 .channel_mode = alc880_sixstack_modes,
4651 .input_mux = &alc880_6stack_capture_source,
4652 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004653 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004654 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004655 .init_verbs = { alc880_volume_init_verbs,
4656 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004657 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4658 .dac_nids = alc880_6st_dac_nids,
4659 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004660 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4661 .channel_mode = alc880_sixstack_modes,
4662 .input_mux = &alc880_6stack_capture_source,
4663 },
4664 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004665 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004666 .init_verbs = { alc880_volume_init_verbs,
4667 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004668 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004669 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4670 .dac_nids = alc880_w810_dac_nids,
4671 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004672 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4673 .channel_mode = alc880_w810_modes,
4674 .input_mux = &alc880_capture_source,
4675 },
4676 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004677 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004678 .init_verbs = { alc880_volume_init_verbs,
4679 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004680 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4681 .dac_nids = alc880_z71v_dac_nids,
4682 .dig_out_nid = ALC880_DIGOUT_NID,
4683 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004684 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4685 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004686 .input_mux = &alc880_capture_source,
4687 },
4688 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004689 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004690 .init_verbs = { alc880_volume_init_verbs,
4691 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004692 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4693 .dac_nids = alc880_f1734_dac_nids,
4694 .hp_nid = 0x02,
4695 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4696 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004697 .input_mux = &alc880_f1734_capture_source,
4698 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004699 .setup = alc880_uniwill_p53_setup,
4700 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004701 },
4702 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004703 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004704 .init_verbs = { alc880_volume_init_verbs,
4705 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004706 alc880_gpio1_init_verbs },
4707 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4708 .dac_nids = alc880_asus_dac_nids,
4709 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4710 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004711 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004712 .input_mux = &alc880_capture_source,
4713 },
4714 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004715 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004716 .init_verbs = { alc880_volume_init_verbs,
4717 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004718 alc880_gpio1_init_verbs },
4719 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4720 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004721 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004722 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4723 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004724 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004725 .input_mux = &alc880_capture_source,
4726 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004727 [ALC880_ASUS_DIG2] = {
4728 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004729 .init_verbs = { alc880_volume_init_verbs,
4730 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004731 alc880_gpio2_init_verbs }, /* use GPIO2 */
4732 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4733 .dac_nids = alc880_asus_dac_nids,
4734 .dig_out_nid = ALC880_DIGOUT_NID,
4735 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4736 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004737 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004738 .input_mux = &alc880_capture_source,
4739 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004740 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004741 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004742 .init_verbs = { alc880_volume_init_verbs,
4743 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004744 alc880_gpio1_init_verbs },
4745 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4746 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004747 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004748 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4749 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004750 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004751 .input_mux = &alc880_capture_source,
4752 },
4753 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004754 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004755 .init_verbs = { alc880_volume_init_verbs,
4756 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004757 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4758 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004759 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004760 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4761 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004762 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004763 .input_mux = &alc880_capture_source,
4764 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004765 [ALC880_UNIWILL] = {
4766 .mixers = { alc880_uniwill_mixer },
4767 .init_verbs = { alc880_volume_init_verbs,
4768 alc880_uniwill_init_verbs },
4769 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4770 .dac_nids = alc880_asus_dac_nids,
4771 .dig_out_nid = ALC880_DIGOUT_NID,
4772 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4773 .channel_mode = alc880_threestack_modes,
4774 .need_dac_fix = 1,
4775 .input_mux = &alc880_capture_source,
4776 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004777 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004778 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004779 },
4780 [ALC880_UNIWILL_P53] = {
4781 .mixers = { alc880_uniwill_p53_mixer },
4782 .init_verbs = { alc880_volume_init_verbs,
4783 alc880_uniwill_p53_init_verbs },
4784 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4785 .dac_nids = alc880_asus_dac_nids,
4786 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004787 .channel_mode = alc880_threestack_modes,
4788 .input_mux = &alc880_capture_source,
4789 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004790 .setup = alc880_uniwill_p53_setup,
4791 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004792 },
4793 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004794 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004795 .init_verbs = { alc880_volume_init_verbs,
4796 alc880_uniwill_p53_init_verbs,
4797 alc880_beep_init_verbs },
4798 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4799 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004800 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004801 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4802 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004803 .input_mux = &alc880_capture_source,
4804 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004805 .setup = alc880_uniwill_p53_setup,
4806 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004807 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004808 [ALC880_CLEVO] = {
4809 .mixers = { alc880_three_stack_mixer },
4810 .init_verbs = { alc880_volume_init_verbs,
4811 alc880_pin_clevo_init_verbs },
4812 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4813 .dac_nids = alc880_dac_nids,
4814 .hp_nid = 0x03,
4815 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4816 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004817 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004818 .input_mux = &alc880_capture_source,
4819 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004820 [ALC880_LG] = {
4821 .mixers = { alc880_lg_mixer },
4822 .init_verbs = { alc880_volume_init_verbs,
4823 alc880_lg_init_verbs },
4824 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4825 .dac_nids = alc880_lg_dac_nids,
4826 .dig_out_nid = ALC880_DIGOUT_NID,
4827 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4828 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004829 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004830 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004831 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004832 .setup = alc880_lg_setup,
4833 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004834#ifdef CONFIG_SND_HDA_POWER_SAVE
4835 .loopbacks = alc880_lg_loopbacks,
4836#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004837 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004838 [ALC880_LG_LW] = {
4839 .mixers = { alc880_lg_lw_mixer },
4840 .init_verbs = { alc880_volume_init_verbs,
4841 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004842 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004843 .dac_nids = alc880_dac_nids,
4844 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004845 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4846 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004847 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004848 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004849 .setup = alc880_lg_lw_setup,
4850 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004851 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004852 [ALC880_MEDION_RIM] = {
4853 .mixers = { alc880_medion_rim_mixer },
4854 .init_verbs = { alc880_volume_init_verbs,
4855 alc880_medion_rim_init_verbs,
4856 alc_gpio2_init_verbs },
4857 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4858 .dac_nids = alc880_dac_nids,
4859 .dig_out_nid = ALC880_DIGOUT_NID,
4860 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4861 .channel_mode = alc880_2_jack_modes,
4862 .input_mux = &alc880_medion_rim_capture_source,
4863 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004864 .setup = alc880_medion_rim_setup,
4865 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004866 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004867#ifdef CONFIG_SND_DEBUG
4868 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004869 .mixers = { alc880_test_mixer },
4870 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004871 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4872 .dac_nids = alc880_test_dac_nids,
4873 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004874 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4875 .channel_mode = alc880_test_modes,
4876 .input_mux = &alc880_test_capture_source,
4877 },
4878#endif
4879};
4880
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004881/*
4882 * Automatic parse of I/O pins from the BIOS configuration
4883 */
4884
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004885enum {
4886 ALC_CTL_WIDGET_VOL,
4887 ALC_CTL_WIDGET_MUTE,
4888 ALC_CTL_BIND_MUTE,
4889};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004890static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004891 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4892 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004893 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004894};
4895
4896/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004897static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004898 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004899{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004900 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004901
Takashi Iwai603c4012008-07-30 15:01:44 +02004902 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4903 knew = snd_array_new(&spec->kctls);
4904 if (!knew)
4905 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004906 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004907 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004908 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004909 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004910 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004911 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004912 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004913 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004914 return 0;
4915}
4916
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004917static int add_control_with_pfx(struct alc_spec *spec, int type,
4918 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004919 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004920{
4921 char name[32];
4922 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004923 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004924}
4925
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004926#define add_pb_vol_ctrl(spec, type, pfx, val) \
4927 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
4928#define add_pb_sw_ctrl(spec, type, pfx, val) \
4929 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
4930#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
4931 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
4932#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
4933 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004934
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004935#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4936#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4937#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4938#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004939#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4940#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4941#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4942#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4943#define ALC880_PIN_CD_NID 0x1c
4944
4945/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004946static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4947 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004948{
4949 hda_nid_t nid;
4950 int assigned[4];
4951 int i, j;
4952
4953 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004954 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004955
4956 /* check the pins hardwired to audio widget */
4957 for (i = 0; i < cfg->line_outs; i++) {
4958 nid = cfg->line_out_pins[i];
4959 if (alc880_is_fixed_pin(nid)) {
4960 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004961 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004962 assigned[idx] = 1;
4963 }
4964 }
4965 /* left pins can be connect to any audio widget */
4966 for (i = 0; i < cfg->line_outs; i++) {
4967 nid = cfg->line_out_pins[i];
4968 if (alc880_is_fixed_pin(nid))
4969 continue;
4970 /* search for an empty channel */
4971 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004972 if (!assigned[j]) {
4973 spec->multiout.dac_nids[i] =
4974 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004975 assigned[j] = 1;
4976 break;
4977 }
4978 }
4979 }
4980 spec->multiout.num_dacs = cfg->line_outs;
4981 return 0;
4982}
4983
4984/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004985static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4986 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004987{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004988 static const char *chname[4] = {
4989 "Front", "Surround", NULL /*CLFE*/, "Side"
4990 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004991 hda_nid_t nid;
4992 int i, err;
4993
4994 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004995 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004996 continue;
4997 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4998 if (i == 2) {
4999 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005000 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5001 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005002 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
5003 HDA_OUTPUT));
5004 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005005 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005006 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5007 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005008 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
5009 HDA_OUTPUT));
5010 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005011 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005012 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5013 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005014 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
5015 HDA_INPUT));
5016 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005017 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005018 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5019 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005020 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
5021 HDA_INPUT));
5022 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005023 return err;
5024 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02005025 const char *pfx;
5026 if (cfg->line_outs == 1 &&
5027 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
5028 pfx = "Speaker";
5029 else
5030 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005031 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005032 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
5033 HDA_OUTPUT));
5034 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005035 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005036 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005037 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
5038 HDA_INPUT));
5039 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005040 return err;
5041 }
5042 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005043 return 0;
5044}
5045
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005046/* add playback controls for speaker and HP outputs */
5047static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5048 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005049{
5050 hda_nid_t nid;
5051 int err;
5052
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005053 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005054 return 0;
5055
5056 if (alc880_is_fixed_pin(pin)) {
5057 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005058 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005059 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005060 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005061 else
5062 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005063 /* control HP volume/switch on the output mixer amp */
5064 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005065 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005066 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5067 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005068 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005069 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005070 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5071 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005072 return err;
5073 } else if (alc880_is_multi_pin(pin)) {
5074 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005075 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005076 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005077 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5078 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005079 return err;
5080 }
5081 return 0;
5082}
5083
5084/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005085static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005086 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005087 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005088{
Kailang Yangdf694da2005-12-05 19:42:22 +01005089 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005090
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005091 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005092 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5093 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005094 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005095 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005096 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5097 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005098 return err;
5099 return 0;
5100}
5101
Takashi Iwai05f5f472009-08-25 13:10:18 +02005102static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005103{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005104 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5105 return (pincap & AC_PINCAP_IN) != 0;
5106}
5107
5108/* create playback/capture controls for input pins */
5109static int alc_auto_create_input_ctls(struct hda_codec *codec,
5110 const struct auto_pin_cfg *cfg,
5111 hda_nid_t mixer,
5112 hda_nid_t cap1, hda_nid_t cap2)
5113{
5114 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005115 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005116 int i, err, idx, type, type_idx = 0;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005117
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005118 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005119 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005120 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005121
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005122 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005123 if (!alc_is_input_pin(codec, pin))
5124 continue;
5125
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005126 type = cfg->inputs[i].type;
5127 if (i > 0 && type == cfg->inputs[i - 1].type)
5128 type_idx++;
5129 else
5130 type_idx = 0;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005131 label = hda_get_autocfg_input_label(codec, cfg, i);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005132 if (mixer) {
5133 idx = get_connection_index(codec, mixer, pin);
5134 if (idx >= 0) {
5135 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005136 label, type_idx,
5137 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005138 if (err < 0)
5139 return err;
5140 }
5141 }
5142
5143 if (!cap1)
5144 continue;
5145 idx = get_connection_index(codec, cap1, pin);
5146 if (idx < 0 && cap2)
5147 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005148 if (idx >= 0)
5149 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005150 }
5151 return 0;
5152}
5153
Takashi Iwai05f5f472009-08-25 13:10:18 +02005154static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5155 const struct auto_pin_cfg *cfg)
5156{
5157 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5158}
5159
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005160static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5161 unsigned int pin_type)
5162{
5163 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5164 pin_type);
5165 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005166 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5167 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005168}
5169
Kailang Yangdf694da2005-12-05 19:42:22 +01005170static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5171 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005172 int dac_idx)
5173{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005174 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005175 /* need the manual connection? */
5176 if (alc880_is_multi_pin(nid)) {
5177 struct alc_spec *spec = codec->spec;
5178 int idx = alc880_multi_pin_idx(nid);
5179 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5180 AC_VERB_SET_CONNECT_SEL,
5181 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5182 }
5183}
5184
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005185static int get_pin_type(int line_out_type)
5186{
5187 if (line_out_type == AUTO_PIN_HP_OUT)
5188 return PIN_HP;
5189 else
5190 return PIN_OUT;
5191}
5192
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005193static void alc880_auto_init_multi_out(struct hda_codec *codec)
5194{
5195 struct alc_spec *spec = codec->spec;
5196 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005197
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005198 for (i = 0; i < spec->autocfg.line_outs; i++) {
5199 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005200 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5201 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005202 }
5203}
5204
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005205static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005206{
5207 struct alc_spec *spec = codec->spec;
5208 hda_nid_t pin;
5209
Takashi Iwai82bc9552006-03-21 11:24:42 +01005210 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005211 if (pin) /* connect to front */
5212 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005213 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005214 if (pin) /* connect to front */
5215 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5216}
5217
5218static void alc880_auto_init_analog_input(struct hda_codec *codec)
5219{
5220 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005221 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005222 int i;
5223
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005224 for (i = 0; i < cfg->num_inputs; i++) {
5225 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005226 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005227 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005228 if (nid != ALC880_PIN_CD_NID &&
5229 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005230 snd_hda_codec_write(codec, nid, 0,
5231 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005232 AMP_OUT_MUTE);
5233 }
5234 }
5235}
5236
Takashi Iwai7f311a42010-04-09 17:32:23 +02005237static void alc880_auto_init_input_src(struct hda_codec *codec)
5238{
5239 struct alc_spec *spec = codec->spec;
5240 int c;
5241
5242 for (c = 0; c < spec->num_adc_nids; c++) {
5243 unsigned int mux_idx;
5244 const struct hda_input_mux *imux;
5245 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5246 imux = &spec->input_mux[mux_idx];
5247 if (!imux->num_items && mux_idx > 0)
5248 imux = &spec->input_mux[0];
5249 if (imux)
5250 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5251 AC_VERB_SET_CONNECT_SEL,
5252 imux->items[0].index);
5253 }
5254}
5255
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005256/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005257/* return 1 if successful, 0 if the proper config is not found,
5258 * or a negative error code
5259 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005260static int alc880_parse_auto_config(struct hda_codec *codec)
5261{
5262 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005263 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005264 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005265
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005266 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5267 alc880_ignore);
5268 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005269 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005270 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005271 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005272
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005273 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5274 if (err < 0)
5275 return err;
5276 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5277 if (err < 0)
5278 return err;
5279 err = alc880_auto_create_extra_out(spec,
5280 spec->autocfg.speaker_pins[0],
5281 "Speaker");
5282 if (err < 0)
5283 return err;
5284 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5285 "Headphone");
5286 if (err < 0)
5287 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005288 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005289 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005290 return err;
5291
5292 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5293
Takashi Iwai757899a2010-07-30 10:48:14 +02005294 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005295
Takashi Iwai603c4012008-07-30 15:01:44 +02005296 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005297 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005298
Takashi Iwaid88897e2008-10-31 15:01:37 +01005299 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005300
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005301 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005302 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005303
Kailang Yang6227cdc2010-02-25 08:36:52 +01005304 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005305
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005306 return 1;
5307}
5308
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005309/* additional initialization for auto-configuration model */
5310static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005311{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005312 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005313 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005314 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005315 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005316 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005317 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005318 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005319 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005320}
5321
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005322/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5323 * one of two digital mic pins, e.g. on ALC272
5324 */
5325static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005326{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005327 struct alc_spec *spec = codec->spec;
5328 int i;
5329
5330 for (i = 0; i < spec->num_adc_nids; i++) {
5331 hda_nid_t cap = spec->capsrc_nids ?
5332 spec->capsrc_nids[i] : spec->adc_nids[i];
5333 int iidx, eidx;
5334
5335 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5336 if (iidx < 0)
5337 continue;
5338 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5339 if (eidx < 0)
5340 continue;
5341 spec->int_mic.mux_idx = iidx;
5342 spec->ext_mic.mux_idx = eidx;
5343 if (spec->capsrc_nids)
5344 spec->capsrc_nids += i;
5345 spec->adc_nids += i;
5346 spec->num_adc_nids = 1;
5347 return;
5348 }
5349 snd_printd(KERN_INFO "hda_codec: %s: "
5350 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5351 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5352 spec->auto_mic = 0; /* disable auto-mic to be sure */
5353}
5354
Takashi Iwai748cce42010-08-04 07:37:39 +02005355/* select or unmute the given capsrc route */
5356static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5357 int idx)
5358{
5359 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5360 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5361 HDA_AMP_MUTE, 0);
5362 } else {
5363 snd_hda_codec_write_cache(codec, cap, 0,
5364 AC_VERB_SET_CONNECT_SEL, idx);
5365 }
5366}
5367
Takashi Iwai840b64c2010-07-13 22:49:01 +02005368/* set the default connection to that pin */
5369static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5370{
5371 struct alc_spec *spec = codec->spec;
5372 int i;
5373
5374 for (i = 0; i < spec->num_adc_nids; i++) {
5375 hda_nid_t cap = spec->capsrc_nids ?
5376 spec->capsrc_nids[i] : spec->adc_nids[i];
5377 int idx;
5378
5379 idx = get_connection_index(codec, cap, pin);
5380 if (idx < 0)
5381 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005382 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005383 return i; /* return the found index */
5384 }
5385 return -1; /* not found */
5386}
5387
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005388/* choose the ADC/MUX containing the input pin and initialize the setup */
5389static void fixup_single_adc(struct hda_codec *codec)
5390{
5391 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005392 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005393 int i;
5394
5395 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005396 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005397 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005398 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005399 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005400 /* use only this ADC */
5401 if (spec->capsrc_nids)
5402 spec->capsrc_nids += i;
5403 spec->adc_nids += i;
5404 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005405 }
5406}
5407
Takashi Iwai840b64c2010-07-13 22:49:01 +02005408/* initialize dual adcs */
5409static void fixup_dual_adc_switch(struct hda_codec *codec)
5410{
5411 struct alc_spec *spec = codec->spec;
5412 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5413 init_capsrc_for_pin(codec, spec->int_mic.pin);
5414}
5415
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005416static void set_capture_mixer(struct hda_codec *codec)
5417{
5418 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005419 static struct snd_kcontrol_new *caps[2][3] = {
5420 { alc_capture_mixer_nosrc1,
5421 alc_capture_mixer_nosrc2,
5422 alc_capture_mixer_nosrc3 },
5423 { alc_capture_mixer1,
5424 alc_capture_mixer2,
5425 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005426 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005427 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005428 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005429 int num_adcs = spec->num_adc_nids;
5430 if (spec->dual_adc_switch)
5431 fixup_dual_adc_switch(codec);
5432 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005433 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005434 else if (spec->input_mux) {
5435 if (spec->input_mux->num_items > 1)
5436 mux = 1;
5437 else if (spec->input_mux->num_items == 1)
5438 fixup_single_adc(codec);
5439 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005440 if (spec->dual_adc_switch)
5441 num_adcs = 1;
5442 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005443 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005444}
5445
Takashi Iwai66946352010-03-29 17:21:45 +02005446/* fill adc_nids (and capsrc_nids) containing all active input pins */
5447static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5448 int num_nids)
5449{
5450 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005451 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005452 int n;
5453 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5454
5455 for (n = 0; n < num_nids; n++) {
5456 hda_nid_t adc, cap;
5457 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5458 int nconns, i, j;
5459
5460 adc = nids[n];
5461 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5462 continue;
5463 cap = adc;
5464 nconns = snd_hda_get_connections(codec, cap, conn,
5465 ARRAY_SIZE(conn));
5466 if (nconns == 1) {
5467 cap = conn[0];
5468 nconns = snd_hda_get_connections(codec, cap, conn,
5469 ARRAY_SIZE(conn));
5470 }
5471 if (nconns <= 0)
5472 continue;
5473 if (!fallback_adc) {
5474 fallback_adc = adc;
5475 fallback_cap = cap;
5476 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005477 for (i = 0; i < cfg->num_inputs; i++) {
5478 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005479 for (j = 0; j < nconns; j++) {
5480 if (conn[j] == nid)
5481 break;
5482 }
5483 if (j >= nconns)
5484 break;
5485 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005486 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005487 int num_adcs = spec->num_adc_nids;
5488 spec->private_adc_nids[num_adcs] = adc;
5489 spec->private_capsrc_nids[num_adcs] = cap;
5490 spec->num_adc_nids++;
5491 spec->adc_nids = spec->private_adc_nids;
5492 if (adc != cap)
5493 spec->capsrc_nids = spec->private_capsrc_nids;
5494 }
5495 }
5496 if (!spec->num_adc_nids) {
5497 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005498 " using fallback 0x%x\n",
5499 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005500 spec->private_adc_nids[0] = fallback_adc;
5501 spec->adc_nids = spec->private_adc_nids;
5502 if (fallback_adc != fallback_cap) {
5503 spec->private_capsrc_nids[0] = fallback_cap;
5504 spec->capsrc_nids = spec->private_adc_nids;
5505 }
5506 }
5507}
5508
Takashi Iwai67d634c2009-11-16 15:35:59 +01005509#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005510#define set_beep_amp(spec, nid, idx, dir) \
5511 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005512
5513static struct snd_pci_quirk beep_white_list[] = {
5514 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005515 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005516 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005517 {}
5518};
5519
5520static inline int has_cdefine_beep(struct hda_codec *codec)
5521{
5522 struct alc_spec *spec = codec->spec;
5523 const struct snd_pci_quirk *q;
5524 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5525 if (q)
5526 return q->value;
5527 return spec->cdefine.enable_pcbeep;
5528}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005529#else
5530#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005531#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005532#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005533
5534/*
5535 * OK, here we have finally the patch for ALC880
5536 */
5537
Linus Torvalds1da177e2005-04-16 15:20:36 -07005538static int patch_alc880(struct hda_codec *codec)
5539{
5540 struct alc_spec *spec;
5541 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005542 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005543
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005544 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005545 if (spec == NULL)
5546 return -ENOMEM;
5547
5548 codec->spec = spec;
5549
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005550 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5551 alc880_models,
5552 alc880_cfg_tbl);
5553 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005554 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5555 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005556 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005557 }
5558
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005559 if (board_config == ALC880_AUTO) {
5560 /* automatic parse from the BIOS config */
5561 err = alc880_parse_auto_config(codec);
5562 if (err < 0) {
5563 alc_free(codec);
5564 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005565 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005566 printk(KERN_INFO
5567 "hda_codec: Cannot set up configuration "
5568 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005569 board_config = ALC880_3ST;
5570 }
5571 }
5572
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005573 err = snd_hda_attach_beep_device(codec, 0x1);
5574 if (err < 0) {
5575 alc_free(codec);
5576 return err;
5577 }
5578
Kailang Yangdf694da2005-12-05 19:42:22 +01005579 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005580 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005581
Linus Torvalds1da177e2005-04-16 15:20:36 -07005582 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5583 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005584 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005585
Linus Torvalds1da177e2005-04-16 15:20:36 -07005586 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5587 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5588
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005589 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005590 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005591 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005592 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005593 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005594 if (wcap != AC_WID_AUD_IN) {
5595 spec->adc_nids = alc880_adc_nids_alt;
5596 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005597 } else {
5598 spec->adc_nids = alc880_adc_nids;
5599 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005600 }
5601 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005602 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005603 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005604
Takashi Iwai2134ea42008-01-10 16:53:55 +01005605 spec->vmaster_nid = 0x0c;
5606
Linus Torvalds1da177e2005-04-16 15:20:36 -07005607 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005608 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005609 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005610#ifdef CONFIG_SND_HDA_POWER_SAVE
5611 if (!spec->loopback.amplist)
5612 spec->loopback.amplist = alc880_loopbacks;
5613#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005614
5615 return 0;
5616}
5617
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005618
Linus Torvalds1da177e2005-04-16 15:20:36 -07005619/*
5620 * ALC260 support
5621 */
5622
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005623static hda_nid_t alc260_dac_nids[1] = {
5624 /* front */
5625 0x02,
5626};
5627
5628static hda_nid_t alc260_adc_nids[1] = {
5629 /* ADC0 */
5630 0x04,
5631};
5632
Kailang Yangdf694da2005-12-05 19:42:22 +01005633static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005634 /* ADC1 */
5635 0x05,
5636};
5637
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005638/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5639 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5640 */
5641static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005642 /* ADC0, ADC1 */
5643 0x04, 0x05
5644};
5645
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005646#define ALC260_DIGOUT_NID 0x03
5647#define ALC260_DIGIN_NID 0x06
5648
5649static struct hda_input_mux alc260_capture_source = {
5650 .num_items = 4,
5651 .items = {
5652 { "Mic", 0x0 },
5653 { "Front Mic", 0x1 },
5654 { "Line", 0x2 },
5655 { "CD", 0x4 },
5656 },
5657};
5658
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005659/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005660 * headphone jack and the internal CD lines since these are the only pins at
5661 * which audio can appear. For flexibility, also allow the option of
5662 * recording the mixer output on the second ADC (ADC0 doesn't have a
5663 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005664 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005665static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5666 {
5667 .num_items = 3,
5668 .items = {
5669 { "Mic/Line", 0x0 },
5670 { "CD", 0x4 },
5671 { "Headphone", 0x2 },
5672 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005673 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005674 {
5675 .num_items = 4,
5676 .items = {
5677 { "Mic/Line", 0x0 },
5678 { "CD", 0x4 },
5679 { "Headphone", 0x2 },
5680 { "Mixer", 0x5 },
5681 },
5682 },
5683
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005684};
5685
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005686/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5687 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005688 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005689static struct hda_input_mux alc260_acer_capture_sources[2] = {
5690 {
5691 .num_items = 4,
5692 .items = {
5693 { "Mic", 0x0 },
5694 { "Line", 0x2 },
5695 { "CD", 0x4 },
5696 { "Headphone", 0x5 },
5697 },
5698 },
5699 {
5700 .num_items = 5,
5701 .items = {
5702 { "Mic", 0x0 },
5703 { "Line", 0x2 },
5704 { "CD", 0x4 },
5705 { "Headphone", 0x6 },
5706 { "Mixer", 0x5 },
5707 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005708 },
5709};
Michael Schwingencc959482009-02-22 18:58:45 +01005710
5711/* Maxdata Favorit 100XS */
5712static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5713 {
5714 .num_items = 2,
5715 .items = {
5716 { "Line/Mic", 0x0 },
5717 { "CD", 0x4 },
5718 },
5719 },
5720 {
5721 .num_items = 3,
5722 .items = {
5723 { "Line/Mic", 0x0 },
5724 { "CD", 0x4 },
5725 { "Mixer", 0x5 },
5726 },
5727 },
5728};
5729
Linus Torvalds1da177e2005-04-16 15:20:36 -07005730/*
5731 * This is just place-holder, so there's something for alc_build_pcms to look
5732 * at when it calculates the maximum number of channels. ALC260 has no mixer
5733 * element which allows changing the channel mode, so the verb list is
5734 * never used.
5735 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005736static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005737 { 2, NULL },
5738};
5739
Kailang Yangdf694da2005-12-05 19:42:22 +01005740
5741/* Mixer combinations
5742 *
5743 * basic: base_output + input + pc_beep + capture
5744 * HP: base_output + input + capture_alt
5745 * HP_3013: hp_3013 + input + capture
5746 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005747 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005748 */
5749
5750static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005751 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005752 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005753 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5754 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5755 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5756 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5757 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005758};
Kailang Yangdf694da2005-12-05 19:42:22 +01005759
5760static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005761 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5762 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5763 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5764 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5765 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5766 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5767 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5768 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005769 { } /* end */
5770};
5771
Takashi Iwaibec15c32008-01-28 18:16:30 +01005772/* update HP, line and mono out pins according to the master switch */
5773static void alc260_hp_master_update(struct hda_codec *codec,
5774 hda_nid_t hp, hda_nid_t line,
5775 hda_nid_t mono)
5776{
5777 struct alc_spec *spec = codec->spec;
5778 unsigned int val = spec->master_sw ? PIN_HP : 0;
5779 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005780 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005781 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005782 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005783 val);
5784 /* mono (speaker) depending on the HP jack sense */
5785 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005786 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005787 val);
5788}
5789
5790static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5791 struct snd_ctl_elem_value *ucontrol)
5792{
5793 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5794 struct alc_spec *spec = codec->spec;
5795 *ucontrol->value.integer.value = spec->master_sw;
5796 return 0;
5797}
5798
5799static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5800 struct snd_ctl_elem_value *ucontrol)
5801{
5802 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5803 struct alc_spec *spec = codec->spec;
5804 int val = !!*ucontrol->value.integer.value;
5805 hda_nid_t hp, line, mono;
5806
5807 if (val == spec->master_sw)
5808 return 0;
5809 spec->master_sw = val;
5810 hp = (kcontrol->private_value >> 16) & 0xff;
5811 line = (kcontrol->private_value >> 8) & 0xff;
5812 mono = kcontrol->private_value & 0xff;
5813 alc260_hp_master_update(codec, hp, line, mono);
5814 return 1;
5815}
5816
5817static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5818 {
5819 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5820 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005821 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005822 .info = snd_ctl_boolean_mono_info,
5823 .get = alc260_hp_master_sw_get,
5824 .put = alc260_hp_master_sw_put,
5825 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5826 },
5827 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5828 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5829 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5830 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5831 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5832 HDA_OUTPUT),
5833 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5834 { } /* end */
5835};
5836
5837static struct hda_verb alc260_hp_unsol_verbs[] = {
5838 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5839 {},
5840};
5841
5842static void alc260_hp_automute(struct hda_codec *codec)
5843{
5844 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005845
Wu Fengguang864f92b2009-11-18 12:38:02 +08005846 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005847 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5848}
5849
5850static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5851{
5852 if ((res >> 26) == ALC880_HP_EVENT)
5853 alc260_hp_automute(codec);
5854}
5855
Kailang Yangdf694da2005-12-05 19:42:22 +01005856static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005857 {
5858 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5859 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005860 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005861 .info = snd_ctl_boolean_mono_info,
5862 .get = alc260_hp_master_sw_get,
5863 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005864 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005865 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005866 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5867 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5868 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5869 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5870 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5871 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005872 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5873 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005874 { } /* end */
5875};
5876
Kailang Yang3f878302008-08-26 13:02:23 +02005877static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5878 .ops = &snd_hda_bind_vol,
5879 .values = {
5880 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5881 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5882 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5883 0
5884 },
5885};
5886
5887static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5888 .ops = &snd_hda_bind_sw,
5889 .values = {
5890 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5891 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5892 0
5893 },
5894};
5895
5896static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5897 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5898 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5899 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5900 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5901 { } /* end */
5902};
5903
Takashi Iwaibec15c32008-01-28 18:16:30 +01005904static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5905 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5906 {},
5907};
5908
5909static void alc260_hp_3013_automute(struct hda_codec *codec)
5910{
5911 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005912
Wu Fengguang864f92b2009-11-18 12:38:02 +08005913 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005914 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005915}
5916
5917static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5918 unsigned int res)
5919{
5920 if ((res >> 26) == ALC880_HP_EVENT)
5921 alc260_hp_3013_automute(codec);
5922}
5923
Kailang Yang3f878302008-08-26 13:02:23 +02005924static void alc260_hp_3012_automute(struct hda_codec *codec)
5925{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005926 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005927
Kailang Yang3f878302008-08-26 13:02:23 +02005928 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5929 bits);
5930 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5931 bits);
5932 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5933 bits);
5934}
5935
5936static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5937 unsigned int res)
5938{
5939 if ((res >> 26) == ALC880_HP_EVENT)
5940 alc260_hp_3012_automute(codec);
5941}
5942
5943/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005944 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5945 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005946static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005947 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005948 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005949 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005950 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5951 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5952 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5953 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005954 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005955 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5956 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005957 { } /* end */
5958};
5959
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005960/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5961 * versions of the ALC260 don't act on requests to enable mic bias from NID
5962 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5963 * datasheet doesn't mention this restriction. At this stage it's not clear
5964 * whether this behaviour is intentional or is a hardware bug in chip
5965 * revisions available in early 2006. Therefore for now allow the
5966 * "Headphone Jack Mode" control to span all choices, but if it turns out
5967 * that the lack of mic bias for this NID is intentional we could change the
5968 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5969 *
5970 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5971 * don't appear to make the mic bias available from the "line" jack, even
5972 * though the NID used for this jack (0x14) can supply it. The theory is
5973 * that perhaps Acer have included blocking capacitors between the ALC260
5974 * and the output jack. If this turns out to be the case for all such
5975 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5976 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005977 *
5978 * The C20x Tablet series have a mono internal speaker which is controlled
5979 * via the chip's Mono sum widget and pin complex, so include the necessary
5980 * controls for such models. On models without a "mono speaker" the control
5981 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005982 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005983static struct snd_kcontrol_new alc260_acer_mixer[] = {
5984 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5985 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005986 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005987 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005988 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005989 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005990 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005991 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5992 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5994 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5995 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5996 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5997 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5998 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005999 { } /* end */
6000};
6001
Michael Schwingencc959482009-02-22 18:58:45 +01006002/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6003 */
6004static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
6005 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6006 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6007 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6008 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6009 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6010 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6011 { } /* end */
6012};
6013
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006014/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6015 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6016 */
6017static struct snd_kcontrol_new alc260_will_mixer[] = {
6018 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6019 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6021 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6022 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6023 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6024 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6025 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6026 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6027 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006028 { } /* end */
6029};
6030
6031/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6032 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6033 */
6034static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
6035 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6036 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6037 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6038 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6039 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6040 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6041 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6042 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6043 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6044 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6045 { } /* end */
6046};
6047
Kailang Yangdf694da2005-12-05 19:42:22 +01006048/*
6049 * initialization verbs
6050 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006051static struct hda_verb alc260_init_verbs[] = {
6052 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006053 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006054 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006055 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006056 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006057 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006058 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006059 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006060 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006061 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006062 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006063 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006064 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006065 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006066 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006067 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006068 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006069 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6070 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006071 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006072 /* set connection select to line in (default select for this ADC) */
6073 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006074 /* mute capture amp left and right */
6075 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6076 /* set connection select to line in (default select for this ADC) */
6077 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006078 /* set vol=0 Line-Out mixer amp left and right */
6079 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6080 /* unmute pin widget amp left and right (no gain on this amp) */
6081 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6082 /* set vol=0 HP mixer amp left and right */
6083 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6084 /* unmute pin widget amp left and right (no gain on this amp) */
6085 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6086 /* set vol=0 Mono mixer amp left and right */
6087 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6088 /* unmute pin widget amp left and right (no gain on this amp) */
6089 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6090 /* unmute LINE-2 out pin */
6091 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006092 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6093 * Line In 2 = 0x03
6094 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006095 /* mute analog inputs */
6096 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6097 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6098 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6099 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6100 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006101 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006102 /* mute Front out path */
6103 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6104 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6105 /* mute Headphone out path */
6106 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6107 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6108 /* mute Mono out path */
6109 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6110 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006111 { }
6112};
6113
Takashi Iwai474167d2006-05-17 17:17:43 +02006114#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006115static struct hda_verb alc260_hp_init_verbs[] = {
6116 /* Headphone and output */
6117 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6118 /* mono output */
6119 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6120 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6121 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6122 /* Mic2 (front panel) pin widget for input and vref at 80% */
6123 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6124 /* Line In pin widget for input */
6125 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6126 /* Line-2 pin widget for output */
6127 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6128 /* CD pin widget for input */
6129 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6130 /* unmute amp left and right */
6131 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6132 /* set connection select to line in (default select for this ADC) */
6133 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6134 /* unmute Line-Out mixer amp left and right (volume = 0) */
6135 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6136 /* mute pin widget amp left and right (no gain on this amp) */
6137 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6138 /* unmute HP mixer amp left and right (volume = 0) */
6139 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6140 /* mute pin widget amp left and right (no gain on this amp) */
6141 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006142 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6143 * Line In 2 = 0x03
6144 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006145 /* mute analog inputs */
6146 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6148 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6150 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006151 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6152 /* Unmute Front out path */
6153 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6154 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6155 /* Unmute Headphone out path */
6156 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6157 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6158 /* Unmute Mono out path */
6159 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6160 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6161 { }
6162};
Takashi Iwai474167d2006-05-17 17:17:43 +02006163#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006164
6165static struct hda_verb alc260_hp_3013_init_verbs[] = {
6166 /* Line out and output */
6167 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6168 /* mono output */
6169 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6170 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6171 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6172 /* Mic2 (front panel) pin widget for input and vref at 80% */
6173 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6174 /* Line In pin widget for input */
6175 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6176 /* Headphone pin widget for output */
6177 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6178 /* CD pin widget for input */
6179 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6180 /* unmute amp left and right */
6181 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6182 /* set connection select to line in (default select for this ADC) */
6183 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6184 /* unmute Line-Out mixer amp left and right (volume = 0) */
6185 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6186 /* mute pin widget amp left and right (no gain on this amp) */
6187 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6188 /* unmute HP mixer amp left and right (volume = 0) */
6189 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6190 /* mute pin widget amp left and right (no gain on this amp) */
6191 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006192 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6193 * Line In 2 = 0x03
6194 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006195 /* mute analog inputs */
6196 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6197 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6198 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6199 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006201 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6202 /* Unmute Front out path */
6203 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6204 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6205 /* Unmute Headphone out path */
6206 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6207 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6208 /* Unmute Mono out path */
6209 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6210 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6211 { }
6212};
6213
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006214/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006215 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6216 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006217 */
6218static struct hda_verb alc260_fujitsu_init_verbs[] = {
6219 /* Disable all GPIOs */
6220 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6221 /* Internal speaker is connected to headphone pin */
6222 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6223 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6224 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006225 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6226 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6227 /* Ensure all other unused pins are disabled and muted. */
6228 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6229 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006230 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006231 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006232 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006233 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6234 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6235 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006236
Jonathan Woithef7ace402006-02-28 11:46:14 +01006237 /* Disable digital (SPDIF) pins */
6238 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6239 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006240
Kailang Yangea1fb292008-08-26 12:58:38 +02006241 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006242 * when acting as an output.
6243 */
6244 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6245
6246 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006247 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6248 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6249 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6250 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6251 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6252 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6253 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6254 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6255 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006256
Jonathan Woithef7ace402006-02-28 11:46:14 +01006257 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6258 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6259 /* Unmute Line1 pin widget output buffer since it starts as an output.
6260 * If the pin mode is changed by the user the pin mode control will
6261 * take care of enabling the pin's input/output buffers as needed.
6262 * Therefore there's no need to enable the input buffer at this
6263 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006264 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006265 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006266 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006267 * mixer ctrl)
6268 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006269 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006270
Jonathan Woithef7ace402006-02-28 11:46:14 +01006271 /* Mute capture amp left and right */
6272 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006273 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006274 * in (on mic1 pin)
6275 */
6276 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006277
Jonathan Woithef7ace402006-02-28 11:46:14 +01006278 /* Do the same for the second ADC: mute capture input amp and
6279 * set ADC connection to line in (on mic1 pin)
6280 */
6281 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6282 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006283
Jonathan Woithef7ace402006-02-28 11:46:14 +01006284 /* Mute all inputs to mixer widget (even unconnected ones) */
6285 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6286 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6287 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6288 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6289 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6290 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6291 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6292 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006293
6294 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006295};
6296
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006297/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6298 * similar laptops (adapted from Fujitsu init verbs).
6299 */
6300static struct hda_verb alc260_acer_init_verbs[] = {
6301 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6302 * the headphone jack. Turn this on and rely on the standard mute
6303 * methods whenever the user wants to turn these outputs off.
6304 */
6305 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6306 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6307 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6308 /* Internal speaker/Headphone jack is connected to Line-out pin */
6309 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6310 /* Internal microphone/Mic jack is connected to Mic1 pin */
6311 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6312 /* Line In jack is connected to Line1 pin */
6313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006314 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6315 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006316 /* Ensure all other unused pins are disabled and muted. */
6317 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6318 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006319 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6320 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6321 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6322 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6323 /* Disable digital (SPDIF) pins */
6324 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6325 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6326
Kailang Yangea1fb292008-08-26 12:58:38 +02006327 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006328 * bus when acting as outputs.
6329 */
6330 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6331 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6332
6333 /* Start with output sum widgets muted and their output gains at min */
6334 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6335 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6336 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6337 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6338 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6339 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6340 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6341 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6342 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6343
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006344 /* Unmute Line-out pin widget amp left and right
6345 * (no equiv mixer ctrl)
6346 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006347 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006348 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6349 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006350 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6351 * inputs. If the pin mode is changed by the user the pin mode control
6352 * will take care of enabling the pin's input/output buffers as needed.
6353 * Therefore there's no need to enable the input buffer at this
6354 * stage.
6355 */
6356 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6357 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6358
6359 /* Mute capture amp left and right */
6360 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6361 /* Set ADC connection select to match default mixer setting - mic
6362 * (on mic1 pin)
6363 */
6364 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6365
6366 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006367 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006368 */
6369 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006370 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006371
6372 /* Mute all inputs to mixer widget (even unconnected ones) */
6373 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6374 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6375 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6376 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6377 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6378 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6380 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6381
6382 { }
6383};
6384
Michael Schwingencc959482009-02-22 18:58:45 +01006385/* Initialisation sequence for Maxdata Favorit 100XS
6386 * (adapted from Acer init verbs).
6387 */
6388static struct hda_verb alc260_favorit100_init_verbs[] = {
6389 /* GPIO 0 enables the output jack.
6390 * Turn this on and rely on the standard mute
6391 * methods whenever the user wants to turn these outputs off.
6392 */
6393 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6394 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6395 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6396 /* Line/Mic input jack is connected to Mic1 pin */
6397 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6398 /* Ensure all other unused pins are disabled and muted. */
6399 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6400 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6401 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6402 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6403 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6404 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6405 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6406 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6407 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6408 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6409 /* Disable digital (SPDIF) pins */
6410 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6411 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6412
6413 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6414 * bus when acting as outputs.
6415 */
6416 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6417 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6418
6419 /* Start with output sum widgets muted and their output gains at min */
6420 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6421 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6422 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6423 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6424 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6425 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6426 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6427 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6428 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6429
6430 /* Unmute Line-out pin widget amp left and right
6431 * (no equiv mixer ctrl)
6432 */
6433 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6434 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6435 * inputs. If the pin mode is changed by the user the pin mode control
6436 * will take care of enabling the pin's input/output buffers as needed.
6437 * Therefore there's no need to enable the input buffer at this
6438 * stage.
6439 */
6440 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6441
6442 /* Mute capture amp left and right */
6443 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6444 /* Set ADC connection select to match default mixer setting - mic
6445 * (on mic1 pin)
6446 */
6447 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6448
6449 /* Do similar with the second ADC: mute capture input amp and
6450 * set ADC connection to mic to match ALSA's default state.
6451 */
6452 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6453 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6454
6455 /* Mute all inputs to mixer widget (even unconnected ones) */
6456 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6457 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6459 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6462 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6463 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6464
6465 { }
6466};
6467
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006468static struct hda_verb alc260_will_verbs[] = {
6469 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6470 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6471 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6472 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6473 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6474 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6475 {}
6476};
6477
6478static struct hda_verb alc260_replacer_672v_verbs[] = {
6479 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6480 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6481 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6482
6483 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6484 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6485 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6486
6487 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6488 {}
6489};
6490
6491/* toggle speaker-output according to the hp-jack state */
6492static void alc260_replacer_672v_automute(struct hda_codec *codec)
6493{
6494 unsigned int present;
6495
6496 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006497 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006498 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006499 snd_hda_codec_write_cache(codec, 0x01, 0,
6500 AC_VERB_SET_GPIO_DATA, 1);
6501 snd_hda_codec_write_cache(codec, 0x0f, 0,
6502 AC_VERB_SET_PIN_WIDGET_CONTROL,
6503 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006504 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006505 snd_hda_codec_write_cache(codec, 0x01, 0,
6506 AC_VERB_SET_GPIO_DATA, 0);
6507 snd_hda_codec_write_cache(codec, 0x0f, 0,
6508 AC_VERB_SET_PIN_WIDGET_CONTROL,
6509 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006510 }
6511}
6512
6513static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6514 unsigned int res)
6515{
6516 if ((res >> 26) == ALC880_HP_EVENT)
6517 alc260_replacer_672v_automute(codec);
6518}
6519
Kailang Yang3f878302008-08-26 13:02:23 +02006520static struct hda_verb alc260_hp_dc7600_verbs[] = {
6521 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6522 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6523 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6524 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6525 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6526 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6527 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6528 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6529 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6530 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6531 {}
6532};
6533
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006534/* Test configuration for debugging, modelled after the ALC880 test
6535 * configuration.
6536 */
6537#ifdef CONFIG_SND_DEBUG
6538static hda_nid_t alc260_test_dac_nids[1] = {
6539 0x02,
6540};
6541static hda_nid_t alc260_test_adc_nids[2] = {
6542 0x04, 0x05,
6543};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006544/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006545 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006546 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006547 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006548static struct hda_input_mux alc260_test_capture_sources[2] = {
6549 {
6550 .num_items = 7,
6551 .items = {
6552 { "MIC1 pin", 0x0 },
6553 { "MIC2 pin", 0x1 },
6554 { "LINE1 pin", 0x2 },
6555 { "LINE2 pin", 0x3 },
6556 { "CD pin", 0x4 },
6557 { "LINE-OUT pin", 0x5 },
6558 { "HP-OUT pin", 0x6 },
6559 },
6560 },
6561 {
6562 .num_items = 8,
6563 .items = {
6564 { "MIC1 pin", 0x0 },
6565 { "MIC2 pin", 0x1 },
6566 { "LINE1 pin", 0x2 },
6567 { "LINE2 pin", 0x3 },
6568 { "CD pin", 0x4 },
6569 { "Mixer", 0x5 },
6570 { "LINE-OUT pin", 0x6 },
6571 { "HP-OUT pin", 0x7 },
6572 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006573 },
6574};
6575static struct snd_kcontrol_new alc260_test_mixer[] = {
6576 /* Output driver widgets */
6577 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6578 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6579 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6580 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6581 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6582 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6583
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006584 /* Modes for retasking pin widgets
6585 * Note: the ALC260 doesn't seem to act on requests to enable mic
6586 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6587 * mention this restriction. At this stage it's not clear whether
6588 * this behaviour is intentional or is a hardware bug in chip
6589 * revisions available at least up until early 2006. Therefore for
6590 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6591 * choices, but if it turns out that the lack of mic bias for these
6592 * NIDs is intentional we could change their modes from
6593 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6594 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006595 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6596 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6597 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6598 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6599 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6600 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6601
6602 /* Loopback mixer controls */
6603 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6604 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6605 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6606 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6607 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6608 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6609 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6610 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6611 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6612 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006613 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6614 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6615 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6616 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006617
6618 /* Controls for GPIO pins, assuming they are configured as outputs */
6619 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6620 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6621 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6622 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6623
Jonathan Woithe92621f12006-02-28 11:47:47 +01006624 /* Switches to allow the digital IO pins to be enabled. The datasheet
6625 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006626 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006627 */
6628 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6629 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6630
Jonathan Woithef8225f62008-01-08 12:16:54 +01006631 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6632 * this output to turn on an external amplifier.
6633 */
6634 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6635 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6636
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006637 { } /* end */
6638};
6639static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006640 /* Enable all GPIOs as outputs with an initial value of 0 */
6641 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6642 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6643 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6644
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006645 /* Enable retasking pins as output, initially without power amp */
6646 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6647 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6648 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6649 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6650 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6651 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6652
Jonathan Woithe92621f12006-02-28 11:47:47 +01006653 /* Disable digital (SPDIF) pins initially, but users can enable
6654 * them via a mixer switch. In the case of SPDIF-out, this initverb
6655 * payload also sets the generation to 0, output to be in "consumer"
6656 * PCM format, copyright asserted, no pre-emphasis and no validity
6657 * control.
6658 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006659 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6660 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6661
Kailang Yangea1fb292008-08-26 12:58:38 +02006662 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006663 * OUT1 sum bus when acting as an output.
6664 */
6665 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6666 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6667 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6668 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6669
6670 /* Start with output sum widgets muted and their output gains at min */
6671 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6672 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6673 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6674 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6675 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6676 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6677 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6678 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6679 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6680
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006681 /* Unmute retasking pin widget output buffers since the default
6682 * state appears to be output. As the pin mode is changed by the
6683 * user the pin mode control will take care of enabling the pin's
6684 * input/output buffers as needed.
6685 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006686 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6687 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6688 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6689 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6690 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6691 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6692 /* Also unmute the mono-out pin widget */
6693 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6694
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006695 /* Mute capture amp left and right */
6696 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006697 /* Set ADC connection select to match default mixer setting (mic1
6698 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006699 */
6700 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6701
6702 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006703 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006704 */
6705 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6706 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6707
6708 /* Mute all inputs to mixer widget (even unconnected ones) */
6709 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6710 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6711 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6712 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6713 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6714 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6715 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6717
6718 { }
6719};
6720#endif
6721
Takashi Iwai63300792008-01-24 15:31:36 +01006722#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6723#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006724
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006725#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6726#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6727
Kailang Yangdf694da2005-12-05 19:42:22 +01006728/*
6729 * for BIOS auto-configuration
6730 */
6731
6732static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006733 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006734{
6735 hda_nid_t nid_vol;
6736 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006737 int err;
6738
6739 if (nid >= 0x0f && nid < 0x11) {
6740 nid_vol = nid - 0x7;
6741 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6742 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6743 } else if (nid == 0x11) {
6744 nid_vol = nid - 0x7;
6745 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6746 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6747 } else if (nid >= 0x12 && nid <= 0x15) {
6748 nid_vol = 0x08;
6749 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6750 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6751 } else
6752 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006753
Takashi Iwai863b4512008-10-21 17:01:47 +02006754 if (!(*vol_bits & (1 << nid_vol))) {
6755 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006756 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006757 if (err < 0)
6758 return err;
6759 *vol_bits |= (1 << nid_vol);
6760 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006761 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006762 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006763 return err;
6764 return 1;
6765}
6766
6767/* add playback controls from the parsed DAC table */
6768static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6769 const struct auto_pin_cfg *cfg)
6770{
6771 hda_nid_t nid;
6772 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006773 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006774
6775 spec->multiout.num_dacs = 1;
6776 spec->multiout.dac_nids = spec->private_dac_nids;
6777 spec->multiout.dac_nids[0] = 0x02;
6778
6779 nid = cfg->line_out_pins[0];
6780 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006781 const char *pfx;
6782 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6783 pfx = "Master";
6784 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6785 pfx = "Speaker";
6786 else
6787 pfx = "Front";
6788 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006789 if (err < 0)
6790 return err;
6791 }
6792
Takashi Iwai82bc9552006-03-21 11:24:42 +01006793 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006794 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006795 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006796 if (err < 0)
6797 return err;
6798 }
6799
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006800 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006801 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006802 err = alc260_add_playback_controls(spec, nid, "Headphone",
6803 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006804 if (err < 0)
6805 return err;
6806 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006807 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006808}
6809
6810/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006811static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006812 const struct auto_pin_cfg *cfg)
6813{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006814 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006815}
6816
6817static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6818 hda_nid_t nid, int pin_type,
6819 int sel_idx)
6820{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006821 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006822 /* need the manual connection? */
6823 if (nid >= 0x12) {
6824 int idx = nid - 0x12;
6825 snd_hda_codec_write(codec, idx + 0x0b, 0,
6826 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006827 }
6828}
6829
6830static void alc260_auto_init_multi_out(struct hda_codec *codec)
6831{
6832 struct alc_spec *spec = codec->spec;
6833 hda_nid_t nid;
6834
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006835 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006836 if (nid) {
6837 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6838 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6839 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006840
Takashi Iwai82bc9552006-03-21 11:24:42 +01006841 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006842 if (nid)
6843 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6844
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006845 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006846 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006847 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006848}
Kailang Yangdf694da2005-12-05 19:42:22 +01006849
6850#define ALC260_PIN_CD_NID 0x16
6851static void alc260_auto_init_analog_input(struct hda_codec *codec)
6852{
6853 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006854 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01006855 int i;
6856
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006857 for (i = 0; i < cfg->num_inputs; i++) {
6858 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01006859 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02006860 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006861 if (nid != ALC260_PIN_CD_NID &&
6862 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006863 snd_hda_codec_write(codec, nid, 0,
6864 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006865 AMP_OUT_MUTE);
6866 }
6867 }
6868}
6869
Takashi Iwai7f311a42010-04-09 17:32:23 +02006870#define alc260_auto_init_input_src alc880_auto_init_input_src
6871
Kailang Yangdf694da2005-12-05 19:42:22 +01006872/*
6873 * generic initialization of ADC, input mixers and output mixers
6874 */
6875static struct hda_verb alc260_volume_init_verbs[] = {
6876 /*
6877 * Unmute ADC0-1 and set the default input to mic-in
6878 */
6879 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6880 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6881 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6882 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006883
Kailang Yangdf694da2005-12-05 19:42:22 +01006884 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6885 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006886 * Note: PASD motherboards uses the Line In 2 as the input for
6887 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006888 */
6889 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006890 /* mute analog inputs */
6891 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6892 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6893 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6894 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6895 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006896
6897 /*
6898 * Set up output mixers (0x08 - 0x0a)
6899 */
6900 /* set vol=0 to output mixers */
6901 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6902 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6903 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6904 /* set up input amps for analog loopback */
6905 /* Amp Indices: DAC = 0, mixer = 1 */
6906 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6907 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6908 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6909 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6910 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6911 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006912
Kailang Yangdf694da2005-12-05 19:42:22 +01006913 { }
6914};
6915
6916static int alc260_parse_auto_config(struct hda_codec *codec)
6917{
6918 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006919 int err;
6920 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6921
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006922 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6923 alc260_ignore);
6924 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006925 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006926 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6927 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006928 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006929 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006930 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006931 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006932 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006933 return err;
6934
6935 spec->multiout.max_channels = 2;
6936
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006937 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006938 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006939 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006940 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006941
Takashi Iwaid88897e2008-10-31 15:01:37 +01006942 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006943
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006944 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006945 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006946
Kailang Yang6227cdc2010-02-25 08:36:52 +01006947 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006948
Kailang Yangdf694da2005-12-05 19:42:22 +01006949 return 1;
6950}
6951
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006952/* additional initialization for auto-configuration model */
6953static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006954{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006955 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006956 alc260_auto_init_multi_out(codec);
6957 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02006958 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02006959 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006960 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006961 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006962}
6963
Takashi Iwaicb53c622007-08-10 17:21:45 +02006964#ifdef CONFIG_SND_HDA_POWER_SAVE
6965static struct hda_amp_list alc260_loopbacks[] = {
6966 { 0x07, HDA_INPUT, 0 },
6967 { 0x07, HDA_INPUT, 1 },
6968 { 0x07, HDA_INPUT, 2 },
6969 { 0x07, HDA_INPUT, 3 },
6970 { 0x07, HDA_INPUT, 4 },
6971 { } /* end */
6972};
6973#endif
6974
Kailang Yangdf694da2005-12-05 19:42:22 +01006975/*
Takashi Iwaifc091762010-08-04 23:53:36 +02006976 * Pin config fixes
6977 */
6978enum {
6979 PINFIX_HP_DC5750,
6980};
6981
Takashi Iwaifc091762010-08-04 23:53:36 +02006982static const struct alc_fixup alc260_fixups[] = {
6983 [PINFIX_HP_DC5750] = {
Takashi Iwai73413b12010-08-30 09:39:57 +02006984 .pins = (const struct alc_pincfg[]) {
6985 { 0x11, 0x90130110 }, /* speaker */
6986 { }
6987 }
Takashi Iwaifc091762010-08-04 23:53:36 +02006988 },
6989};
6990
6991static struct snd_pci_quirk alc260_fixup_tbl[] = {
6992 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
6993 {}
6994};
6995
6996/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006997 * ALC260 configurations
6998 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006999static const char *alc260_models[ALC260_MODEL_LAST] = {
7000 [ALC260_BASIC] = "basic",
7001 [ALC260_HP] = "hp",
7002 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007003 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007004 [ALC260_FUJITSU_S702X] = "fujitsu",
7005 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007006 [ALC260_WILL] = "will",
7007 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007008 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007009#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007010 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007011#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007012 [ALC260_AUTO] = "auto",
7013};
7014
7015static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007016 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007017 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007018 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007019 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007020 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007021 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007022 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007023 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007024 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007025 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7026 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7027 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7028 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7029 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7030 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7031 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7032 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7033 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007034 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007035 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007036 {}
7037};
7038
Kailang Yangdf694da2005-12-05 19:42:22 +01007039static struct alc_config_preset alc260_presets[] = {
7040 [ALC260_BASIC] = {
7041 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007042 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007043 .init_verbs = { alc260_init_verbs },
7044 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7045 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007046 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007047 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007048 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7049 .channel_mode = alc260_modes,
7050 .input_mux = &alc260_capture_source,
7051 },
7052 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007053 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007054 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007055 .init_verbs = { alc260_init_verbs,
7056 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007057 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7058 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007059 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7060 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007061 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7062 .channel_mode = alc260_modes,
7063 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007064 .unsol_event = alc260_hp_unsol_event,
7065 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007066 },
Kailang Yang3f878302008-08-26 13:02:23 +02007067 [ALC260_HP_DC7600] = {
7068 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007069 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007070 .init_verbs = { alc260_init_verbs,
7071 alc260_hp_dc7600_verbs },
7072 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7073 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007074 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7075 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007076 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7077 .channel_mode = alc260_modes,
7078 .input_mux = &alc260_capture_source,
7079 .unsol_event = alc260_hp_3012_unsol_event,
7080 .init_hook = alc260_hp_3012_automute,
7081 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007082 [ALC260_HP_3013] = {
7083 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007084 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007085 .init_verbs = { alc260_hp_3013_init_verbs,
7086 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007087 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7088 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007089 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7090 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007091 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7092 .channel_mode = alc260_modes,
7093 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007094 .unsol_event = alc260_hp_3013_unsol_event,
7095 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007096 },
7097 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007098 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007099 .init_verbs = { alc260_fujitsu_init_verbs },
7100 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7101 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007102 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7103 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007104 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7105 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007106 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7107 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007108 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007109 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007110 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007111 .init_verbs = { alc260_acer_init_verbs },
7112 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7113 .dac_nids = alc260_dac_nids,
7114 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7115 .adc_nids = alc260_dual_adc_nids,
7116 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7117 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007118 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7119 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007120 },
Michael Schwingencc959482009-02-22 18:58:45 +01007121 [ALC260_FAVORIT100] = {
7122 .mixers = { alc260_favorit100_mixer },
7123 .init_verbs = { alc260_favorit100_init_verbs },
7124 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7125 .dac_nids = alc260_dac_nids,
7126 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7127 .adc_nids = alc260_dual_adc_nids,
7128 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7129 .channel_mode = alc260_modes,
7130 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7131 .input_mux = alc260_favorit100_capture_sources,
7132 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007133 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007134 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007135 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7136 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7137 .dac_nids = alc260_dac_nids,
7138 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7139 .adc_nids = alc260_adc_nids,
7140 .dig_out_nid = ALC260_DIGOUT_NID,
7141 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7142 .channel_mode = alc260_modes,
7143 .input_mux = &alc260_capture_source,
7144 },
7145 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007146 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007147 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7148 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7149 .dac_nids = alc260_dac_nids,
7150 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7151 .adc_nids = alc260_adc_nids,
7152 .dig_out_nid = ALC260_DIGOUT_NID,
7153 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7154 .channel_mode = alc260_modes,
7155 .input_mux = &alc260_capture_source,
7156 .unsol_event = alc260_replacer_672v_unsol_event,
7157 .init_hook = alc260_replacer_672v_automute,
7158 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007159#ifdef CONFIG_SND_DEBUG
7160 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007161 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007162 .init_verbs = { alc260_test_init_verbs },
7163 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7164 .dac_nids = alc260_test_dac_nids,
7165 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7166 .adc_nids = alc260_test_adc_nids,
7167 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7168 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007169 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7170 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007171 },
7172#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007173};
7174
Linus Torvalds1da177e2005-04-16 15:20:36 -07007175static int patch_alc260(struct hda_codec *codec)
7176{
7177 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007178 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007179
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007180 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007181 if (spec == NULL)
7182 return -ENOMEM;
7183
7184 codec->spec = spec;
7185
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007186 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7187 alc260_models,
7188 alc260_cfg_tbl);
7189 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007190 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007191 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007192 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007193 }
7194
Takashi Iwaifc091762010-08-04 23:53:36 +02007195 if (board_config == ALC260_AUTO)
7196 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 1);
7197
Kailang Yangdf694da2005-12-05 19:42:22 +01007198 if (board_config == ALC260_AUTO) {
7199 /* automatic parse from the BIOS config */
7200 err = alc260_parse_auto_config(codec);
7201 if (err < 0) {
7202 alc_free(codec);
7203 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007204 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007205 printk(KERN_INFO
7206 "hda_codec: Cannot set up configuration "
7207 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007208 board_config = ALC260_BASIC;
7209 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007210 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007211
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007212 err = snd_hda_attach_beep_device(codec, 0x1);
7213 if (err < 0) {
7214 alc_free(codec);
7215 return err;
7216 }
7217
Kailang Yangdf694da2005-12-05 19:42:22 +01007218 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007219 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007220
Linus Torvalds1da177e2005-04-16 15:20:36 -07007221 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7222 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307223 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007224
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007225 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7226 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7227
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007228 if (!spec->adc_nids && spec->input_mux) {
7229 /* check whether NID 0x04 is valid */
7230 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007231 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007232 /* get type */
7233 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7234 spec->adc_nids = alc260_adc_nids_alt;
7235 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7236 } else {
7237 spec->adc_nids = alc260_adc_nids;
7238 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7239 }
7240 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007241 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007242 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007243
Takashi Iwaifc091762010-08-04 23:53:36 +02007244 if (board_config == ALC260_AUTO)
7245 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 0);
7246
Takashi Iwai2134ea42008-01-10 16:53:55 +01007247 spec->vmaster_nid = 0x08;
7248
Linus Torvalds1da177e2005-04-16 15:20:36 -07007249 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007250 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007251 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007252#ifdef CONFIG_SND_HDA_POWER_SAVE
7253 if (!spec->loopback.amplist)
7254 spec->loopback.amplist = alc260_loopbacks;
7255#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007256
7257 return 0;
7258}
7259
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007260
Linus Torvalds1da177e2005-04-16 15:20:36 -07007261/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007262 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007263 *
7264 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7265 * configuration. Each pin widget can choose any input DACs and a mixer.
7266 * Each ADC is connected from a mixer of all inputs. This makes possible
7267 * 6-channel independent captures.
7268 *
7269 * In addition, an independent DAC for the multi-playback (not used in this
7270 * driver yet).
7271 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007272#define ALC882_DIGOUT_NID 0x06
7273#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007274#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7275#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7276#define ALC1200_DIGOUT_NID 0x10
7277
Linus Torvalds1da177e2005-04-16 15:20:36 -07007278
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007279static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007280 { 8, NULL }
7281};
7282
Takashi Iwai4953550a2009-06-30 15:28:30 +02007283/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007284static hda_nid_t alc882_dac_nids[4] = {
7285 /* front, rear, clfe, rear_surr */
7286 0x02, 0x03, 0x04, 0x05
7287};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007288#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007289
Takashi Iwai4953550a2009-06-30 15:28:30 +02007290/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007291#define alc882_adc_nids alc880_adc_nids
7292#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007293#define alc883_adc_nids alc882_adc_nids_alt
7294static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7295static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7296#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007297
Takashi Iwaie1406342008-02-11 18:32:32 +01007298static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7299static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007300#define alc883_capsrc_nids alc882_capsrc_nids_alt
7301static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7302#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007303
Linus Torvalds1da177e2005-04-16 15:20:36 -07007304/* input MUX */
7305/* FIXME: should be a matrix-type input source selection */
7306
7307static struct hda_input_mux alc882_capture_source = {
7308 .num_items = 4,
7309 .items = {
7310 { "Mic", 0x0 },
7311 { "Front Mic", 0x1 },
7312 { "Line", 0x2 },
7313 { "CD", 0x4 },
7314 },
7315};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007316
Takashi Iwai4953550a2009-06-30 15:28:30 +02007317#define alc883_capture_source alc882_capture_source
7318
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007319static struct hda_input_mux alc889_capture_source = {
7320 .num_items = 3,
7321 .items = {
7322 { "Front Mic", 0x0 },
7323 { "Mic", 0x3 },
7324 { "Line", 0x2 },
7325 },
7326};
7327
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007328static struct hda_input_mux mb5_capture_source = {
7329 .num_items = 3,
7330 .items = {
7331 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307332 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007333 { "CD", 0x4 },
7334 },
7335};
7336
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007337static struct hda_input_mux macmini3_capture_source = {
7338 .num_items = 2,
7339 .items = {
7340 { "Line", 0x2 },
7341 { "CD", 0x4 },
7342 },
7343};
7344
Takashi Iwai4953550a2009-06-30 15:28:30 +02007345static struct hda_input_mux alc883_3stack_6ch_intel = {
7346 .num_items = 4,
7347 .items = {
7348 { "Mic", 0x1 },
7349 { "Front Mic", 0x0 },
7350 { "Line", 0x2 },
7351 { "CD", 0x4 },
7352 },
7353};
7354
7355static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7356 .num_items = 2,
7357 .items = {
7358 { "Mic", 0x1 },
7359 { "Line", 0x2 },
7360 },
7361};
7362
7363static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7364 .num_items = 4,
7365 .items = {
7366 { "Mic", 0x0 },
David Henningsson150b4322010-07-29 14:46:42 +02007367 { "Int Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007368 { "Line", 0x2 },
7369 { "CD", 0x4 },
7370 },
7371};
7372
7373static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7374 .num_items = 2,
7375 .items = {
7376 { "Mic", 0x0 },
7377 { "Int Mic", 0x1 },
7378 },
7379};
7380
7381static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7382 .num_items = 3,
7383 .items = {
7384 { "Mic", 0x0 },
7385 { "Front Mic", 0x1 },
7386 { "Line", 0x4 },
7387 },
7388};
7389
7390static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7391 .num_items = 2,
7392 .items = {
7393 { "Mic", 0x0 },
7394 { "Line", 0x2 },
7395 },
7396};
7397
7398static struct hda_input_mux alc889A_mb31_capture_source = {
7399 .num_items = 2,
7400 .items = {
7401 { "Mic", 0x0 },
7402 /* Front Mic (0x01) unused */
7403 { "Line", 0x2 },
7404 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007405 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007406 },
7407};
7408
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007409static struct hda_input_mux alc889A_imac91_capture_source = {
7410 .num_items = 2,
7411 .items = {
7412 { "Mic", 0x01 },
7413 { "Line", 0x2 }, /* Not sure! */
7414 },
7415};
7416
Takashi Iwai4953550a2009-06-30 15:28:30 +02007417/*
7418 * 2ch mode
7419 */
7420static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7421 { 2, NULL }
7422};
7423
Kailang Yangdf694da2005-12-05 19:42:22 +01007424/*
Kailang Yang272a5272007-05-14 11:00:38 +02007425 * 2ch mode
7426 */
7427static struct hda_verb alc882_3ST_ch2_init[] = {
7428 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7429 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7430 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7431 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7432 { } /* end */
7433};
7434
7435/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007436 * 4ch mode
7437 */
7438static struct hda_verb alc882_3ST_ch4_init[] = {
7439 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7440 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7441 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7442 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7443 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7444 { } /* end */
7445};
7446
7447/*
Kailang Yang272a5272007-05-14 11:00:38 +02007448 * 6ch mode
7449 */
7450static struct hda_verb alc882_3ST_ch6_init[] = {
7451 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7452 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7453 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7454 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7455 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7456 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7457 { } /* end */
7458};
7459
Takashi Iwai4953550a2009-06-30 15:28:30 +02007460static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007461 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007462 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007463 { 6, alc882_3ST_ch6_init },
7464};
7465
Takashi Iwai4953550a2009-06-30 15:28:30 +02007466#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7467
Kailang Yang272a5272007-05-14 11:00:38 +02007468/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307469 * 2ch mode
7470 */
7471static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7472 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7473 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7474 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7475 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7476 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7477 { } /* end */
7478};
7479
7480/*
7481 * 4ch mode
7482 */
7483static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7484 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7485 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7486 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7487 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7488 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7489 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7490 { } /* end */
7491};
7492
7493/*
7494 * 6ch mode
7495 */
7496static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7497 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7498 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7499 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7500 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7501 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7502 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7503 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7504 { } /* end */
7505};
7506
7507static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7508 { 2, alc883_3ST_ch2_clevo_init },
7509 { 4, alc883_3ST_ch4_clevo_init },
7510 { 6, alc883_3ST_ch6_clevo_init },
7511};
7512
7513
7514/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007515 * 6ch mode
7516 */
7517static struct hda_verb alc882_sixstack_ch6_init[] = {
7518 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7519 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7520 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7521 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7522 { } /* end */
7523};
7524
7525/*
7526 * 8ch mode
7527 */
7528static struct hda_verb alc882_sixstack_ch8_init[] = {
7529 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7530 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7531 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7532 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7533 { } /* end */
7534};
7535
7536static struct hda_channel_mode alc882_sixstack_modes[2] = {
7537 { 6, alc882_sixstack_ch6_init },
7538 { 8, alc882_sixstack_ch8_init },
7539};
7540
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007541
7542/* Macbook Air 2,1 */
7543
7544static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7545 { 2, NULL },
7546};
7547
Takashi Iwai87350ad2007-08-16 18:19:38 +02007548/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007549 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007550 */
7551
7552/*
7553 * 2ch mode
7554 */
7555static struct hda_verb alc885_mbp_ch2_init[] = {
7556 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7557 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7558 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7559 { } /* end */
7560};
7561
7562/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007563 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007564 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007565static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007566 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7567 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7568 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7569 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7570 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7571 { } /* end */
7572};
7573
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007574static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007575 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007576 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007577};
7578
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007579/*
7580 * 2ch
7581 * Speakers/Woofer/HP = Front
7582 * LineIn = Input
7583 */
7584static struct hda_verb alc885_mb5_ch2_init[] = {
7585 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7586 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7587 { } /* end */
7588};
7589
7590/*
7591 * 6ch mode
7592 * Speakers/HP = Front
7593 * Woofer = LFE
7594 * LineIn = Surround
7595 */
7596static struct hda_verb alc885_mb5_ch6_init[] = {
7597 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7598 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7599 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7600 { } /* end */
7601};
7602
7603static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7604 { 2, alc885_mb5_ch2_init },
7605 { 6, alc885_mb5_ch6_init },
7606};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007607
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007608#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007609
7610/*
7611 * 2ch mode
7612 */
7613static struct hda_verb alc883_4ST_ch2_init[] = {
7614 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7615 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7616 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7617 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7618 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7619 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7620 { } /* end */
7621};
7622
7623/*
7624 * 4ch mode
7625 */
7626static struct hda_verb alc883_4ST_ch4_init[] = {
7627 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7628 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7629 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7630 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7631 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7632 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7633 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7634 { } /* end */
7635};
7636
7637/*
7638 * 6ch mode
7639 */
7640static struct hda_verb alc883_4ST_ch6_init[] = {
7641 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7642 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7643 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7644 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7645 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7646 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7647 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7648 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7649 { } /* end */
7650};
7651
7652/*
7653 * 8ch mode
7654 */
7655static struct hda_verb alc883_4ST_ch8_init[] = {
7656 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7657 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7658 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7659 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7660 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7661 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7662 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7663 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7664 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7665 { } /* end */
7666};
7667
7668static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7669 { 2, alc883_4ST_ch2_init },
7670 { 4, alc883_4ST_ch4_init },
7671 { 6, alc883_4ST_ch6_init },
7672 { 8, alc883_4ST_ch8_init },
7673};
7674
7675
7676/*
7677 * 2ch mode
7678 */
7679static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7680 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7681 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7682 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7683 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7684 { } /* end */
7685};
7686
7687/*
7688 * 4ch mode
7689 */
7690static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7691 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7692 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7693 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7694 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7695 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7696 { } /* end */
7697};
7698
7699/*
7700 * 6ch mode
7701 */
7702static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7703 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7704 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7705 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7706 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7707 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7708 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7709 { } /* end */
7710};
7711
7712static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7713 { 2, alc883_3ST_ch2_intel_init },
7714 { 4, alc883_3ST_ch4_intel_init },
7715 { 6, alc883_3ST_ch6_intel_init },
7716};
7717
7718/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007719 * 2ch mode
7720 */
7721static struct hda_verb alc889_ch2_intel_init[] = {
7722 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7723 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7724 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7725 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7726 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7727 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7728 { } /* end */
7729};
7730
7731/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007732 * 6ch mode
7733 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007734static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007735 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7736 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7737 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7738 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7739 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007740 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7741 { } /* end */
7742};
7743
7744/*
7745 * 8ch mode
7746 */
7747static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007748 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7749 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7750 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7751 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7752 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007753 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7754 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007755 { } /* end */
7756};
7757
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007758static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7759 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007760 { 6, alc889_ch6_intel_init },
7761 { 8, alc889_ch8_intel_init },
7762};
7763
7764/*
7765 * 6ch mode
7766 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007767static struct hda_verb alc883_sixstack_ch6_init[] = {
7768 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7769 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7770 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7771 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7772 { } /* end */
7773};
7774
7775/*
7776 * 8ch mode
7777 */
7778static struct hda_verb alc883_sixstack_ch8_init[] = {
7779 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7780 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7781 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7782 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7783 { } /* end */
7784};
7785
7786static struct hda_channel_mode alc883_sixstack_modes[2] = {
7787 { 6, alc883_sixstack_ch6_init },
7788 { 8, alc883_sixstack_ch8_init },
7789};
7790
7791
Linus Torvalds1da177e2005-04-16 15:20:36 -07007792/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7793 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7794 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007795static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007796 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007797 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007798 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007799 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007800 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7801 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007802 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7803 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007804 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007805 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007806 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7807 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7808 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7809 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7810 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007812 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007813 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7814 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007815 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007816 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007817 { } /* end */
7818};
7819
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007820/* Macbook Air 2,1 same control for HP and internal Speaker */
7821
7822static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7823 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7824 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7825 { }
7826};
7827
7828
Takashi Iwai87350ad2007-08-16 18:19:38 +02007829static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007830 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7831 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7832 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7833 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7834 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007835 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7836 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007837 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7838 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007839 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007840 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7841 { } /* end */
7842};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007843
7844static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007845 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7846 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7847 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7848 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7849 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7850 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307851 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7852 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307853 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7854 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007855 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7856 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7857 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7858 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7859 { } /* end */
7860};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007861
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007862static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7863 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7864 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7865 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7866 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7867 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7868 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7869 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7870 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7871 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7872 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7873 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7874 { } /* end */
7875};
7876
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007877static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007878 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7879 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007880 { } /* end */
7881};
7882
7883
Kailang Yangbdd148a2007-05-08 15:19:08 +02007884static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7885 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7886 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7887 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7888 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7889 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7890 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7892 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7893 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007894 { } /* end */
7895};
7896
Kailang Yang272a5272007-05-14 11:00:38 +02007897static struct snd_kcontrol_new alc882_targa_mixer[] = {
7898 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7899 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7900 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7901 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7902 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7903 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7904 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7905 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7906 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007907 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007908 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7909 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007910 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007911 { } /* end */
7912};
7913
7914/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7915 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7916 */
7917static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7918 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7919 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7920 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7921 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7922 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7923 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7924 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7925 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7926 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7927 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7928 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7929 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007930 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007931 { } /* end */
7932};
7933
Takashi Iwai914759b2007-09-06 14:52:04 +02007934static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7935 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7936 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7937 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7938 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7939 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7940 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7941 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7942 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7943 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7944 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007945 { } /* end */
7946};
7947
Kailang Yangdf694da2005-12-05 19:42:22 +01007948static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7949 {
7950 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7951 .name = "Channel Mode",
7952 .info = alc_ch_mode_info,
7953 .get = alc_ch_mode_get,
7954 .put = alc_ch_mode_put,
7955 },
7956 { } /* end */
7957};
7958
Takashi Iwai4953550a2009-06-30 15:28:30 +02007959static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007960 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007961 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7962 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007963 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007964 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7965 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007966 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007967 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7968 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007969 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007970 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7971 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007972
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007973 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007974 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007975 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007976 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007977 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007978 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007979 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007980 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007981 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007982 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007983 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007984 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007985 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007986 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007987 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007988 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007989 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007990 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007991 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7992 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007993 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007994 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7995 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007996 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007997 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7998 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7999 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8000 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8001 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008002 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008003 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008004
8005 /* FIXME: use matrix-type input source selection */
8006 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008007 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008008 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008009 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008010 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008011 /* ADC2: mute amp left and right */
8012 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008013 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008014 /* ADC3: mute amp left and right */
8015 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008016 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008017
8018 { }
8019};
8020
Takashi Iwai4953550a2009-06-30 15:28:30 +02008021static struct hda_verb alc882_adc1_init_verbs[] = {
8022 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8023 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8024 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8025 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8026 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8027 /* ADC1: mute amp left and right */
8028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8029 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8030 { }
8031};
8032
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008033static struct hda_verb alc882_eapd_verbs[] = {
8034 /* change to EAPD mode */
8035 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008036 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008037 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008038};
8039
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008040static struct hda_verb alc889_eapd_verbs[] = {
8041 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8042 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8043 { }
8044};
8045
Wu Fengguang6732bd02009-07-30 09:19:14 +02008046static struct hda_verb alc_hp15_unsol_verbs[] = {
8047 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8048 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8049 {}
8050};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008051
8052static struct hda_verb alc885_init_verbs[] = {
8053 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008056 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008057 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8058 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008059 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008060 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8061 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008062 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008063 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8064 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008065
8066 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008067 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008068 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8069 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8070 /* Front Pin: output 0 (0x0c) */
8071 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8072 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8073 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8074 /* Rear Pin: output 1 (0x0d) */
8075 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8076 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8077 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8078 /* CLFE Pin: output 2 (0x0e) */
8079 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8080 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8081 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8082 /* Side Pin: output 3 (0x0f) */
8083 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8084 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8085 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8086 /* Mic (rear) pin: input vref at 80% */
8087 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8088 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8089 /* Front Mic pin: input vref at 80% */
8090 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8091 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8092 /* Line In pin: input */
8093 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8094 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8095
8096 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8097 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008098 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008099 /* Input mixer2 */
8100 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008101 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008102 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008103 /* ADC2: mute amp left and right */
8104 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8105 /* ADC3: mute amp left and right */
8106 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8107
8108 { }
8109};
8110
8111static struct hda_verb alc885_init_input_verbs[] = {
8112 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8113 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8114 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8115 { }
8116};
8117
8118
8119/* Unmute Selector 24h and set the default input to front mic */
8120static struct hda_verb alc889_init_input_verbs[] = {
8121 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8122 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8123 { }
8124};
8125
8126
Takashi Iwai4953550a2009-06-30 15:28:30 +02008127#define alc883_init_verbs alc882_base_init_verbs
8128
Tobin Davis9102cd12006-12-15 10:02:12 +01008129/* Mac Pro test */
8130static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8131 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8132 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8133 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8134 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8135 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008136 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008137 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8138 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008139 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008140 { } /* end */
8141};
8142
8143static struct hda_verb alc882_macpro_init_verbs[] = {
8144 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8145 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8146 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8147 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8148 /* Front Pin: output 0 (0x0c) */
8149 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8150 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8151 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8152 /* Front Mic pin: input vref at 80% */
8153 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8154 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8155 /* Speaker: output */
8156 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8157 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8158 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8159 /* Headphone output (output 0 - 0x0c) */
8160 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8161 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8162 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8163
8164 /* FIXME: use matrix-type input source selection */
8165 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8166 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8167 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8168 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8169 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8170 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8171 /* Input mixer2 */
8172 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8173 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8174 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8175 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8176 /* Input mixer3 */
8177 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8178 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8179 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8180 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8181 /* ADC1: mute amp left and right */
8182 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8183 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8184 /* ADC2: mute amp left and right */
8185 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8186 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8187 /* ADC3: mute amp left and right */
8188 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8189 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8190
8191 { }
8192};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008193
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008194/* Macbook 5,1 */
8195static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008196 /* DACs */
8197 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8198 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8199 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8200 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008201 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008202 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8203 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8204 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008205 /* Surround mixer */
8206 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8207 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8208 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8209 /* LFE mixer */
8210 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8211 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8212 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8213 /* HP mixer */
8214 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8215 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8216 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8217 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008218 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8219 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008220 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8221 /* LFE Pin (0x0e) */
8222 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8223 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8224 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8225 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008226 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8227 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008228 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308229 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008230 /* Front Mic pin: input vref at 80% */
8231 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8232 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8233 /* Line In pin */
8234 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8235 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8236
Alex Murrayb8f171e2010-06-14 12:08:43 +09308237 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8238 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8239 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008240 { }
8241};
8242
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008243/* Macmini 3,1 */
8244static struct hda_verb alc885_macmini3_init_verbs[] = {
8245 /* 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},
8250 /* Front mixer */
8251 {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)},
8254 /* 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) */
8267 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8268 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8269 {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) */
8275 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8276 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8277 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8278 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8279 /* Line In pin */
8280 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8281 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8282
8283 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8284 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8285 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8287 { }
8288};
8289
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008290
8291static struct hda_verb alc885_mba21_init_verbs[] = {
8292 /*Internal and HP Speaker Mixer*/
8293 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8294 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8295 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8296 /*Internal Speaker Pin (0x0c)*/
8297 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8298 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8299 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8300 /* HP Pin: output 0 (0x0e) */
8301 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8302 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8303 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8304 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8305 /* Line in (is hp when jack connected)*/
8306 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8307 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8308
8309 { }
8310 };
8311
8312
Takashi Iwai87350ad2007-08-16 18:19:38 +02008313/* Macbook Pro rev3 */
8314static struct hda_verb alc885_mbp3_init_verbs[] = {
8315 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8316 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8317 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8318 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8319 /* Rear mixer */
8320 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8321 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8322 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008323 /* HP mixer */
8324 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8326 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008327 /* Front Pin: output 0 (0x0c) */
8328 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8329 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8330 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008331 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008332 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008333 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8334 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008335 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8336 /* Mic (rear) pin: input vref at 80% */
8337 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8338 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8339 /* Front Mic pin: input vref at 80% */
8340 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8341 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8342 /* Line In pin: use output 1 when in LineOut mode */
8343 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8344 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8345 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8346
8347 /* FIXME: use matrix-type input source selection */
8348 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8349 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8350 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8351 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8352 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8353 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8354 /* Input mixer2 */
8355 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8356 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8357 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8358 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8359 /* Input mixer3 */
8360 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8361 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8362 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8363 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8364 /* ADC1: mute amp left and right */
8365 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8366 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8367 /* ADC2: mute amp left and right */
8368 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8369 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8370 /* ADC3: mute amp left and right */
8371 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8372 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8373
8374 { }
8375};
8376
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008377/* iMac 9,1 */
8378static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008379 /* Internal Speaker Pin (0x0c) */
8380 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8381 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8382 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8383 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8384 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8385 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8386 /* HP Pin: Rear */
8387 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8388 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8389 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8390 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8391 /* Line in Rear */
8392 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8393 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8394 /* Front Mic pin: input vref at 80% */
8395 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8396 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008397 /* Rear mixer */
8398 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8399 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8400 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008401 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8402 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8403 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8404 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8405 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008406 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8407 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8408 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8409 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008410 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008411 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8412 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8413 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8414 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008415 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008416 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8417 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8418 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8419 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008420 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008421 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8422 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008423 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008424 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8425 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008426 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008427 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8428 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008429 { }
8430};
8431
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008432/* iMac 24 mixer. */
8433static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8434 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8435 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8436 { } /* end */
8437};
8438
8439/* iMac 24 init verbs. */
8440static struct hda_verb alc885_imac24_init_verbs[] = {
8441 /* Internal speakers: output 0 (0x0c) */
8442 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8443 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8444 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8445 /* Internal speakers: output 0 (0x0c) */
8446 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8447 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8448 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8449 /* Headphone: output 0 (0x0c) */
8450 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8451 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8452 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8453 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8454 /* Front Mic: input vref at 80% */
8455 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8456 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8457 { }
8458};
8459
8460/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008461static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008462{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008463 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008464
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008465 spec->autocfg.hp_pins[0] = 0x14;
8466 spec->autocfg.speaker_pins[0] = 0x18;
8467 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008468}
8469
Takashi Iwai9d54f082010-02-22 08:34:40 +01008470#define alc885_mb5_setup alc885_imac24_setup
8471#define alc885_macmini3_setup alc885_imac24_setup
8472
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008473/* Macbook Air 2,1 */
8474static void alc885_mba21_setup(struct hda_codec *codec)
8475{
8476 struct alc_spec *spec = codec->spec;
8477
8478 spec->autocfg.hp_pins[0] = 0x14;
8479 spec->autocfg.speaker_pins[0] = 0x18;
8480}
8481
8482
8483
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008484static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008485{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008486 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008487
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008488 spec->autocfg.hp_pins[0] = 0x15;
8489 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008490}
8491
Takashi Iwai9d54f082010-02-22 08:34:40 +01008492static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308493{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008494 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308495
Takashi Iwai9d54f082010-02-22 08:34:40 +01008496 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008497 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008498 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008499}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008500
Kailang Yang272a5272007-05-14 11:00:38 +02008501static struct hda_verb alc882_targa_verbs[] = {
8502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8504
8505 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8506 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008507
Kailang Yang272a5272007-05-14 11:00:38 +02008508 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8509 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8510 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8511
8512 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008513 { } /* end */
8514};
8515
8516/* toggle speaker-output according to the hp-jack state */
8517static void alc882_targa_automute(struct hda_codec *codec)
8518{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008519 struct alc_spec *spec = codec->spec;
8520 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008521 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008522 spec->jack_present ? 1 : 3);
8523}
8524
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008525static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008526{
8527 struct alc_spec *spec = codec->spec;
8528
8529 spec->autocfg.hp_pins[0] = 0x14;
8530 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008531}
8532
8533static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8534{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008535 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008536 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008537}
8538
8539static struct hda_verb alc882_asus_a7j_verbs[] = {
8540 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8541 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8542
8543 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8544 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8545 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008546
Kailang Yang272a5272007-05-14 11:00:38 +02008547 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8548 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8549 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8550
8551 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8552 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8553 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8554 { } /* end */
8555};
8556
Takashi Iwai914759b2007-09-06 14:52:04 +02008557static struct hda_verb alc882_asus_a7m_verbs[] = {
8558 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8559 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8560
8561 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8562 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8563 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008564
Takashi Iwai914759b2007-09-06 14:52:04 +02008565 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8566 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8567 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8568
8569 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8570 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8571 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8572 { } /* end */
8573};
8574
Tobin Davis9102cd12006-12-15 10:02:12 +01008575static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8576{
8577 unsigned int gpiostate, gpiomask, gpiodir;
8578
8579 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8580 AC_VERB_GET_GPIO_DATA, 0);
8581
8582 if (!muted)
8583 gpiostate |= (1 << pin);
8584 else
8585 gpiostate &= ~(1 << pin);
8586
8587 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8588 AC_VERB_GET_GPIO_MASK, 0);
8589 gpiomask |= (1 << pin);
8590
8591 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8592 AC_VERB_GET_GPIO_DIRECTION, 0);
8593 gpiodir |= (1 << pin);
8594
8595
8596 snd_hda_codec_write(codec, codec->afg, 0,
8597 AC_VERB_SET_GPIO_MASK, gpiomask);
8598 snd_hda_codec_write(codec, codec->afg, 0,
8599 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8600
8601 msleep(1);
8602
8603 snd_hda_codec_write(codec, codec->afg, 0,
8604 AC_VERB_SET_GPIO_DATA, gpiostate);
8605}
8606
Takashi Iwai7debbe52007-08-16 15:01:03 +02008607/* set up GPIO at initialization */
8608static void alc885_macpro_init_hook(struct hda_codec *codec)
8609{
8610 alc882_gpio_mute(codec, 0, 0);
8611 alc882_gpio_mute(codec, 1, 0);
8612}
8613
8614/* set up GPIO and update auto-muting at initialization */
8615static void alc885_imac24_init_hook(struct hda_codec *codec)
8616{
8617 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008618 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008619}
8620
Kailang Yangdf694da2005-12-05 19:42:22 +01008621/*
8622 * generic initialization of ADC, input mixers and output mixers
8623 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008624static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008625 /*
8626 * Unmute ADC0-2 and set the default input to mic-in
8627 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008628 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8629 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8630 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8631 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8632
Kailang Yangdf694da2005-12-05 19:42:22 +01008633 /*
8634 * Set up output mixers (0x0c - 0x0f)
8635 */
8636 /* set vol=0 to output mixers */
8637 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8638 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8639 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8640 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8641 /* set up input amps for analog loopback */
8642 /* Amp Indices: DAC = 0, mixer = 1 */
8643 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8644 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8645 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8646 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8647 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8648 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8649 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8650 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8651 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8652 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8653
8654 /* FIXME: use matrix-type input source selection */
8655 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008656 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008657 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008658 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008659 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008660 { }
8661};
8662
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008663/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8664static struct hda_verb alc889A_mb31_ch2_init[] = {
8665 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8666 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8667 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8668 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8669 { } /* end */
8670};
8671
8672/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8673static struct hda_verb alc889A_mb31_ch4_init[] = {
8674 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8675 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8676 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8677 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8678 { } /* end */
8679};
8680
8681/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8682static struct hda_verb alc889A_mb31_ch5_init[] = {
8683 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8684 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8685 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8686 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8687 { } /* end */
8688};
8689
8690/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8691static struct hda_verb alc889A_mb31_ch6_init[] = {
8692 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8693 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8694 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8695 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8696 { } /* end */
8697};
8698
8699static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8700 { 2, alc889A_mb31_ch2_init },
8701 { 4, alc889A_mb31_ch4_init },
8702 { 5, alc889A_mb31_ch5_init },
8703 { 6, alc889A_mb31_ch6_init },
8704};
8705
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008706static struct hda_verb alc883_medion_eapd_verbs[] = {
8707 /* eanable EAPD on medion laptop */
8708 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8709 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8710 { }
8711};
8712
Takashi Iwai4953550a2009-06-30 15:28:30 +02008713#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008714
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008715static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8716 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8717 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8718 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8719 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8720 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8721 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8722 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8723 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8724 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8725 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8726 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8727 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8728 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008729 { } /* end */
8730};
8731
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008732static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008733 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8734 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8735 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8736 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8737 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8738 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8739 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8740 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8741 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8742 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008743 { } /* end */
8744};
8745
Jiang zhefb97dc62008-03-06 11:07:11 +01008746static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8747 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8748 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8749 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8750 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8751 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8752 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8753 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8754 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8755 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8756 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008757 { } /* end */
8758};
8759
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008760static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8761 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8762 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8763 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8764 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8765 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8766 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8767 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8768 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008769 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008770 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8771 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008772 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008773 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008774 { } /* end */
8775};
8776
8777static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8778 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8779 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8780 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8781 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8782 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8783 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8784 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8785 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8786 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8787 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8788 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8789 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8790 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8791 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008792 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008793 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8794 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008795 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008796 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008797 { } /* end */
8798};
8799
Jiang zhe17bba1b2008-06-04 12:11:07 +02008800static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8801 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8802 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8803 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8804 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8805 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8806 HDA_OUTPUT),
8807 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8808 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8809 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8810 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8811 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8812 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8813 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8814 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8815 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8816 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8817 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8818 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8819 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8820 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008821 { } /* end */
8822};
8823
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008824static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8825 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8826 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8827 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8828 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8829 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8830 HDA_OUTPUT),
8831 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8832 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8833 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8834 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8835 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8836 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8837 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8838 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8839 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8840 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8841 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8842 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8843 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8844 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8845 { } /* end */
8846};
8847
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008848static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008849 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008850 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008851 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008852 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008853 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8854 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008855 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8856 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008857 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8858 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8859 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8860 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8861 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8862 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008863 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008864 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8865 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008866 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008867 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008868 { } /* end */
8869};
8870
Sasha Alexandrc2592492009-06-16 14:52:54 -04008871static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008872 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008873 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008874 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008875 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008876 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, HDA_OUTPUT),
8879 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8880 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8881 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8882 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8883 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8884 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8885 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8886 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008887 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008888 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008889 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008890};
Kailang Yangccc656c2006-10-17 12:32:26 +02008891
Sasha Alexandrc2592492009-06-16 14:52:54 -04008892static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008893 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008894 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008895 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008896 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008897 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8898 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8899 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008900 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008901 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008902 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8903 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8904 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008905 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008906};
Kailang Yangccc656c2006-10-17 12:32:26 +02008907
Takashi Iwaib99dba32009-09-17 18:23:00 +02008908static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8909 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8910 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8911 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8912 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8913 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8914 { } /* end */
8915};
8916
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008917static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8918 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8919 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008920 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8921 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008922 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8923 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8924 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8925 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008926 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008927};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008928
Kailang Yang272a5272007-05-14 11:00:38 +02008929static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8930 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8931 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8932 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8933 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8934 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8936 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson150b4322010-07-29 14:46:42 +02008937 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8938 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008939 { } /* end */
8940};
8941
8942static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8943 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8944 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8945 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8946 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),
8949 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8950 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8951 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008952 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008953};
Kailang Yang272a5272007-05-14 11:00:38 +02008954
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02008955static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
8956 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8957 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8958 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8959 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
8960 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
8961 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
8962 { } /* end */
8963};
8964
8965static struct hda_verb alc883_medion_wim2160_verbs[] = {
8966 /* Unmute front mixer */
8967 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8968 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8969
8970 /* Set speaker pin to front mixer */
8971 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8972
8973 /* Init headphone pin */
8974 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8975 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8976 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8977 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8978
8979 { } /* end */
8980};
8981
8982/* toggle speaker-output according to the hp-jack state */
8983static void alc883_medion_wim2160_setup(struct hda_codec *codec)
8984{
8985 struct alc_spec *spec = codec->spec;
8986
8987 spec->autocfg.hp_pins[0] = 0x1a;
8988 spec->autocfg.speaker_pins[0] = 0x15;
8989}
8990
Tobin Davis2880a862007-08-07 11:50:26 +02008991static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008992 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8993 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008994 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008995 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8996 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8998 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009000 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009001};
Tobin Davis2880a862007-08-07 11:50:26 +02009002
Tony Vroond2fd4b02009-06-21 00:40:10 +01009003static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
9004 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009005 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009006 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9007 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009008 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9009 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9010 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9011 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9012 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9013 { } /* end */
9014};
9015
Kailang Yange2757d52008-08-26 13:17:46 +02009016static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
9017 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9018 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9019 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9020 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9021 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9022 0x0d, 1, 0x0, HDA_OUTPUT),
9023 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9024 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9025 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9026 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9027 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009028 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9029 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9030 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9031 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9032 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9033 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9034 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9035 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9036 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9037 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009038 { } /* end */
9039};
9040
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009041static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9042 /* Output mixers */
9043 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9044 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9045 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9046 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9047 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9048 HDA_OUTPUT),
9049 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9050 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9051 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9052 /* Output switches */
9053 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9054 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9055 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9056 /* Boost mixers */
9057 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
9058 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
9059 /* Input mixers */
9060 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9061 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9062 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9063 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9064 { } /* end */
9065};
9066
Guido Günther3e1647c52009-06-05 00:47:26 +02009067static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9068 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9069 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9070 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9071 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9072 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
9073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9074 { } /* end */
9075};
9076
Kailang Yange2757d52008-08-26 13:17:46 +02009077static struct hda_bind_ctls alc883_bind_cap_vol = {
9078 .ops = &snd_hda_bind_vol,
9079 .values = {
9080 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9081 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9082 0
9083 },
9084};
9085
9086static struct hda_bind_ctls alc883_bind_cap_switch = {
9087 .ops = &snd_hda_bind_sw,
9088 .values = {
9089 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9090 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9091 0
9092 },
9093};
9094
9095static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9096 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9097 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9098 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9099 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9100 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9101 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9102 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9103 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009104 { } /* end */
9105};
9106
9107static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009108 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9109 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9110 {
9111 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9112 /* .name = "Capture Source", */
9113 .name = "Input Source",
9114 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009115 .info = alc_mux_enum_info,
9116 .get = alc_mux_enum_get,
9117 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009118 },
9119 { } /* end */
9120};
9121
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009122static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9123 {
9124 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9125 .name = "Channel Mode",
9126 .info = alc_ch_mode_info,
9127 .get = alc_ch_mode_get,
9128 .put = alc_ch_mode_put,
9129 },
9130 { } /* end */
9131};
9132
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009133/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009134static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009135{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009136 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009137
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009138 spec->autocfg.hp_pins[0] = 0x15;
9139 spec->autocfg.speaker_pins[0] = 0x14;
9140 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009141}
9142
9143/* auto-toggle front mic */
9144/*
9145static void alc883_mitac_mic_automute(struct hda_codec *codec)
9146{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009147 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009148
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009149 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
9150}
9151*/
9152
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009153static struct hda_verb alc883_mitac_verbs[] = {
9154 /* HP */
9155 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9156 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9157 /* Subwoofer */
9158 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9159 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9160
9161 /* enable unsolicited event */
9162 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9163 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9164
9165 { } /* end */
9166};
9167
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309168static struct hda_verb alc883_clevo_m540r_verbs[] = {
9169 /* HP */
9170 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9171 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9172 /* Int speaker */
9173 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9174
9175 /* enable unsolicited event */
9176 /*
9177 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9178 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9179 */
9180
9181 { } /* end */
9182};
9183
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009184static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009185 /* HP */
9186 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9187 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9188 /* Int speaker */
9189 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9190 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9191
9192 /* enable unsolicited event */
9193 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009194 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009195
9196 { } /* end */
9197};
9198
Jiang zhefb97dc62008-03-06 11:07:11 +01009199static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9200 /* HP */
9201 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9202 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9203 /* Subwoofer */
9204 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9205 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9206
9207 /* enable unsolicited event */
9208 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9209
9210 { } /* end */
9211};
9212
Sasha Alexandrc2592492009-06-16 14:52:54 -04009213static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009214 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9215 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9216
9217 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9218 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009219
David Heidelberger64a8be72009-06-08 16:15:18 +02009220/* Connect Line-Out side jack (SPDIF) to Side */
9221 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9222 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9223 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9224/* Connect Mic jack to CLFE */
9225 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9226 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9227 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9228/* Connect Line-in jack to Surround */
9229 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9230 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9231 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9232/* Connect HP out jack to Front */
9233 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9234 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9235 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009236
9237 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009238
9239 { } /* end */
9240};
9241
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009242static struct hda_verb alc883_lenovo_101e_verbs[] = {
9243 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9244 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9245 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9246 { } /* end */
9247};
9248
Kailang Yang272a5272007-05-14 11:00:38 +02009249static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9250 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9251 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9252 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9253 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9254 { } /* end */
9255};
9256
9257static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9258 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9259 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9260 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9261 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9262 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9263 { } /* end */
9264};
9265
Kailang Yang189609a2007-08-20 11:31:23 +02009266static struct hda_verb alc883_haier_w66_verbs[] = {
9267 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9268 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9269
9270 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9271
9272 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9273 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9274 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9275 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9276 { } /* end */
9277};
9278
Kailang Yange2757d52008-08-26 13:17:46 +02009279static struct hda_verb alc888_lenovo_sky_verbs[] = {
9280 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9281 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9282 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9283 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9284 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9285 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9286 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9287 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9288 { } /* end */
9289};
9290
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009291static struct hda_verb alc888_6st_dell_verbs[] = {
9292 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9293 { }
9294};
9295
Guido Günther3e1647c52009-06-05 00:47:26 +02009296static struct hda_verb alc883_vaiott_verbs[] = {
9297 /* HP */
9298 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9299 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9300
9301 /* enable unsolicited event */
9302 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9303
9304 { } /* end */
9305};
9306
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009307static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009308{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009309 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009310
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009311 spec->autocfg.hp_pins[0] = 0x1b;
9312 spec->autocfg.speaker_pins[0] = 0x14;
9313 spec->autocfg.speaker_pins[1] = 0x16;
9314 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009315}
9316
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009317static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009318 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009319 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9320 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009321 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009322 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009323};
9324
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009325/*
9326 * 2ch mode
9327 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009328static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009329 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9330 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9331 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9332 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009333 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009334};
9335
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009336/*
9337 * 4ch mode
9338 */
9339static struct hda_verb alc888_3st_hp_4ch_init[] = {
9340 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9341 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9342 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9343 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9344 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9345 { } /* end */
9346};
9347
9348/*
9349 * 6ch mode
9350 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009351static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009352 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9353 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009354 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009355 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9356 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009357 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9358 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009359};
9360
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009361static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009362 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009363 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009364 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009365};
9366
Kailang Yang272a5272007-05-14 11:00:38 +02009367/* toggle front-jack and RCA according to the hp-jack state */
9368static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9369{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009370 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009371
Takashi Iwai47fd8302007-08-10 17:11:07 +02009372 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9373 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9374 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9375 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009376}
9377
9378/* toggle RCA according to the front-jack state */
9379static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9380{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009381 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009382
Takashi Iwai47fd8302007-08-10 17:11:07 +02009383 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9384 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009385}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009386
Kailang Yang272a5272007-05-14 11:00:38 +02009387static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9388 unsigned int res)
9389{
9390 if ((res >> 26) == ALC880_HP_EVENT)
9391 alc888_lenovo_ms7195_front_automute(codec);
9392 if ((res >> 26) == ALC880_FRONT_EVENT)
9393 alc888_lenovo_ms7195_rca_automute(codec);
9394}
9395
9396static struct hda_verb alc883_medion_md2_verbs[] = {
9397 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9398 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9399
9400 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9401
9402 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9403 { } /* end */
9404};
9405
9406/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009407static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009408{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009409 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009410
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009411 spec->autocfg.hp_pins[0] = 0x14;
9412 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009413}
9414
Kailang Yangccc656c2006-10-17 12:32:26 +02009415/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009416#define alc883_targa_init_hook alc882_targa_init_hook
9417#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009418
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009419static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
9420{
9421 unsigned int present;
9422
Takashi Iwaid56757a2009-11-18 08:00:14 +01009423 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009424 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
9425 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9426}
9427
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009428static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009429{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009430 struct alc_spec *spec = codec->spec;
9431
9432 spec->autocfg.hp_pins[0] = 0x15;
9433 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009434}
9435
9436static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9437{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009438 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009439 alc883_clevo_m720_mic_automute(codec);
9440}
9441
9442static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009443 unsigned int res)
9444{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009445 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009446 case ALC880_MIC_EVENT:
9447 alc883_clevo_m720_mic_automute(codec);
9448 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009449 default:
9450 alc_automute_amp_unsol_event(codec, res);
9451 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009452 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009453}
9454
Jiang zhefb97dc62008-03-06 11:07:11 +01009455/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009456static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009457{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009458 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009459
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009460 spec->autocfg.hp_pins[0] = 0x14;
9461 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009462}
9463
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009464static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009465{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009466 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009467
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009468 spec->autocfg.hp_pins[0] = 0x1b;
9469 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009470}
9471
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009472static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9473{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009474 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009475
Takashi Iwai47fd8302007-08-10 17:11:07 +02009476 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9477 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009478}
9479
9480static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9481{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009482 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009483
Takashi Iwai47fd8302007-08-10 17:11:07 +02009484 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9485 HDA_AMP_MUTE, bits);
9486 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9487 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009488}
9489
9490static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9491 unsigned int res)
9492{
9493 if ((res >> 26) == ALC880_HP_EVENT)
9494 alc883_lenovo_101e_all_automute(codec);
9495 if ((res >> 26) == ALC880_FRONT_EVENT)
9496 alc883_lenovo_101e_ispeaker_automute(codec);
9497}
9498
Takashi Iwai676a9b52007-08-16 15:23:35 +02009499/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009500static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009501{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009502 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009503
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009504 spec->autocfg.hp_pins[0] = 0x14;
9505 spec->autocfg.speaker_pins[0] = 0x15;
9506 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009507}
9508
Kailang Yangd1a991a2007-08-15 16:21:59 +02009509static struct hda_verb alc883_acer_eapd_verbs[] = {
9510 /* HP Pin: output 0 (0x0c) */
9511 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9512 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9513 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9514 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009515 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9516 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009517 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009518 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9519 /* eanable EAPD on medion laptop */
9520 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9521 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009522 /* enable unsolicited event */
9523 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009524 { }
9525};
9526
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009527static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
9528 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9529 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9530 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9531 { } /* end */
9532};
9533
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009534static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009535{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009536 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009537
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009538 spec->autocfg.hp_pins[0] = 0x1b;
9539 spec->autocfg.speaker_pins[0] = 0x14;
9540 spec->autocfg.speaker_pins[1] = 0x15;
9541 spec->autocfg.speaker_pins[2] = 0x16;
9542 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009543}
9544
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009545static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009546{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009547 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009548
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009549 spec->autocfg.hp_pins[0] = 0x1b;
9550 spec->autocfg.speaker_pins[0] = 0x14;
9551 spec->autocfg.speaker_pins[1] = 0x15;
9552 spec->autocfg.speaker_pins[2] = 0x16;
9553 spec->autocfg.speaker_pins[3] = 0x17;
9554 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009555}
9556
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009557static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c52009-06-05 00:47:26 +02009558{
9559 struct alc_spec *spec = codec->spec;
9560
9561 spec->autocfg.hp_pins[0] = 0x15;
9562 spec->autocfg.speaker_pins[0] = 0x14;
9563 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c52009-06-05 00:47:26 +02009564}
9565
Kailang Yange2757d52008-08-26 13:17:46 +02009566static struct hda_verb alc888_asus_m90v_verbs[] = {
9567 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9568 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9569 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9570 /* enable unsolicited event */
9571 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9572 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9573 { } /* end */
9574};
9575
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009576static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009577{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009578 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009579
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009580 spec->autocfg.hp_pins[0] = 0x1b;
9581 spec->autocfg.speaker_pins[0] = 0x14;
9582 spec->autocfg.speaker_pins[1] = 0x15;
9583 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009584 spec->ext_mic.pin = 0x18;
9585 spec->int_mic.pin = 0x19;
9586 spec->ext_mic.mux_idx = 0;
9587 spec->int_mic.mux_idx = 1;
9588 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009589}
9590
9591static struct hda_verb alc888_asus_eee1601_verbs[] = {
9592 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9593 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9594 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9595 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9596 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9597 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9598 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9599 /* enable unsolicited event */
9600 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9601 { } /* end */
9602};
9603
Kailang Yange2757d52008-08-26 13:17:46 +02009604static void alc883_eee1601_inithook(struct hda_codec *codec)
9605{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009606 struct alc_spec *spec = codec->spec;
9607
9608 spec->autocfg.hp_pins[0] = 0x14;
9609 spec->autocfg.speaker_pins[0] = 0x1b;
9610 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009611}
9612
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009613static struct hda_verb alc889A_mb31_verbs[] = {
9614 /* Init rear pin (used as headphone output) */
9615 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9616 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9617 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9618 /* Init line pin (used as output in 4ch and 6ch mode) */
9619 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9620 /* Init line 2 pin (used as headphone out by default) */
9621 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9622 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9623 { } /* end */
9624};
9625
9626/* Mute speakers according to the headphone jack state */
9627static void alc889A_mb31_automute(struct hda_codec *codec)
9628{
9629 unsigned int present;
9630
9631 /* Mute only in 2ch or 4ch mode */
9632 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9633 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009634 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009635 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9636 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9637 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9638 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9639 }
9640}
9641
9642static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9643{
9644 if ((res >> 26) == ALC880_HP_EVENT)
9645 alc889A_mb31_automute(codec);
9646}
9647
Takashi Iwai4953550a2009-06-30 15:28:30 +02009648
Takashi Iwaicb53c622007-08-10 17:21:45 +02009649#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009650#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009651#endif
9652
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009653/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009654#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9655#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9656#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9657#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9658
9659static hda_nid_t alc883_slave_dig_outs[] = {
9660 ALC1200_DIGOUT_NID, 0,
9661};
9662
9663static hda_nid_t alc1200_slave_dig_outs[] = {
9664 ALC883_DIGOUT_NID, 0,
9665};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009666
9667/*
9668 * configuration and preset
9669 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009670static const char *alc882_models[ALC882_MODEL_LAST] = {
9671 [ALC882_3ST_DIG] = "3stack-dig",
9672 [ALC882_6ST_DIG] = "6stack-dig",
9673 [ALC882_ARIMA] = "arima",
9674 [ALC882_W2JC] = "w2jc",
9675 [ALC882_TARGA] = "targa",
9676 [ALC882_ASUS_A7J] = "asus-a7j",
9677 [ALC882_ASUS_A7M] = "asus-a7m",
9678 [ALC885_MACPRO] = "macpro",
9679 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009680 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009681 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009682 [ALC885_MBP3] = "mbp3",
9683 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009684 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009685 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009686 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9687 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009688 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009689 [ALC883_TARGA_DIG] = "targa-dig",
9690 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009691 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009692 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009693 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009694 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009695 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009696 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009697 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009698 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009699 [ALC883_MEDION_MD2] = "medion-md2",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009700 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009701 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009702 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009703 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9704 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009705 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009706 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009707 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009708 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009709 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309710 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009711 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009712 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009713 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009714 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009715 [ALC889A_INTEL] = "intel-alc889a",
9716 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009717 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009718 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c52009-06-05 00:47:26 +02009719 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009720 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009721};
9722
Takashi Iwai4953550a2009-06-30 15:28:30 +02009723static struct snd_pci_quirk alc882_cfg_tbl[] = {
9724 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9725
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009726 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009727 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009728 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009729 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9730 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009731 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009732 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9733 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009734 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009735 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009736 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9737 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009738 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9739 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009740 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9741 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009742 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009743 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009744 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009745 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009746 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9747 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009748 /* default Acer -- disabled as it causes more problems.
9749 * model=auto should work fine now
9750 */
9751 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009752
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009753 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009754
Tobin Davisfebe3372007-06-12 11:27:46 +02009755 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009756 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9757 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009758 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009759 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009760 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009761
9762 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9763 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9764 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009765 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009766 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9767 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9768 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009769 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009770 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009771 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009772 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009773
9774 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009775 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009776 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009777 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009778 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9779 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009780 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009781 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009782 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9783
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009784 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9785 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9786 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009787 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009788 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009789 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009790 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009791 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009792 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9793 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9794 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9795 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9796 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9797 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009798 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009799 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9800 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9801 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009802 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009803 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009804 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9805 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009806 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009807 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009808 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009809 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009810 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009811 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009812 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009813 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009814 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009815
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009816 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009817 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009818 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9819 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309820 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009821 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009822 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009823 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009824 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009825 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009826 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009827 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009828 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009829 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009830 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009831 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9832 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009833 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009834 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009835 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009836 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009837 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009838
Jiang zhe17bba1b2008-06-04 12:11:07 +02009839 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9840 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009841 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009842 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9843 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9844 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009845 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009846
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009847 {}
9848};
9849
Takashi Iwai4953550a2009-06-30 15:28:30 +02009850/* codec SSID table for Intel Mac */
9851static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9852 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9853 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9854 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9855 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9856 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9857 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9858 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009859 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009860 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009861 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009862 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009863 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9864 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9865 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009866 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009867 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009868 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009869 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9870 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009871 */
9872 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009873 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009874 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009875 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009876};
9877
Takashi Iwai4953550a2009-06-30 15:28:30 +02009878static struct alc_config_preset alc882_presets[] = {
9879 [ALC882_3ST_DIG] = {
9880 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009881 .init_verbs = { alc882_base_init_verbs,
9882 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009883 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9884 .dac_nids = alc882_dac_nids,
9885 .dig_out_nid = ALC882_DIGOUT_NID,
9886 .dig_in_nid = ALC882_DIGIN_NID,
9887 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9888 .channel_mode = alc882_ch_modes,
9889 .need_dac_fix = 1,
9890 .input_mux = &alc882_capture_source,
9891 },
9892 [ALC882_6ST_DIG] = {
9893 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009894 .init_verbs = { alc882_base_init_verbs,
9895 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009896 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9897 .dac_nids = alc882_dac_nids,
9898 .dig_out_nid = ALC882_DIGOUT_NID,
9899 .dig_in_nid = ALC882_DIGIN_NID,
9900 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9901 .channel_mode = alc882_sixstack_modes,
9902 .input_mux = &alc882_capture_source,
9903 },
9904 [ALC882_ARIMA] = {
9905 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009906 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9907 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009908 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9909 .dac_nids = alc882_dac_nids,
9910 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9911 .channel_mode = alc882_sixstack_modes,
9912 .input_mux = &alc882_capture_source,
9913 },
9914 [ALC882_W2JC] = {
9915 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009916 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9917 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009918 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9919 .dac_nids = alc882_dac_nids,
9920 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9921 .channel_mode = alc880_threestack_modes,
9922 .need_dac_fix = 1,
9923 .input_mux = &alc882_capture_source,
9924 .dig_out_nid = ALC882_DIGOUT_NID,
9925 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009926 [ALC885_MBA21] = {
9927 .mixers = { alc885_mba21_mixer },
9928 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9929 .num_dacs = 2,
9930 .dac_nids = alc882_dac_nids,
9931 .channel_mode = alc885_mba21_ch_modes,
9932 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9933 .input_mux = &alc882_capture_source,
9934 .unsol_event = alc_automute_amp_unsol_event,
9935 .setup = alc885_mba21_setup,
9936 .init_hook = alc_automute_amp,
9937 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009938 [ALC885_MBP3] = {
9939 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9940 .init_verbs = { alc885_mbp3_init_verbs,
9941 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009942 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009943 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009944 .hp_nid = 0x04,
9945 .channel_mode = alc885_mbp_4ch_modes,
9946 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009947 .input_mux = &alc882_capture_source,
9948 .dig_out_nid = ALC882_DIGOUT_NID,
9949 .dig_in_nid = ALC882_DIGIN_NID,
9950 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009951 .setup = alc885_mbp3_setup,
9952 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009953 },
9954 [ALC885_MB5] = {
9955 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9956 .init_verbs = { alc885_mb5_init_verbs,
9957 alc880_gpio1_init_verbs },
9958 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9959 .dac_nids = alc882_dac_nids,
9960 .channel_mode = alc885_mb5_6ch_modes,
9961 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9962 .input_mux = &mb5_capture_source,
9963 .dig_out_nid = ALC882_DIGOUT_NID,
9964 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009965 .unsol_event = alc_automute_amp_unsol_event,
9966 .setup = alc885_mb5_setup,
9967 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009968 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009969 [ALC885_MACMINI3] = {
9970 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9971 .init_verbs = { alc885_macmini3_init_verbs,
9972 alc880_gpio1_init_verbs },
9973 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9974 .dac_nids = alc882_dac_nids,
9975 .channel_mode = alc885_macmini3_6ch_modes,
9976 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9977 .input_mux = &macmini3_capture_source,
9978 .dig_out_nid = ALC882_DIGOUT_NID,
9979 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009980 .unsol_event = alc_automute_amp_unsol_event,
9981 .setup = alc885_macmini3_setup,
9982 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009983 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009984 [ALC885_MACPRO] = {
9985 .mixers = { alc882_macpro_mixer },
9986 .init_verbs = { alc882_macpro_init_verbs },
9987 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9988 .dac_nids = alc882_dac_nids,
9989 .dig_out_nid = ALC882_DIGOUT_NID,
9990 .dig_in_nid = ALC882_DIGIN_NID,
9991 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9992 .channel_mode = alc882_ch_modes,
9993 .input_mux = &alc882_capture_source,
9994 .init_hook = alc885_macpro_init_hook,
9995 },
9996 [ALC885_IMAC24] = {
9997 .mixers = { alc885_imac24_mixer },
9998 .init_verbs = { alc885_imac24_init_verbs },
9999 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10000 .dac_nids = alc882_dac_nids,
10001 .dig_out_nid = ALC882_DIGOUT_NID,
10002 .dig_in_nid = ALC882_DIGIN_NID,
10003 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10004 .channel_mode = alc882_ch_modes,
10005 .input_mux = &alc882_capture_source,
10006 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010007 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010008 .init_hook = alc885_imac24_init_hook,
10009 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010010 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010011 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010012 .init_verbs = { alc885_imac91_init_verbs,
10013 alc880_gpio1_init_verbs },
10014 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10015 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010016 .channel_mode = alc885_mba21_ch_modes,
10017 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10018 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010019 .dig_out_nid = ALC882_DIGOUT_NID,
10020 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010021 .unsol_event = alc_automute_amp_unsol_event,
10022 .setup = alc885_imac91_setup,
10023 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010024 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010025 [ALC882_TARGA] = {
10026 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010027 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010028 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010029 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10030 .dac_nids = alc882_dac_nids,
10031 .dig_out_nid = ALC882_DIGOUT_NID,
10032 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10033 .adc_nids = alc882_adc_nids,
10034 .capsrc_nids = alc882_capsrc_nids,
10035 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10036 .channel_mode = alc882_3ST_6ch_modes,
10037 .need_dac_fix = 1,
10038 .input_mux = &alc882_capture_source,
10039 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010040 .setup = alc882_targa_setup,
10041 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010042 },
10043 [ALC882_ASUS_A7J] = {
10044 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010045 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10046 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010047 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10048 .dac_nids = alc882_dac_nids,
10049 .dig_out_nid = ALC882_DIGOUT_NID,
10050 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10051 .adc_nids = alc882_adc_nids,
10052 .capsrc_nids = alc882_capsrc_nids,
10053 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10054 .channel_mode = alc882_3ST_6ch_modes,
10055 .need_dac_fix = 1,
10056 .input_mux = &alc882_capture_source,
10057 },
10058 [ALC882_ASUS_A7M] = {
10059 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010060 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10061 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010062 alc882_asus_a7m_verbs },
10063 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10064 .dac_nids = alc882_dac_nids,
10065 .dig_out_nid = ALC882_DIGOUT_NID,
10066 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10067 .channel_mode = alc880_threestack_modes,
10068 .need_dac_fix = 1,
10069 .input_mux = &alc882_capture_source,
10070 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010071 [ALC883_3ST_2ch_DIG] = {
10072 .mixers = { alc883_3ST_2ch_mixer },
10073 .init_verbs = { alc883_init_verbs },
10074 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10075 .dac_nids = alc883_dac_nids,
10076 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010077 .dig_in_nid = ALC883_DIGIN_NID,
10078 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10079 .channel_mode = alc883_3ST_2ch_modes,
10080 .input_mux = &alc883_capture_source,
10081 },
10082 [ALC883_3ST_6ch_DIG] = {
10083 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10084 .init_verbs = { alc883_init_verbs },
10085 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10086 .dac_nids = alc883_dac_nids,
10087 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010088 .dig_in_nid = ALC883_DIGIN_NID,
10089 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10090 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010091 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010092 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010093 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010094 [ALC883_3ST_6ch] = {
10095 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10096 .init_verbs = { alc883_init_verbs },
10097 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10098 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010099 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10100 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010101 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010102 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010103 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010104 [ALC883_3ST_6ch_INTEL] = {
10105 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10106 .init_verbs = { alc883_init_verbs },
10107 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10108 .dac_nids = alc883_dac_nids,
10109 .dig_out_nid = ALC883_DIGOUT_NID,
10110 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010111 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010112 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10113 .channel_mode = alc883_3ST_6ch_intel_modes,
10114 .need_dac_fix = 1,
10115 .input_mux = &alc883_3stack_6ch_intel,
10116 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010117 [ALC889A_INTEL] = {
10118 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010119 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10120 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010121 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10122 .dac_nids = alc883_dac_nids,
10123 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10124 .adc_nids = alc889_adc_nids,
10125 .dig_out_nid = ALC883_DIGOUT_NID,
10126 .dig_in_nid = ALC883_DIGIN_NID,
10127 .slave_dig_outs = alc883_slave_dig_outs,
10128 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10129 .channel_mode = alc889_8ch_intel_modes,
10130 .capsrc_nids = alc889_capsrc_nids,
10131 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010132 .setup = alc889_automute_setup,
10133 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010134 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010135 .need_dac_fix = 1,
10136 },
10137 [ALC889_INTEL] = {
10138 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10139 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010140 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010141 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10142 .dac_nids = alc883_dac_nids,
10143 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10144 .adc_nids = alc889_adc_nids,
10145 .dig_out_nid = ALC883_DIGOUT_NID,
10146 .dig_in_nid = ALC883_DIGIN_NID,
10147 .slave_dig_outs = alc883_slave_dig_outs,
10148 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10149 .channel_mode = alc889_8ch_intel_modes,
10150 .capsrc_nids = alc889_capsrc_nids,
10151 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010152 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010153 .init_hook = alc889_intel_init_hook,
10154 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010155 .need_dac_fix = 1,
10156 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010157 [ALC883_6ST_DIG] = {
10158 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10159 .init_verbs = { alc883_init_verbs },
10160 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10161 .dac_nids = alc883_dac_nids,
10162 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010163 .dig_in_nid = ALC883_DIGIN_NID,
10164 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10165 .channel_mode = alc883_sixstack_modes,
10166 .input_mux = &alc883_capture_source,
10167 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010168 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010169 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010170 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10171 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010172 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10173 .dac_nids = alc883_dac_nids,
10174 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010175 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10176 .channel_mode = alc883_3ST_6ch_modes,
10177 .need_dac_fix = 1,
10178 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010179 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010180 .setup = alc882_targa_setup,
10181 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010182 },
10183 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010184 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010185 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10186 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010187 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10188 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010189 .adc_nids = alc883_adc_nids_alt,
10190 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010191 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010192 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010193 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10194 .channel_mode = alc883_3ST_2ch_modes,
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 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010200 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010201 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10202 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010203 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010204 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010205 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10206 .dac_nids = alc883_dac_nids,
10207 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10208 .adc_nids = alc883_adc_nids_rev,
10209 .capsrc_nids = alc883_capsrc_nids_rev,
10210 .dig_out_nid = ALC883_DIGOUT_NID,
10211 .dig_in_nid = ALC883_DIGIN_NID,
10212 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10213 .channel_mode = alc883_4ST_8ch_modes,
10214 .need_dac_fix = 1,
10215 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010216 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010217 .setup = alc882_targa_setup,
10218 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010219 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010220 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010221 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010222 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10223 * and the headphone jack. Turn this on and rely on the
10224 * standard mute methods whenever the user wants to turn
10225 * these outputs off.
10226 */
10227 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10228 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10229 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010230 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10231 .channel_mode = alc883_3ST_2ch_modes,
10232 .input_mux = &alc883_capture_source,
10233 },
Tobin Davis2880a862007-08-07 11:50:26 +020010234 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010235 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010236 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010237 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10238 .dac_nids = alc883_dac_nids,
10239 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010240 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10241 .channel_mode = alc883_3ST_2ch_modes,
10242 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010243 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010244 .setup = alc883_acer_aspire_setup,
10245 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010246 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010247 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010248 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010249 alc883_chmode_mixer },
10250 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10251 alc888_acer_aspire_4930g_verbs },
10252 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10253 .dac_nids = alc883_dac_nids,
10254 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10255 .adc_nids = alc883_adc_nids_rev,
10256 .capsrc_nids = alc883_capsrc_nids_rev,
10257 .dig_out_nid = ALC883_DIGOUT_NID,
10258 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10259 .channel_mode = alc883_3ST_6ch_modes,
10260 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010261 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010262 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010263 ARRAY_SIZE(alc888_2_capture_sources),
10264 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010265 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010266 .setup = alc888_acer_aspire_4930g_setup,
10267 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010268 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010269 [ALC888_ACER_ASPIRE_6530G] = {
10270 .mixers = { alc888_acer_aspire_6530_mixer },
10271 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10272 alc888_acer_aspire_6530g_verbs },
10273 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10274 .dac_nids = alc883_dac_nids,
10275 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10276 .adc_nids = alc883_adc_nids_rev,
10277 .capsrc_nids = alc883_capsrc_nids_rev,
10278 .dig_out_nid = ALC883_DIGOUT_NID,
10279 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10280 .channel_mode = alc883_3ST_2ch_modes,
10281 .num_mux_defs =
10282 ARRAY_SIZE(alc888_2_capture_sources),
10283 .input_mux = alc888_acer_aspire_6530_sources,
10284 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010285 .setup = alc888_acer_aspire_6530g_setup,
10286 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010287 },
Hector Martin3b315d72009-06-02 10:54:19 +020010288 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010289 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010290 alc883_chmode_mixer },
10291 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010292 alc889_acer_aspire_8930g_verbs,
10293 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010294 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10295 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010296 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10297 .adc_nids = alc889_adc_nids,
10298 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010299 .dig_out_nid = ALC883_DIGOUT_NID,
10300 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10301 .channel_mode = alc883_3ST_6ch_modes,
10302 .need_dac_fix = 1,
10303 .const_channel_count = 6,
10304 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010305 ARRAY_SIZE(alc889_capture_sources),
10306 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010307 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010308 .setup = alc889_acer_aspire_8930g_setup,
10309 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010310#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010311 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010312#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010313 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010314 [ALC888_ACER_ASPIRE_7730G] = {
10315 .mixers = { alc883_3ST_6ch_mixer,
10316 alc883_chmode_mixer },
10317 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10318 alc888_acer_aspire_7730G_verbs },
10319 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10320 .dac_nids = alc883_dac_nids,
10321 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10322 .adc_nids = alc883_adc_nids_rev,
10323 .capsrc_nids = alc883_capsrc_nids_rev,
10324 .dig_out_nid = ALC883_DIGOUT_NID,
10325 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10326 .channel_mode = alc883_3ST_6ch_modes,
10327 .need_dac_fix = 1,
10328 .const_channel_count = 6,
10329 .input_mux = &alc883_capture_source,
10330 .unsol_event = alc_automute_amp_unsol_event,
10331 .setup = alc888_acer_aspire_6530g_setup,
10332 .init_hook = alc_automute_amp,
10333 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010334 [ALC883_MEDION] = {
10335 .mixers = { alc883_fivestack_mixer,
10336 alc883_chmode_mixer },
10337 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010338 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010339 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10340 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010341 .adc_nids = alc883_adc_nids_alt,
10342 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010343 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010344 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10345 .channel_mode = alc883_sixstack_modes,
10346 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010347 },
Kailang Yang272a5272007-05-14 11:00:38 +020010348 [ALC883_MEDION_MD2] = {
10349 .mixers = { alc883_medion_md2_mixer},
10350 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
10351 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10352 .dac_nids = alc883_dac_nids,
10353 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010354 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10355 .channel_mode = alc883_3ST_2ch_modes,
10356 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010357 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010358 .setup = alc883_medion_md2_setup,
10359 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020010360 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010361 [ALC883_MEDION_WIM2160] = {
10362 .mixers = { alc883_medion_wim2160_mixer },
10363 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10364 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10365 .dac_nids = alc883_dac_nids,
10366 .dig_out_nid = ALC883_DIGOUT_NID,
10367 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10368 .adc_nids = alc883_adc_nids,
10369 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10370 .channel_mode = alc883_3ST_2ch_modes,
10371 .input_mux = &alc883_capture_source,
10372 .unsol_event = alc_automute_amp_unsol_event,
10373 .setup = alc883_medion_wim2160_setup,
10374 .init_hook = alc_automute_amp,
10375 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010376 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010377 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010378 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10379 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10380 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010381 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10382 .channel_mode = alc883_3ST_2ch_modes,
10383 .input_mux = &alc883_capture_source,
10384 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010385 [ALC883_CLEVO_M540R] = {
10386 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10387 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10388 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10389 .dac_nids = alc883_dac_nids,
10390 .dig_out_nid = ALC883_DIGOUT_NID,
10391 .dig_in_nid = ALC883_DIGIN_NID,
10392 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10393 .channel_mode = alc883_3ST_6ch_clevo_modes,
10394 .need_dac_fix = 1,
10395 .input_mux = &alc883_capture_source,
10396 /* This machine has the hardware HP auto-muting, thus
10397 * we need no software mute via unsol event
10398 */
10399 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010400 [ALC883_CLEVO_M720] = {
10401 .mixers = { alc883_clevo_m720_mixer },
10402 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010403 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10404 .dac_nids = alc883_dac_nids,
10405 .dig_out_nid = ALC883_DIGOUT_NID,
10406 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10407 .channel_mode = alc883_3ST_2ch_modes,
10408 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010409 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010410 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010411 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010412 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010413 [ALC883_LENOVO_101E_2ch] = {
10414 .mixers = { alc883_lenovo_101e_2ch_mixer},
10415 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10416 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10417 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010418 .adc_nids = alc883_adc_nids_alt,
10419 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010420 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010421 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10422 .channel_mode = alc883_3ST_2ch_modes,
10423 .input_mux = &alc883_lenovo_101e_capture_source,
10424 .unsol_event = alc883_lenovo_101e_unsol_event,
10425 .init_hook = alc883_lenovo_101e_all_automute,
10426 },
Kailang Yang272a5272007-05-14 11:00:38 +020010427 [ALC883_LENOVO_NB0763] = {
10428 .mixers = { alc883_lenovo_nb0763_mixer },
10429 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10430 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10431 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010432 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10433 .channel_mode = alc883_3ST_2ch_modes,
10434 .need_dac_fix = 1,
10435 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010436 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010437 .setup = alc883_medion_md2_setup,
10438 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010439 },
10440 [ALC888_LENOVO_MS7195_DIG] = {
10441 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10442 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10443 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10444 .dac_nids = alc883_dac_nids,
10445 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010446 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10447 .channel_mode = alc883_3ST_6ch_modes,
10448 .need_dac_fix = 1,
10449 .input_mux = &alc883_capture_source,
10450 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10451 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010452 },
10453 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010454 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010455 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10456 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10457 .dac_nids = alc883_dac_nids,
10458 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010459 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10460 .channel_mode = alc883_3ST_2ch_modes,
10461 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010462 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010463 .setup = alc883_haier_w66_setup,
10464 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010465 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010466 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010467 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010468 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010469 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10470 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010471 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10472 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010473 .need_dac_fix = 1,
10474 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010475 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010476 .setup = alc888_3st_hp_setup,
10477 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010478 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010479 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010480 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010481 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10482 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10483 .dac_nids = alc883_dac_nids,
10484 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010485 .dig_in_nid = ALC883_DIGIN_NID,
10486 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10487 .channel_mode = alc883_sixstack_modes,
10488 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010489 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010490 .setup = alc888_6st_dell_setup,
10491 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010492 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010493 [ALC883_MITAC] = {
10494 .mixers = { alc883_mitac_mixer },
10495 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10496 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10497 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010498 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10499 .channel_mode = alc883_3ST_2ch_modes,
10500 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010501 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010502 .setup = alc883_mitac_setup,
10503 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010504 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010505 [ALC883_FUJITSU_PI2515] = {
10506 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10507 .init_verbs = { alc883_init_verbs,
10508 alc883_2ch_fujitsu_pi2515_verbs},
10509 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10510 .dac_nids = alc883_dac_nids,
10511 .dig_out_nid = ALC883_DIGOUT_NID,
10512 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10513 .channel_mode = alc883_3ST_2ch_modes,
10514 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010515 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010516 .setup = alc883_2ch_fujitsu_pi2515_setup,
10517 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010518 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010519 [ALC888_FUJITSU_XA3530] = {
10520 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10521 .init_verbs = { alc883_init_verbs,
10522 alc888_fujitsu_xa3530_verbs },
10523 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10524 .dac_nids = alc883_dac_nids,
10525 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10526 .adc_nids = alc883_adc_nids_rev,
10527 .capsrc_nids = alc883_capsrc_nids_rev,
10528 .dig_out_nid = ALC883_DIGOUT_NID,
10529 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10530 .channel_mode = alc888_4ST_8ch_intel_modes,
10531 .num_mux_defs =
10532 ARRAY_SIZE(alc888_2_capture_sources),
10533 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010534 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010535 .setup = alc888_fujitsu_xa3530_setup,
10536 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010537 },
Kailang Yange2757d52008-08-26 13:17:46 +020010538 [ALC888_LENOVO_SKY] = {
10539 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10540 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10541 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10542 .dac_nids = alc883_dac_nids,
10543 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010544 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10545 .channel_mode = alc883_sixstack_modes,
10546 .need_dac_fix = 1,
10547 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010548 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010549 .setup = alc888_lenovo_sky_setup,
10550 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010551 },
10552 [ALC888_ASUS_M90V] = {
10553 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10554 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10555 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10556 .dac_nids = alc883_dac_nids,
10557 .dig_out_nid = ALC883_DIGOUT_NID,
10558 .dig_in_nid = ALC883_DIGIN_NID,
10559 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10560 .channel_mode = alc883_3ST_6ch_modes,
10561 .need_dac_fix = 1,
10562 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010563 .unsol_event = alc_sku_unsol_event,
10564 .setup = alc883_mode2_setup,
10565 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010566 },
10567 [ALC888_ASUS_EEE1601] = {
10568 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010569 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010570 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10571 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10572 .dac_nids = alc883_dac_nids,
10573 .dig_out_nid = ALC883_DIGOUT_NID,
10574 .dig_in_nid = ALC883_DIGIN_NID,
10575 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10576 .channel_mode = alc883_3ST_2ch_modes,
10577 .need_dac_fix = 1,
10578 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010579 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010580 .init_hook = alc883_eee1601_inithook,
10581 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010582 [ALC1200_ASUS_P5Q] = {
10583 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10584 .init_verbs = { alc883_init_verbs },
10585 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10586 .dac_nids = alc883_dac_nids,
10587 .dig_out_nid = ALC1200_DIGOUT_NID,
10588 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010589 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010590 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10591 .channel_mode = alc883_sixstack_modes,
10592 .input_mux = &alc883_capture_source,
10593 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010594 [ALC889A_MB31] = {
10595 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10596 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10597 alc880_gpio1_init_verbs },
10598 .adc_nids = alc883_adc_nids,
10599 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010600 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010601 .dac_nids = alc883_dac_nids,
10602 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10603 .channel_mode = alc889A_mb31_6ch_modes,
10604 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10605 .input_mux = &alc889A_mb31_capture_source,
10606 .dig_out_nid = ALC883_DIGOUT_NID,
10607 .unsol_event = alc889A_mb31_unsol_event,
10608 .init_hook = alc889A_mb31_automute,
10609 },
Guido Günther3e1647c52009-06-05 00:47:26 +020010610 [ALC883_SONY_VAIO_TT] = {
10611 .mixers = { alc883_vaiott_mixer },
10612 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10613 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10614 .dac_nids = alc883_dac_nids,
10615 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10616 .channel_mode = alc883_3ST_2ch_modes,
10617 .input_mux = &alc883_capture_source,
10618 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010619 .setup = alc883_vaiott_setup,
10620 .init_hook = alc_automute_amp,
Guido Günther3e1647c52009-06-05 00:47:26 +020010621 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010622};
10623
10624
10625/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010626 * Pin config fixes
10627 */
10628enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010629 PINFIX_ABIT_AW9D_MAX,
10630 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010631 PINFIX_ACER_ASPIRE_7736,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010632};
10633
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010634static const struct alc_fixup alc882_fixups[] = {
10635 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010636 .pins = (const struct alc_pincfg[]) {
10637 { 0x15, 0x01080104 }, /* side */
10638 { 0x16, 0x01011012 }, /* rear */
10639 { 0x17, 0x01016011 }, /* clfe */
10640 { }
10641 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010642 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010643 [PINFIX_PB_M5210] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010644 .verbs = (const struct hda_verb[]) {
10645 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10646 {}
10647 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010648 },
David Henningssonc3d226a2010-10-14 15:42:08 +020010649 [PINFIX_ACER_ASPIRE_7736] = {
10650 .sku = ALC_FIXUP_SKU_IGNORE,
10651 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010652};
10653
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010654static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010655 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010656 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020010657 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010658 {}
10659};
10660
10661/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010662 * BIOS auto configuration
10663 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010664static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10665 const struct auto_pin_cfg *cfg)
10666{
10667 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10668}
10669
Takashi Iwai4953550a2009-06-30 15:28:30 +020010670static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010671 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010672 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010673{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010674 int idx;
10675
Takashi Iwai489008c2010-04-07 09:06:00 +020010676 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010677 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010678
Takashi Iwai489008c2010-04-07 09:06:00 +020010679 if (dac == 0x25)
10680 idx = 4;
10681 else if (dac >= 0x02 && dac <= 0x05)
10682 idx = dac - 2;
10683 else
10684 return;
10685 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010686}
10687
Takashi Iwai4953550a2009-06-30 15:28:30 +020010688static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010689{
10690 struct alc_spec *spec = codec->spec;
10691 int i;
10692
10693 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010694 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010695 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010696 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010697 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010698 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010699 }
10700}
10701
Takashi Iwai4953550a2009-06-30 15:28:30 +020010702static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010703{
10704 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010705 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010706 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010707
Takashi Iwai5855fb82010-09-16 18:24:02 +020010708 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10709 pin = spec->autocfg.hp_pins[i];
10710 if (!pin)
10711 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010712 dac = spec->multiout.hp_nid;
10713 if (!dac)
10714 dac = spec->multiout.dac_nids[0]; /* to front */
10715 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10716 }
Takashi Iwai5855fb82010-09-16 18:24:02 +020010717 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10718 pin = spec->autocfg.speaker_pins[i];
10719 if (!pin)
10720 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010721 dac = spec->multiout.extra_out_nid[0];
10722 if (!dac)
10723 dac = spec->multiout.dac_nids[0]; /* to front */
10724 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10725 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010726}
10727
Takashi Iwai4953550a2009-06-30 15:28:30 +020010728static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010729{
10730 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010731 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010732 int i;
10733
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010734 for (i = 0; i < cfg->num_inputs; i++) {
10735 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010736 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010737 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10738 snd_hda_codec_write(codec, nid, 0,
10739 AC_VERB_SET_AMP_GAIN_MUTE,
10740 AMP_OUT_MUTE);
10741 }
10742}
10743
10744static void alc882_auto_init_input_src(struct hda_codec *codec)
10745{
10746 struct alc_spec *spec = codec->spec;
10747 int c;
10748
10749 for (c = 0; c < spec->num_adc_nids; c++) {
10750 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10751 hda_nid_t nid = spec->capsrc_nids[c];
10752 unsigned int mux_idx;
10753 const struct hda_input_mux *imux;
10754 int conns, mute, idx, item;
10755
10756 conns = snd_hda_get_connections(codec, nid, conn_list,
10757 ARRAY_SIZE(conn_list));
10758 if (conns < 0)
10759 continue;
10760 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10761 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010762 if (!imux->num_items && mux_idx > 0)
10763 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010764 for (idx = 0; idx < conns; idx++) {
10765 /* if the current connection is the selected one,
10766 * unmute it as default - otherwise mute it
10767 */
10768 mute = AMP_IN_MUTE(idx);
10769 for (item = 0; item < imux->num_items; item++) {
10770 if (imux->items[item].index == idx) {
10771 if (spec->cur_mux[c] == item)
10772 mute = AMP_IN_UNMUTE(idx);
10773 break;
10774 }
10775 }
10776 /* check if we have a selector or mixer
10777 * we could check for the widget type instead, but
10778 * just check for Amp-In presence (in case of mixer
10779 * without amp-in there is something wrong, this
10780 * function shouldn't be used or capsrc nid is wrong)
10781 */
10782 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010783 snd_hda_codec_write(codec, nid, 0,
10784 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010785 mute);
10786 else if (mute != AMP_IN_MUTE(idx))
10787 snd_hda_codec_write(codec, nid, 0,
10788 AC_VERB_SET_CONNECT_SEL,
10789 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010790 }
10791 }
10792}
10793
Takashi Iwai4953550a2009-06-30 15:28:30 +020010794/* add mic boosts if needed */
10795static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010796{
10797 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010798 struct auto_pin_cfg *cfg = &spec->autocfg;
10799 int i, err;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010800 hda_nid_t nid;
10801
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010802 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010803 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010804 break;
10805 nid = cfg->inputs[i].pin;
10806 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +020010807 char label[32];
10808 snprintf(label, sizeof(label), "%s Boost",
10809 hda_get_autocfg_input_label(codec, cfg, i));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010810 err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010811 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010812 if (err < 0)
10813 return err;
10814 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010815 }
10816 return 0;
10817}
10818
10819/* almost identical with ALC880 parser... */
10820static int alc882_parse_auto_config(struct hda_codec *codec)
10821{
10822 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010823 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010824 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010825
Takashi Iwai05f5f472009-08-25 13:10:18 +020010826 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10827 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010828 if (err < 0)
10829 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010830 if (!spec->autocfg.line_outs)
10831 return 0; /* can't find valid BIOS pin config */
10832
10833 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10834 if (err < 0)
10835 return err;
10836 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10837 if (err < 0)
10838 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010839 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10840 "Headphone");
10841 if (err < 0)
10842 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010843 err = alc880_auto_create_extra_out(spec,
10844 spec->autocfg.speaker_pins[0],
10845 "Speaker");
10846 if (err < 0)
10847 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010848 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10849 if (err < 0)
10850 return err;
10851
10852 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10853
Takashi Iwai757899a2010-07-30 10:48:14 +020010854 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010855
10856 if (spec->kctls.list)
10857 add_mixer(spec, spec->kctls.list);
10858
10859 add_verb(spec, alc883_auto_init_verbs);
10860 /* if ADC 0x07 is available, initialize it, too */
10861 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10862 add_verb(spec, alc882_adc1_init_verbs);
10863
10864 spec->num_mux_defs = 1;
10865 spec->input_mux = &spec->private_imux[0];
10866
Kailang Yang6227cdc2010-02-25 08:36:52 +010010867 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010868
10869 err = alc_auto_add_mic_boost(codec);
10870 if (err < 0)
10871 return err;
10872
Takashi Iwai776e1842007-08-29 15:07:11 +020010873 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010874}
10875
10876/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010877static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010878{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010879 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010880 alc882_auto_init_multi_out(codec);
10881 alc882_auto_init_hp_out(codec);
10882 alc882_auto_init_analog_input(codec);
10883 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010884 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010885 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010886 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010887}
10888
Takashi Iwai4953550a2009-06-30 15:28:30 +020010889static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010890{
10891 struct alc_spec *spec;
10892 int err, board_config;
10893
10894 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10895 if (spec == NULL)
10896 return -ENOMEM;
10897
10898 codec->spec = spec;
10899
Takashi Iwai4953550a2009-06-30 15:28:30 +020010900 switch (codec->vendor_id) {
10901 case 0x10ec0882:
10902 case 0x10ec0885:
10903 break;
10904 default:
10905 /* ALC883 and variants */
10906 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10907 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010908 }
10909
Takashi Iwai4953550a2009-06-30 15:28:30 +020010910 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10911 alc882_models,
10912 alc882_cfg_tbl);
10913
10914 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10915 board_config = snd_hda_check_board_codec_sid_config(codec,
10916 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10917
10918 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010919 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010920 codec->chip_name);
10921 board_config = ALC882_AUTO;
10922 }
10923
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010924 if (board_config == ALC882_AUTO)
10925 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010926
David Henningsson90622912010-10-14 14:50:18 +020010927 alc_auto_parse_customize_define(codec);
10928
Takashi Iwai4953550a2009-06-30 15:28:30 +020010929 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010930 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010931 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010932 if (err < 0) {
10933 alc_free(codec);
10934 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010935 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010936 printk(KERN_INFO
10937 "hda_codec: Cannot set up configuration "
10938 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010939 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010940 }
10941 }
10942
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010943 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020010944 err = snd_hda_attach_beep_device(codec, 0x1);
10945 if (err < 0) {
10946 alc_free(codec);
10947 return err;
10948 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010949 }
10950
Takashi Iwai4953550a2009-06-30 15:28:30 +020010951 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010952 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010953
Takashi Iwai4953550a2009-06-30 15:28:30 +020010954 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10955 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10956 /* FIXME: setup DAC5 */
10957 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10958 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10959
10960 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10961 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10962
Takashi Iwai4953550a2009-06-30 15:28:30 +020010963 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010964 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010965 spec->num_adc_nids = 0;
10966 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010967 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010968 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010969 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010970 hda_nid_t nid = alc882_adc_nids[i];
10971 unsigned int wcap = get_wcaps(codec, nid);
10972 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010973 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010974 if (wcap != AC_WID_AUD_IN)
10975 continue;
10976 spec->private_adc_nids[spec->num_adc_nids] = nid;
10977 err = snd_hda_get_connections(codec, nid, &cap, 1);
10978 if (err < 0)
10979 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010980 err = snd_hda_get_connections(codec, cap, items,
10981 ARRAY_SIZE(items));
10982 if (err < 0)
10983 continue;
10984 for (j = 0; j < imux->num_items; j++)
10985 if (imux->items[j].index >= err)
10986 break;
10987 if (j < imux->num_items)
10988 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010989 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10990 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010991 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010992 spec->adc_nids = spec->private_adc_nids;
10993 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010994 }
10995
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010996 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010010997
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010998 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010010999 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011000
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011001 if (board_config == ALC882_AUTO)
11002 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
11003
Takashi Iwai2134ea42008-01-10 16:53:55 +010011004 spec->vmaster_nid = 0x0c;
11005
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011006 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011007 if (board_config == ALC882_AUTO)
11008 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011009
11010 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011011#ifdef CONFIG_SND_HDA_POWER_SAVE
11012 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011013 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011014#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011015
11016 return 0;
11017}
11018
Takashi Iwai4953550a2009-06-30 15:28:30 +020011019
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011020/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011021 * ALC262 support
11022 */
11023
11024#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11025#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11026
11027#define alc262_dac_nids alc260_dac_nids
11028#define alc262_adc_nids alc882_adc_nids
11029#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011030#define alc262_capsrc_nids alc882_capsrc_nids
11031#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011032
11033#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011034#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011035
Kailang Yang4e555fe2008-08-26 13:05:55 +020011036static hda_nid_t alc262_dmic_adc_nids[1] = {
11037 /* ADC0 */
11038 0x09
11039};
11040
11041static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
11042
Kailang Yangdf694da2005-12-05 19:42:22 +010011043static struct snd_kcontrol_new alc262_base_mixer[] = {
11044 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11045 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11046 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11047 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11048 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11049 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11050 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11051 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011052 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011053 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11054 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011055 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011056 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11057 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11058 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11059 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011060 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011061};
11062
Takashi Iwaice875f02008-01-28 18:17:43 +010011063/* update HP, line and mono-out pins according to the master switch */
11064static void alc262_hp_master_update(struct hda_codec *codec)
11065{
11066 struct alc_spec *spec = codec->spec;
11067 int val = spec->master_sw;
11068
11069 /* HP & line-out */
11070 snd_hda_codec_write_cache(codec, 0x1b, 0,
11071 AC_VERB_SET_PIN_WIDGET_CONTROL,
11072 val ? PIN_HP : 0);
11073 snd_hda_codec_write_cache(codec, 0x15, 0,
11074 AC_VERB_SET_PIN_WIDGET_CONTROL,
11075 val ? PIN_HP : 0);
11076 /* mono (speaker) depending on the HP jack sense */
11077 val = val && !spec->jack_present;
11078 snd_hda_codec_write_cache(codec, 0x16, 0,
11079 AC_VERB_SET_PIN_WIDGET_CONTROL,
11080 val ? PIN_OUT : 0);
11081}
11082
11083static void alc262_hp_bpc_automute(struct hda_codec *codec)
11084{
11085 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011086
11087 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011088 alc262_hp_master_update(codec);
11089}
11090
11091static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11092{
11093 if ((res >> 26) != ALC880_HP_EVENT)
11094 return;
11095 alc262_hp_bpc_automute(codec);
11096}
11097
11098static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11099{
11100 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011101
11102 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011103 alc262_hp_master_update(codec);
11104}
11105
11106static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11107 unsigned int res)
11108{
11109 if ((res >> 26) != ALC880_HP_EVENT)
11110 return;
11111 alc262_hp_wildwest_automute(codec);
11112}
11113
Takashi Iwaib72519b2009-05-08 14:31:55 +020011114#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011115
11116static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11117 struct snd_ctl_elem_value *ucontrol)
11118{
11119 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11120 struct alc_spec *spec = codec->spec;
11121 int val = !!*ucontrol->value.integer.value;
11122
11123 if (val == spec->master_sw)
11124 return 0;
11125 spec->master_sw = val;
11126 alc262_hp_master_update(codec);
11127 return 1;
11128}
11129
Takashi Iwaib72519b2009-05-08 14:31:55 +020011130#define ALC262_HP_MASTER_SWITCH \
11131 { \
11132 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11133 .name = "Master Playback Switch", \
11134 .info = snd_ctl_boolean_mono_info, \
11135 .get = alc262_hp_master_sw_get, \
11136 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011137 }, \
11138 { \
11139 .iface = NID_MAPPING, \
11140 .name = "Master Playback Switch", \
11141 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011142 }
11143
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011144
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011145static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011146 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011147 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11148 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11149 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011150 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11151 HDA_OUTPUT),
11152 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11153 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011154 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11155 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011156 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011157 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11158 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011159 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011160 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11161 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11162 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11163 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011164 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11165 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11166 { } /* end */
11167};
11168
Kailang Yangcd7509a2007-01-26 18:33:17 +010011169static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011170 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011171 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11172 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11173 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11174 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011175 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11176 HDA_OUTPUT),
11177 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11178 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011179 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11180 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011181 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011182 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11183 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11184 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11185 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011186 { } /* end */
11187};
11188
11189static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11190 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11191 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011192 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011193 { } /* end */
11194};
11195
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011196/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011197static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011198{
11199 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011200
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011201 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011202 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011203}
11204
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011205static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011206 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11207 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011208 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11210 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11211 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11212 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11213 { } /* end */
11214};
11215
11216static struct hda_verb alc262_hp_t5735_verbs[] = {
11217 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11218 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11219
11220 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11221 { }
11222};
11223
Kailang Yang8c427222008-01-10 13:03:59 +010011224static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011225 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11226 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011227 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11228 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011229 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11230 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11231 { } /* end */
11232};
11233
11234static struct hda_verb alc262_hp_rp5700_verbs[] = {
11235 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11236 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11237 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11238 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11239 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11240 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11241 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11242 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11243 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11244 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11245 {}
11246};
11247
11248static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11249 .num_items = 1,
11250 .items = {
11251 { "Line", 0x1 },
11252 },
11253};
11254
Takashi Iwai42171c12009-05-08 14:11:43 +020011255/* bind hp and internal speaker mute (with plug check) as master switch */
11256static void alc262_hippo_master_update(struct hda_codec *codec)
11257{
11258 struct alc_spec *spec = codec->spec;
11259 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11260 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11261 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11262 unsigned int mute;
11263
11264 /* HP */
11265 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11266 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11267 HDA_AMP_MUTE, mute);
11268 /* mute internal speaker per jack sense */
11269 if (spec->jack_present)
11270 mute = HDA_AMP_MUTE;
11271 if (line_nid)
11272 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11273 HDA_AMP_MUTE, mute);
11274 if (speaker_nid && speaker_nid != line_nid)
11275 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11276 HDA_AMP_MUTE, mute);
11277}
11278
11279#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11280
11281static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11282 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011283{
11284 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011285 struct alc_spec *spec = codec->spec;
11286 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011287
Takashi Iwai42171c12009-05-08 14:11:43 +020011288 if (val == spec->master_sw)
11289 return 0;
11290 spec->master_sw = val;
11291 alc262_hippo_master_update(codec);
11292 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011293}
Takashi Iwai5b319542007-07-26 11:49:22 +020011294
Takashi Iwai42171c12009-05-08 14:11:43 +020011295#define ALC262_HIPPO_MASTER_SWITCH \
11296 { \
11297 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11298 .name = "Master Playback Switch", \
11299 .info = snd_ctl_boolean_mono_info, \
11300 .get = alc262_hippo_master_sw_get, \
11301 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011302 }, \
11303 { \
11304 .iface = NID_MAPPING, \
11305 .name = "Master Playback Switch", \
11306 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11307 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011308 }
11309
11310static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11311 ALC262_HIPPO_MASTER_SWITCH,
11312 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11313 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11314 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11315 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11316 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11318 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11319 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11320 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11321 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11322 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11323 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11324 { } /* end */
11325};
11326
11327static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11328 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11329 ALC262_HIPPO_MASTER_SWITCH,
11330 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11331 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11332 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11333 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11335 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11336 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11337 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11338 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11339 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11340 { } /* end */
11341};
11342
11343/* mute/unmute internal speaker according to the hp jack and mute state */
11344static void alc262_hippo_automute(struct hda_codec *codec)
11345{
11346 struct alc_spec *spec = codec->spec;
11347 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011348
Wu Fengguang864f92b2009-11-18 12:38:02 +080011349 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011350 alc262_hippo_master_update(codec);
11351}
11352
11353static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11354{
11355 if ((res >> 26) != ALC880_HP_EVENT)
11356 return;
11357 alc262_hippo_automute(codec);
11358}
11359
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011360static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011361{
11362 struct alc_spec *spec = codec->spec;
11363
11364 spec->autocfg.hp_pins[0] = 0x15;
11365 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011366}
11367
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011368static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011369{
11370 struct alc_spec *spec = codec->spec;
11371
11372 spec->autocfg.hp_pins[0] = 0x1b;
11373 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011374}
11375
11376
Kailang Yang272a5272007-05-14 11:00:38 +020011377static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011378 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011379 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011380 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11381 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11382 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11383 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11384 { } /* end */
11385};
11386
Kailang Yang83c34212007-07-05 11:43:05 +020011387static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011388 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11389 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011390 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11391 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11392 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11393 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11394 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11395 { } /* end */
11396};
Kailang Yang272a5272007-05-14 11:00:38 +020011397
Tony Vroonba340e82009-02-02 19:01:30 +000011398static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11399 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11400 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11401 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11402 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11403 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11404 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11405 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11406 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11407 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11408 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11409 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11410 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11411 { } /* end */
11412};
11413
11414static struct hda_verb alc262_tyan_verbs[] = {
11415 /* Headphone automute */
11416 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11417 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11418 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11419
11420 /* P11 AUX_IN, white 4-pin connector */
11421 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11422 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11423 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11424 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11425
11426 {}
11427};
11428
11429/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011430static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011431{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011432 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011433
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011434 spec->autocfg.hp_pins[0] = 0x1b;
11435 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011436}
11437
Tony Vroonba340e82009-02-02 19:01:30 +000011438
Kailang Yangdf694da2005-12-05 19:42:22 +010011439#define alc262_capture_mixer alc882_capture_mixer
11440#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11441
11442/*
11443 * generic initialization of ADC, input mixers and output mixers
11444 */
11445static struct hda_verb alc262_init_verbs[] = {
11446 /*
11447 * Unmute ADC0-2 and set the default input to mic-in
11448 */
11449 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11450 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11451 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11452 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11453 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11454 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11455
Takashi Iwaicb53c622007-08-10 17:21:45 +020011456 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011457 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011458 * Note: PASD motherboards uses the Line In 2 as the input for
11459 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011460 */
11461 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011462 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11463 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11464 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11465 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11466 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011467
11468 /*
11469 * Set up output mixers (0x0c - 0x0e)
11470 */
11471 /* set vol=0 to output mixers */
11472 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11473 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11474 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11475 /* set up input amps for analog loopback */
11476 /* Amp Indices: DAC = 0, mixer = 1 */
11477 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11478 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11479 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11480 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11481 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11482 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11483
11484 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11485 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11486 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11487 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11488 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11489 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11490
11491 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11492 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11493 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11494 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11495 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011496
Kailang Yangdf694da2005-12-05 19:42:22 +010011497 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11498 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011499
Kailang Yangdf694da2005-12-05 19:42:22 +010011500 /* FIXME: use matrix-type input source selection */
11501 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11502 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11503 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11504 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11505 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11506 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11507 /* Input mixer2 */
11508 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11509 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11510 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11511 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11512 /* Input mixer3 */
11513 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11514 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11515 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011516 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011517
11518 { }
11519};
11520
Kailang Yang4e555fe2008-08-26 13:05:55 +020011521static struct hda_verb alc262_eapd_verbs[] = {
11522 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11523 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11524 { }
11525};
11526
Kailang Yangccc656c2006-10-17 12:32:26 +020011527static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11528 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11529 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11530 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11531
11532 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11533 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11534 {}
11535};
11536
Kailang Yang272a5272007-05-14 11:00:38 +020011537static struct hda_verb alc262_sony_unsol_verbs[] = {
11538 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11539 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11540 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11541
11542 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11543 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011544 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011545};
11546
Kailang Yang4e555fe2008-08-26 13:05:55 +020011547static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11548 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11549 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11550 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11551 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11552 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011553 { } /* end */
11554};
11555
11556static struct hda_verb alc262_toshiba_s06_verbs[] = {
11557 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11558 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11559 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11560 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11561 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11562 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11563 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11564 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11565 {}
11566};
11567
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011568static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011569{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011570 struct alc_spec *spec = codec->spec;
11571
11572 spec->autocfg.hp_pins[0] = 0x15;
11573 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011574 spec->ext_mic.pin = 0x18;
11575 spec->ext_mic.mux_idx = 0;
11576 spec->int_mic.pin = 0x12;
11577 spec->int_mic.mux_idx = 9;
11578 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011579}
11580
Takashi Iwai834be882006-03-01 14:16:17 +010011581/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011582 * nec model
11583 * 0x15 = headphone
11584 * 0x16 = internal speaker
11585 * 0x18 = external mic
11586 */
11587
11588static struct snd_kcontrol_new alc262_nec_mixer[] = {
11589 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11590 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11591
11592 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11593 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11594 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11595
11596 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11597 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11598 { } /* end */
11599};
11600
11601static struct hda_verb alc262_nec_verbs[] = {
11602 /* Unmute Speaker */
11603 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11604
11605 /* Headphone */
11606 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11607 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11608
11609 /* External mic to headphone */
11610 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11611 /* External mic to speaker */
11612 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11613 {}
11614};
11615
11616/*
Takashi Iwai834be882006-03-01 14:16:17 +010011617 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011618 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11619 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011620 */
11621
11622#define ALC_HP_EVENT 0x37
11623
11624static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11625 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11626 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011627 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11628 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011629 {}
11630};
11631
Jiang zhe0e31daf2008-03-20 12:12:39 +010011632static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11633 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11634 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11635 {}
11636};
11637
Daniel T Chene2595322009-12-19 18:19:02 -050011638static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11639 /* Front Mic pin: input vref at 50% */
11640 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11641 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11642 {}
11643};
11644
Takashi Iwai834be882006-03-01 14:16:17 +010011645static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011646 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011647 .items = {
11648 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011649 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011650 { "CD", 0x4 },
11651 },
11652};
11653
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011654static struct hda_input_mux alc262_HP_capture_source = {
11655 .num_items = 5,
11656 .items = {
11657 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011658 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011659 { "Line", 0x2 },
11660 { "CD", 0x4 },
11661 { "AUX IN", 0x6 },
11662 },
11663};
11664
zhejiangaccbe492007-08-31 12:36:05 +020011665static struct hda_input_mux alc262_HP_D7000_capture_source = {
11666 .num_items = 4,
11667 .items = {
11668 { "Mic", 0x0 },
11669 { "Front Mic", 0x2 },
11670 { "Line", 0x1 },
11671 { "CD", 0x4 },
11672 },
11673};
11674
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011675/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011676static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11677{
11678 struct alc_spec *spec = codec->spec;
11679 unsigned int mute;
11680
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011681 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011682 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11683 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011684 spec->sense_updated = 1;
11685 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011686 /* unmute internal speaker only if both HPs are unplugged and
11687 * master switch is on
11688 */
11689 if (spec->jack_present)
11690 mute = HDA_AMP_MUTE;
11691 else
Takashi Iwai834be882006-03-01 14:16:17 +010011692 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011693 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11694 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011695}
11696
11697/* unsolicited event for HP jack sensing */
11698static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11699 unsigned int res)
11700{
11701 if ((res >> 26) != ALC_HP_EVENT)
11702 return;
11703 alc262_fujitsu_automute(codec, 1);
11704}
11705
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011706static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11707{
11708 alc262_fujitsu_automute(codec, 1);
11709}
11710
Takashi Iwai834be882006-03-01 14:16:17 +010011711/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011712static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11713 .ops = &snd_hda_bind_vol,
11714 .values = {
11715 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11716 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11717 0
11718 },
11719};
Takashi Iwai834be882006-03-01 14:16:17 +010011720
Jiang zhe0e31daf2008-03-20 12:12:39 +010011721/* mute/unmute internal speaker according to the hp jack and mute state */
11722static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11723{
11724 struct alc_spec *spec = codec->spec;
11725 unsigned int mute;
11726
11727 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011728 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011729 spec->sense_updated = 1;
11730 }
11731 if (spec->jack_present) {
11732 /* mute internal speaker */
11733 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11734 HDA_AMP_MUTE, HDA_AMP_MUTE);
11735 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11736 HDA_AMP_MUTE, HDA_AMP_MUTE);
11737 } else {
11738 /* unmute internal speaker if necessary */
11739 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11740 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11741 HDA_AMP_MUTE, mute);
11742 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11743 HDA_AMP_MUTE, mute);
11744 }
11745}
11746
11747/* unsolicited event for HP jack sensing */
11748static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11749 unsigned int res)
11750{
11751 if ((res >> 26) != ALC_HP_EVENT)
11752 return;
11753 alc262_lenovo_3000_automute(codec, 1);
11754}
11755
Takashi Iwai8de56b72009-07-24 16:51:47 +020011756static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11757 int dir, int idx, long *valp)
11758{
11759 int i, change = 0;
11760
11761 for (i = 0; i < 2; i++, valp++)
11762 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11763 HDA_AMP_MUTE,
11764 *valp ? 0 : HDA_AMP_MUTE);
11765 return change;
11766}
11767
Takashi Iwai834be882006-03-01 14:16:17 +010011768/* bind hp and internal speaker mute (with plug check) */
11769static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11770 struct snd_ctl_elem_value *ucontrol)
11771{
11772 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11773 long *valp = ucontrol->value.integer.value;
11774 int change;
11775
Takashi Iwai8de56b72009-07-24 16:51:47 +020011776 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11777 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011778 if (change)
11779 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011780 return change;
11781}
11782
11783static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011784 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011785 {
11786 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11787 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011788 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011789 .info = snd_hda_mixer_amp_switch_info,
11790 .get = snd_hda_mixer_amp_switch_get,
11791 .put = alc262_fujitsu_master_sw_put,
11792 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11793 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011794 {
11795 .iface = NID_MAPPING,
11796 .name = "Master Playback Switch",
11797 .private_value = 0x1b,
11798 },
Takashi Iwai834be882006-03-01 14:16:17 +010011799 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11800 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11801 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11802 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11803 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011804 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11805 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11806 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011807 { } /* end */
11808};
11809
Jiang zhe0e31daf2008-03-20 12:12:39 +010011810/* bind hp and internal speaker mute (with plug check) */
11811static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11812 struct snd_ctl_elem_value *ucontrol)
11813{
11814 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11815 long *valp = ucontrol->value.integer.value;
11816 int change;
11817
Takashi Iwai8de56b72009-07-24 16:51:47 +020011818 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011819 if (change)
11820 alc262_lenovo_3000_automute(codec, 0);
11821 return change;
11822}
11823
11824static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11825 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11826 {
11827 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11828 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011829 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011830 .info = snd_hda_mixer_amp_switch_info,
11831 .get = snd_hda_mixer_amp_switch_get,
11832 .put = alc262_lenovo_3000_master_sw_put,
11833 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11834 },
11835 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11836 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11837 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11839 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11840 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11841 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11842 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11843 { } /* end */
11844};
11845
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011846static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11847 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011848 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011849 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11850 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11851 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11852 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11853 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11854 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11855 { } /* end */
11856};
11857
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011858/* additional init verbs for Benq laptops */
11859static struct hda_verb alc262_EAPD_verbs[] = {
11860 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11861 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11862 {}
11863};
11864
Kailang Yang83c34212007-07-05 11:43:05 +020011865static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11866 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11867 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11868
11869 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11870 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11871 {}
11872};
11873
Tobin Davisf651b502007-10-26 12:40:47 +020011874/* Samsung Q1 Ultra Vista model setup */
11875static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011876 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11877 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011878 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11879 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11880 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011881 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011882 { } /* end */
11883};
11884
11885static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011886 /* output mixer */
11887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11890 /* speaker */
11891 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11892 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11893 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11894 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11895 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011896 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011897 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11898 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11899 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11900 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11901 /* internal mic */
11902 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11903 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11904 /* ADC, choose mic */
11905 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11906 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11907 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11908 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11909 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11910 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11911 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11912 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11913 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11914 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011915 {}
11916};
11917
Tobin Davisf651b502007-10-26 12:40:47 +020011918/* mute/unmute internal speaker according to the hp jack and mute state */
11919static void alc262_ultra_automute(struct hda_codec *codec)
11920{
11921 struct alc_spec *spec = codec->spec;
11922 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011923
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011924 mute = 0;
11925 /* auto-mute only when HP is used as HP */
11926 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011927 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011928 if (spec->jack_present)
11929 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011930 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011931 /* mute/unmute internal speaker */
11932 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11933 HDA_AMP_MUTE, mute);
11934 /* mute/unmute HP */
11935 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11936 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011937}
11938
11939/* unsolicited event for HP jack sensing */
11940static void alc262_ultra_unsol_event(struct hda_codec *codec,
11941 unsigned int res)
11942{
11943 if ((res >> 26) != ALC880_HP_EVENT)
11944 return;
11945 alc262_ultra_automute(codec);
11946}
11947
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011948static struct hda_input_mux alc262_ultra_capture_source = {
11949 .num_items = 2,
11950 .items = {
11951 { "Mic", 0x1 },
11952 { "Headphone", 0x7 },
11953 },
11954};
11955
11956static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11957 struct snd_ctl_elem_value *ucontrol)
11958{
11959 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11960 struct alc_spec *spec = codec->spec;
11961 int ret;
11962
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011963 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011964 if (!ret)
11965 return 0;
11966 /* reprogram the HP pin as mic or HP according to the input source */
11967 snd_hda_codec_write_cache(codec, 0x15, 0,
11968 AC_VERB_SET_PIN_WIDGET_CONTROL,
11969 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11970 alc262_ultra_automute(codec); /* mute/unmute HP */
11971 return ret;
11972}
11973
11974static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11975 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11976 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11977 {
11978 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11979 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011980 .info = alc_mux_enum_info,
11981 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011982 .put = alc262_ultra_mux_enum_put,
11983 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011984 {
11985 .iface = NID_MAPPING,
11986 .name = "Capture Source",
11987 .private_value = 0x15,
11988 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011989 { } /* end */
11990};
11991
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011992/* We use two mixers depending on the output pin; 0x16 is a mono output
11993 * and thus it's bound with a different mixer.
11994 * This function returns which mixer amp should be used.
11995 */
11996static int alc262_check_volbit(hda_nid_t nid)
11997{
11998 if (!nid)
11999 return 0;
12000 else if (nid == 0x16)
12001 return 2;
12002 else
12003 return 1;
12004}
12005
12006static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012007 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012008{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012009 unsigned long val;
12010 int vbit;
12011
12012 vbit = alc262_check_volbit(nid);
12013 if (!vbit)
12014 return 0;
12015 if (*vbits & vbit) /* a volume control for this mixer already there */
12016 return 0;
12017 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012018 if (vbit == 2)
12019 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
12020 else
12021 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012022 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012023}
12024
12025static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012026 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012027{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012028 unsigned long val;
12029
12030 if (!nid)
12031 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012032 if (nid == 0x16)
12033 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
12034 else
12035 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012036 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012037}
12038
Kailang Yangdf694da2005-12-05 19:42:22 +010012039/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012040static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
12041 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012042{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012043 const char *pfx;
12044 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020012045 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012046
12047 spec->multiout.num_dacs = 1; /* only use one dac */
12048 spec->multiout.dac_nids = spec->private_dac_nids;
12049 spec->multiout.dac_nids[0] = 2;
12050
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012051 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
12052 pfx = "Master";
12053 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12054 pfx = "Speaker";
Takashi Iwai033688a2010-09-08 15:47:09 +020012055 else if (cfg->line_out_type == AUTO_PIN_HP_OUT)
12056 pfx = "Headphone";
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012057 else
12058 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012059 for (i = 0; i < 2; i++) {
12060 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12061 if (err < 0)
12062 return err;
12063 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12064 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12065 "Speaker", i);
12066 if (err < 0)
12067 return err;
12068 }
12069 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12070 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12071 "Headphone", i);
12072 if (err < 0)
12073 return err;
12074 }
12075 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012076
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012077 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12078 alc262_check_volbit(cfg->speaker_pins[0]) |
12079 alc262_check_volbit(cfg->hp_pins[0]);
12080 if (vbits == 1 || vbits == 2)
12081 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012082 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012083 for (i = 0; i < 2; i++) {
12084 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12085 &vbits, i);
12086 if (err < 0)
12087 return err;
12088 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12089 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12090 "Speaker", &vbits, i);
12091 if (err < 0)
12092 return err;
12093 }
12094 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12095 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12096 "Headphone", &vbits, i);
12097 if (err < 0)
12098 return err;
12099 }
12100 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012101 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012102}
12103
Takashi Iwai05f5f472009-08-25 13:10:18 +020012104#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012105 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012106
12107/*
12108 * generic initialization of ADC, input mixers and output mixers
12109 */
12110static struct hda_verb alc262_volume_init_verbs[] = {
12111 /*
12112 * Unmute ADC0-2 and set the default input to mic-in
12113 */
12114 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12115 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12116 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12117 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12118 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12119 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12120
Takashi Iwaicb53c622007-08-10 17:21:45 +020012121 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012122 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012123 * Note: PASD motherboards uses the Line In 2 as the input for
12124 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012125 */
12126 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012127 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012132
12133 /*
12134 * Set up output mixers (0x0c - 0x0f)
12135 */
12136 /* set vol=0 to output mixers */
12137 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12138 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12139 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012140
Kailang Yangdf694da2005-12-05 19:42:22 +010012141 /* set up input amps for analog loopback */
12142 /* Amp Indices: DAC = 0, mixer = 1 */
12143 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12144 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12145 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12146 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12147 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12148 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12149
12150 /* FIXME: use matrix-type input source selection */
12151 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12152 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12153 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12154 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12155 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12156 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12157 /* Input mixer2 */
12158 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12159 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12160 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12161 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12162 /* Input mixer3 */
12163 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12164 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12165 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12166 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12167
12168 { }
12169};
12170
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012171static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12172 /*
12173 * Unmute ADC0-2 and set the default input to mic-in
12174 */
12175 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12176 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12177 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12178 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12179 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12180 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12181
Takashi Iwaicb53c622007-08-10 17:21:45 +020012182 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012183 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012184 * Note: PASD motherboards uses the Line In 2 as the input for
12185 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012186 */
12187 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012188 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12189 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12190 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12191 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12192 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12193 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12194 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012195
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012196 /*
12197 * Set up output mixers (0x0c - 0x0e)
12198 */
12199 /* set vol=0 to output mixers */
12200 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12201 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12202 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12203
12204 /* set up input amps for analog loopback */
12205 /* Amp Indices: DAC = 0, mixer = 1 */
12206 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12207 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12208 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12209 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12210 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12211 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12212
Takashi Iwaice875f02008-01-28 18:17:43 +010012213 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012214 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12215 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12216
12217 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12218 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12219
12220 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12221 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12222
12223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12224 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12225 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12226 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12227 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12228
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012229 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012230 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12231 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012232 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012233 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12234 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12235
12236
12237 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012238 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12239 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012240 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012241 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12242 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12243 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12244 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12245 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12246 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12247 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12248 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012249 /* Input mixer2 */
12250 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012251 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12252 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12253 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12254 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12255 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12256 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12257 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12258 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012259 /* Input mixer3 */
12260 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012261 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12262 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12263 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12264 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12265 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12266 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12267 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12268 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012269
Takashi Iwaice875f02008-01-28 18:17:43 +010012270 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12271
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012272 { }
12273};
12274
Kailang Yangcd7509a2007-01-26 18:33:17 +010012275static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12276 /*
12277 * Unmute ADC0-2 and set the default input to mic-in
12278 */
12279 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12280 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12281 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12282 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12283 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12284 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12285
Takashi Iwaicb53c622007-08-10 17:21:45 +020012286 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012287 * mixer widget
12288 * Note: PASD motherboards uses the Line In 2 as the input for front
12289 * panel mic (mic 2)
12290 */
12291 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12293 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12294 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12295 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12296 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12297 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12298 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12299 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012300 /*
12301 * Set up output mixers (0x0c - 0x0e)
12302 */
12303 /* set vol=0 to output mixers */
12304 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12305 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12306 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12307
12308 /* set up input amps for analog loopback */
12309 /* Amp Indices: DAC = 0, mixer = 1 */
12310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12311 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12312 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12313 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12314 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12315 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12316
12317
12318 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12319 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12320 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12321 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12322 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12323 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12324 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12325
12326 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12327 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12328
12329 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12330 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12331
12332 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12333 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12334 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12335 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12336 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12337 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12338
12339 /* FIXME: use matrix-type input source selection */
12340 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12341 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12342 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12343 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12344 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12345 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12346 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12347 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12348 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12349 /* Input mixer2 */
12350 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12351 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12352 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12353 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12354 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12355 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12356 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12357 /* Input mixer3 */
12358 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12359 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12360 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12361 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12362 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12363 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12364 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12365
Takashi Iwaice875f02008-01-28 18:17:43 +010012366 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12367
Kailang Yangcd7509a2007-01-26 18:33:17 +010012368 { }
12369};
12370
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012371static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12372
12373 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12374 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12375 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12376
12377 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12378 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12379 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12380 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12381
12382 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12383 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12384 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12385 {}
12386};
12387
Takashi Iwai18675e42010-09-08 15:55:44 +020012388/*
12389 * Pin config fixes
12390 */
12391enum {
12392 PINFIX_FSC_H270,
12393};
12394
12395static const struct alc_fixup alc262_fixups[] = {
12396 [PINFIX_FSC_H270] = {
12397 .pins = (const struct alc_pincfg[]) {
12398 { 0x14, 0x99130110 }, /* speaker */
12399 { 0x15, 0x0221142f }, /* front HP */
12400 { 0x1b, 0x0121141f }, /* rear HP */
12401 { }
12402 }
12403 },
12404 [PINFIX_PB_M5210] = {
12405 .verbs = (const struct hda_verb[]) {
12406 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
12407 {}
12408 }
12409 },
12410};
12411
12412static struct snd_pci_quirk alc262_fixup_tbl[] = {
12413 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12414 {}
12415};
12416
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012417
Takashi Iwaicb53c622007-08-10 17:21:45 +020012418#ifdef CONFIG_SND_HDA_POWER_SAVE
12419#define alc262_loopbacks alc880_loopbacks
12420#endif
12421
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012422/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012423#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12424#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12425#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12426#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12427
12428/*
12429 * BIOS auto configuration
12430 */
12431static int alc262_parse_auto_config(struct hda_codec *codec)
12432{
12433 struct alc_spec *spec = codec->spec;
12434 int err;
12435 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12436
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012437 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12438 alc262_ignore);
12439 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012440 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012441 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012442 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012443 spec->multiout.max_channels = 2;
12444 spec->no_analog = 1;
12445 goto dig_only;
12446 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012447 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012448 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012449 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12450 if (err < 0)
12451 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012452 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012453 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012454 return err;
12455
12456 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12457
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012458 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012459 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012460
Takashi Iwai603c4012008-07-30 15:01:44 +020012461 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012462 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012463
Takashi Iwaid88897e2008-10-31 15:01:37 +010012464 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012465 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012466 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012467
Takashi Iwai776e1842007-08-29 15:07:11 +020012468 err = alc_auto_add_mic_boost(codec);
12469 if (err < 0)
12470 return err;
12471
Kailang Yang6227cdc2010-02-25 08:36:52 +010012472 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012473
Kailang Yangdf694da2005-12-05 19:42:22 +010012474 return 1;
12475}
12476
12477#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12478#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12479#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012480#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012481
12482
12483/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012484static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012485{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012486 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012487 alc262_auto_init_multi_out(codec);
12488 alc262_auto_init_hp_out(codec);
12489 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012490 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012491 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012492 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012493 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012494}
12495
12496/*
12497 * configuration and preset
12498 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012499static const char *alc262_models[ALC262_MODEL_LAST] = {
12500 [ALC262_BASIC] = "basic",
12501 [ALC262_HIPPO] = "hippo",
12502 [ALC262_HIPPO_1] = "hippo_1",
12503 [ALC262_FUJITSU] = "fujitsu",
12504 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012505 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012506 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012507 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012508 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012509 [ALC262_BENQ_T31] = "benq-t31",
12510 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012511 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012512 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012513 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012514 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012515 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012516 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012517 [ALC262_AUTO] = "auto",
12518};
12519
12520static struct snd_pci_quirk alc262_cfg_tbl[] = {
12521 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012522 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012523 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12524 ALC262_HP_BPC),
12525 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12526 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012527 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12528 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012529 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012530 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012531 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012532 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012533 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012534 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012535 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012536 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012537 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12538 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12539 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012540 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12541 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012542 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012543 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012544 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012545 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012546 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012547 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012548 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012549 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012550#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012551 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12552 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012553#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012554 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012555 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012556 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012557 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012558 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012559 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012560 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12561 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012562 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012563 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012564 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012565 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012566 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012567 {}
12568};
12569
12570static struct alc_config_preset alc262_presets[] = {
12571 [ALC262_BASIC] = {
12572 .mixers = { alc262_base_mixer },
12573 .init_verbs = { alc262_init_verbs },
12574 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12575 .dac_nids = alc262_dac_nids,
12576 .hp_nid = 0x03,
12577 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12578 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012579 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012580 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012581 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012582 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012583 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012584 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12585 .dac_nids = alc262_dac_nids,
12586 .hp_nid = 0x03,
12587 .dig_out_nid = ALC262_DIGOUT_NID,
12588 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12589 .channel_mode = alc262_modes,
12590 .input_mux = &alc262_capture_source,
12591 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012592 .setup = alc262_hippo_setup,
12593 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012594 },
12595 [ALC262_HIPPO_1] = {
12596 .mixers = { alc262_hippo1_mixer },
12597 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12598 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12599 .dac_nids = alc262_dac_nids,
12600 .hp_nid = 0x02,
12601 .dig_out_nid = ALC262_DIGOUT_NID,
12602 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12603 .channel_mode = alc262_modes,
12604 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012605 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012606 .setup = alc262_hippo1_setup,
12607 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012608 },
Takashi Iwai834be882006-03-01 14:16:17 +010012609 [ALC262_FUJITSU] = {
12610 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012611 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12612 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012613 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12614 .dac_nids = alc262_dac_nids,
12615 .hp_nid = 0x03,
12616 .dig_out_nid = ALC262_DIGOUT_NID,
12617 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12618 .channel_mode = alc262_modes,
12619 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012620 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012621 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012622 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012623 [ALC262_HP_BPC] = {
12624 .mixers = { alc262_HP_BPC_mixer },
12625 .init_verbs = { alc262_HP_BPC_init_verbs },
12626 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12627 .dac_nids = alc262_dac_nids,
12628 .hp_nid = 0x03,
12629 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12630 .channel_mode = alc262_modes,
12631 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012632 .unsol_event = alc262_hp_bpc_unsol_event,
12633 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012634 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012635 [ALC262_HP_BPC_D7000_WF] = {
12636 .mixers = { alc262_HP_BPC_WildWest_mixer },
12637 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12638 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12639 .dac_nids = alc262_dac_nids,
12640 .hp_nid = 0x03,
12641 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12642 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012643 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012644 .unsol_event = alc262_hp_wildwest_unsol_event,
12645 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012646 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012647 [ALC262_HP_BPC_D7000_WL] = {
12648 .mixers = { alc262_HP_BPC_WildWest_mixer,
12649 alc262_HP_BPC_WildWest_option_mixer },
12650 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12651 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12652 .dac_nids = alc262_dac_nids,
12653 .hp_nid = 0x03,
12654 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12655 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012656 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012657 .unsol_event = alc262_hp_wildwest_unsol_event,
12658 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012659 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012660 [ALC262_HP_TC_T5735] = {
12661 .mixers = { alc262_hp_t5735_mixer },
12662 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12663 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12664 .dac_nids = alc262_dac_nids,
12665 .hp_nid = 0x03,
12666 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12667 .channel_mode = alc262_modes,
12668 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012669 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012670 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012671 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012672 },
12673 [ALC262_HP_RP5700] = {
12674 .mixers = { alc262_hp_rp5700_mixer },
12675 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12676 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12677 .dac_nids = alc262_dac_nids,
12678 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12679 .channel_mode = alc262_modes,
12680 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012681 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012682 [ALC262_BENQ_ED8] = {
12683 .mixers = { alc262_base_mixer },
12684 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12685 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12686 .dac_nids = alc262_dac_nids,
12687 .hp_nid = 0x03,
12688 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12689 .channel_mode = alc262_modes,
12690 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012691 },
Kailang Yang272a5272007-05-14 11:00:38 +020012692 [ALC262_SONY_ASSAMD] = {
12693 .mixers = { alc262_sony_mixer },
12694 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12695 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12696 .dac_nids = alc262_dac_nids,
12697 .hp_nid = 0x02,
12698 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12699 .channel_mode = alc262_modes,
12700 .input_mux = &alc262_capture_source,
12701 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012702 .setup = alc262_hippo_setup,
12703 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012704 },
12705 [ALC262_BENQ_T31] = {
12706 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012707 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12708 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012709 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12710 .dac_nids = alc262_dac_nids,
12711 .hp_nid = 0x03,
12712 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12713 .channel_mode = alc262_modes,
12714 .input_mux = &alc262_capture_source,
12715 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012716 .setup = alc262_hippo_setup,
12717 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012718 },
Tobin Davisf651b502007-10-26 12:40:47 +020012719 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012720 .mixers = { alc262_ultra_mixer },
12721 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012722 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012723 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12724 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012725 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12726 .channel_mode = alc262_modes,
12727 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012728 .adc_nids = alc262_adc_nids, /* ADC0 */
12729 .capsrc_nids = alc262_capsrc_nids,
12730 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012731 .unsol_event = alc262_ultra_unsol_event,
12732 .init_hook = alc262_ultra_automute,
12733 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012734 [ALC262_LENOVO_3000] = {
12735 .mixers = { alc262_lenovo_3000_mixer },
12736 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012737 alc262_lenovo_3000_unsol_verbs,
12738 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012739 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12740 .dac_nids = alc262_dac_nids,
12741 .hp_nid = 0x03,
12742 .dig_out_nid = ALC262_DIGOUT_NID,
12743 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12744 .channel_mode = alc262_modes,
12745 .input_mux = &alc262_fujitsu_capture_source,
12746 .unsol_event = alc262_lenovo_3000_unsol_event,
12747 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012748 [ALC262_NEC] = {
12749 .mixers = { alc262_nec_mixer },
12750 .init_verbs = { alc262_nec_verbs },
12751 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12752 .dac_nids = alc262_dac_nids,
12753 .hp_nid = 0x03,
12754 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12755 .channel_mode = alc262_modes,
12756 .input_mux = &alc262_capture_source,
12757 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012758 [ALC262_TOSHIBA_S06] = {
12759 .mixers = { alc262_toshiba_s06_mixer },
12760 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12761 alc262_eapd_verbs },
12762 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12763 .capsrc_nids = alc262_dmic_capsrc_nids,
12764 .dac_nids = alc262_dac_nids,
12765 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012766 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012767 .dig_out_nid = ALC262_DIGOUT_NID,
12768 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12769 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012770 .unsol_event = alc_sku_unsol_event,
12771 .setup = alc262_toshiba_s06_setup,
12772 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012773 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012774 [ALC262_TOSHIBA_RX1] = {
12775 .mixers = { alc262_toshiba_rx1_mixer },
12776 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12777 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12778 .dac_nids = alc262_dac_nids,
12779 .hp_nid = 0x03,
12780 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12781 .channel_mode = alc262_modes,
12782 .input_mux = &alc262_capture_source,
12783 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012784 .setup = alc262_hippo_setup,
12785 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012786 },
Tony Vroonba340e82009-02-02 19:01:30 +000012787 [ALC262_TYAN] = {
12788 .mixers = { alc262_tyan_mixer },
12789 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12790 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12791 .dac_nids = alc262_dac_nids,
12792 .hp_nid = 0x02,
12793 .dig_out_nid = ALC262_DIGOUT_NID,
12794 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12795 .channel_mode = alc262_modes,
12796 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012797 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012798 .setup = alc262_tyan_setup,
12799 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012800 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012801};
12802
12803static int patch_alc262(struct hda_codec *codec)
12804{
12805 struct alc_spec *spec;
12806 int board_config;
12807 int err;
12808
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012809 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012810 if (spec == NULL)
12811 return -ENOMEM;
12812
12813 codec->spec = spec;
12814#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012815 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12816 * under-run
12817 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012818 {
12819 int tmp;
12820 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12821 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12822 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12823 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12824 }
12825#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012826 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012827
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012828 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12829
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012830 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12831 alc262_models,
12832 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012833
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012834 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012835 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12836 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012837 board_config = ALC262_AUTO;
12838 }
12839
Takashi Iwai18675e42010-09-08 15:55:44 +020012840 if (board_config == ALC262_AUTO)
12841 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 1);
12842
Kailang Yangdf694da2005-12-05 19:42:22 +010012843 if (board_config == ALC262_AUTO) {
12844 /* automatic parse from the BIOS config */
12845 err = alc262_parse_auto_config(codec);
12846 if (err < 0) {
12847 alc_free(codec);
12848 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012849 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012850 printk(KERN_INFO
12851 "hda_codec: Cannot set up configuration "
12852 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012853 board_config = ALC262_BASIC;
12854 }
12855 }
12856
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012857 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012858 err = snd_hda_attach_beep_device(codec, 0x1);
12859 if (err < 0) {
12860 alc_free(codec);
12861 return err;
12862 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012863 }
12864
Kailang Yangdf694da2005-12-05 19:42:22 +010012865 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012866 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012867
Kailang Yangdf694da2005-12-05 19:42:22 +010012868 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12869 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012870
Kailang Yangdf694da2005-12-05 19:42:22 +010012871 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12872 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12873
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012874 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012875 int i;
12876 /* check whether the digital-mic has to be supported */
12877 for (i = 0; i < spec->input_mux->num_items; i++) {
12878 if (spec->input_mux->items[i].index >= 9)
12879 break;
12880 }
12881 if (i < spec->input_mux->num_items) {
12882 /* use only ADC0 */
12883 spec->adc_nids = alc262_dmic_adc_nids;
12884 spec->num_adc_nids = 1;
12885 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012886 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012887 /* all analog inputs */
12888 /* check whether NID 0x07 is valid */
12889 unsigned int wcap = get_wcaps(codec, 0x07);
12890
12891 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012892 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012893 if (wcap != AC_WID_AUD_IN) {
12894 spec->adc_nids = alc262_adc_nids_alt;
12895 spec->num_adc_nids =
12896 ARRAY_SIZE(alc262_adc_nids_alt);
12897 spec->capsrc_nids = alc262_capsrc_nids_alt;
12898 } else {
12899 spec->adc_nids = alc262_adc_nids;
12900 spec->num_adc_nids =
12901 ARRAY_SIZE(alc262_adc_nids);
12902 spec->capsrc_nids = alc262_capsrc_nids;
12903 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012904 }
12905 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012906 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012907 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012908 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012909 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012910
Takashi Iwai18675e42010-09-08 15:55:44 +020012911 if (board_config == ALC262_AUTO)
12912 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 0);
12913
Takashi Iwai2134ea42008-01-10 16:53:55 +010012914 spec->vmaster_nid = 0x0c;
12915
Kailang Yangdf694da2005-12-05 19:42:22 +010012916 codec->patch_ops = alc_patch_ops;
12917 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012918 spec->init_hook = alc262_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020012919
12920 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020012921#ifdef CONFIG_SND_HDA_POWER_SAVE
12922 if (!spec->loopback.amplist)
12923 spec->loopback.amplist = alc262_loopbacks;
12924#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012925
Kailang Yangdf694da2005-12-05 19:42:22 +010012926 return 0;
12927}
12928
Kailang Yangdf694da2005-12-05 19:42:22 +010012929/*
Kailang Yanga361d842007-06-05 12:30:55 +020012930 * ALC268 channel source setting (2 channel)
12931 */
12932#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12933#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012934
Kailang Yanga361d842007-06-05 12:30:55 +020012935static hda_nid_t alc268_dac_nids[2] = {
12936 /* front, hp */
12937 0x02, 0x03
12938};
12939
12940static hda_nid_t alc268_adc_nids[2] = {
12941 /* ADC0-1 */
12942 0x08, 0x07
12943};
12944
12945static hda_nid_t alc268_adc_nids_alt[1] = {
12946 /* ADC0 */
12947 0x08
12948};
12949
Takashi Iwaie1406342008-02-11 18:32:32 +010012950static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12951
Kailang Yanga361d842007-06-05 12:30:55 +020012952static struct snd_kcontrol_new alc268_base_mixer[] = {
12953 /* output mixer control */
12954 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12955 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12956 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12957 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012958 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12959 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12960 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012961 { }
12962};
12963
Takashi Iwai42171c12009-05-08 14:11:43 +020012964static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12965 /* output mixer control */
12966 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12967 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12968 ALC262_HIPPO_MASTER_SWITCH,
12969 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12970 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12971 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12972 { }
12973};
12974
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012975/* bind Beep switches of both NID 0x0f and 0x10 */
12976static struct hda_bind_ctls alc268_bind_beep_sw = {
12977 .ops = &snd_hda_bind_sw,
12978 .values = {
12979 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12980 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12981 0
12982 },
12983};
12984
12985static struct snd_kcontrol_new alc268_beep_mixer[] = {
12986 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12987 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12988 { }
12989};
12990
Kailang Yangd1a991a2007-08-15 16:21:59 +020012991static struct hda_verb alc268_eapd_verbs[] = {
12992 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12993 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12994 { }
12995};
12996
Takashi Iwaid2738092007-08-16 14:59:45 +020012997/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012998static struct hda_verb alc268_toshiba_verbs[] = {
12999 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13000 { } /* end */
13001};
13002
13003/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020013004/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020013005static struct hda_bind_ctls alc268_acer_bind_master_vol = {
13006 .ops = &snd_hda_bind_vol,
13007 .values = {
13008 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13009 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
13010 0
13011 },
13012};
13013
Takashi Iwai889c4392007-08-23 18:56:52 +020013014/* mute/unmute internal speaker according to the hp jack and mute state */
13015static void alc268_acer_automute(struct hda_codec *codec, int force)
13016{
13017 struct alc_spec *spec = codec->spec;
13018 unsigned int mute;
13019
13020 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080013021 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020013022 spec->sense_updated = 1;
13023 }
13024 if (spec->jack_present)
13025 mute = HDA_AMP_MUTE; /* mute internal speaker */
13026 else /* unmute internal speaker if necessary */
13027 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13028 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13029 HDA_AMP_MUTE, mute);
13030}
13031
13032
13033/* bind hp and internal speaker mute (with plug check) */
13034static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
13035 struct snd_ctl_elem_value *ucontrol)
13036{
13037 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
13038 long *valp = ucontrol->value.integer.value;
13039 int change;
13040
Takashi Iwai8de56b72009-07-24 16:51:47 +020013041 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020013042 if (change)
13043 alc268_acer_automute(codec, 0);
13044 return change;
13045}
Takashi Iwaid2738092007-08-16 14:59:45 +020013046
Kailang Yang8ef355d2008-08-26 13:10:22 +020013047static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
13048 /* output mixer control */
13049 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13050 {
13051 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13052 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013053 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013054 .info = snd_hda_mixer_amp_switch_info,
13055 .get = snd_hda_mixer_amp_switch_get,
13056 .put = alc268_acer_master_sw_put,
13057 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13058 },
13059 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13060 { }
13061};
13062
Takashi Iwaid2738092007-08-16 14:59:45 +020013063static struct snd_kcontrol_new alc268_acer_mixer[] = {
13064 /* output mixer control */
13065 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13066 {
13067 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13068 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013069 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013070 .info = snd_hda_mixer_amp_switch_info,
13071 .get = snd_hda_mixer_amp_switch_get,
13072 .put = alc268_acer_master_sw_put,
13073 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13074 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020013075 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13076 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13077 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013078 { }
13079};
13080
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013081static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13082 /* output mixer control */
13083 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13084 {
13085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13086 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013087 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013088 .info = snd_hda_mixer_amp_switch_info,
13089 .get = snd_hda_mixer_amp_switch_get,
13090 .put = alc268_acer_master_sw_put,
13091 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13092 },
13093 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13094 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
13095 { }
13096};
13097
Kailang Yang8ef355d2008-08-26 13:10:22 +020013098static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13099 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13100 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13101 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13102 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13103 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13104 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13105 { }
13106};
13107
Takashi Iwaid2738092007-08-16 14:59:45 +020013108static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013109 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13110 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013111 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13112 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013113 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13114 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013115 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13116 { }
13117};
13118
13119/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013120#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013121#define alc268_toshiba_setup alc262_hippo_setup
13122#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013123
13124static void alc268_acer_unsol_event(struct hda_codec *codec,
13125 unsigned int res)
13126{
Takashi Iwai889c4392007-08-23 18:56:52 +020013127 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013128 return;
13129 alc268_acer_automute(codec, 1);
13130}
13131
Takashi Iwai889c4392007-08-23 18:56:52 +020013132static void alc268_acer_init_hook(struct hda_codec *codec)
13133{
13134 alc268_acer_automute(codec, 1);
13135}
13136
Kailang Yang8ef355d2008-08-26 13:10:22 +020013137/* toggle speaker-output according to the hp-jack state */
13138static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13139{
13140 unsigned int present;
13141 unsigned char bits;
13142
Wu Fengguang864f92b2009-11-18 12:38:02 +080013143 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013144 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013145 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013146 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013147 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013148 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013149}
13150
Kailang Yang8ef355d2008-08-26 13:10:22 +020013151static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13152 unsigned int res)
13153{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013154 switch (res >> 26) {
13155 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013156 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013157 break;
13158 case ALC880_MIC_EVENT:
13159 alc_mic_automute(codec);
13160 break;
13161 }
13162}
13163
13164static void alc268_acer_lc_setup(struct hda_codec *codec)
13165{
13166 struct alc_spec *spec = codec->spec;
13167 spec->ext_mic.pin = 0x18;
13168 spec->ext_mic.mux_idx = 0;
13169 spec->int_mic.pin = 0x12;
13170 spec->int_mic.mux_idx = 6;
13171 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013172}
13173
13174static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13175{
13176 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013177 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013178}
13179
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013180static struct snd_kcontrol_new alc268_dell_mixer[] = {
13181 /* output mixer control */
13182 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13183 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13184 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13185 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13186 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13187 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13188 { }
13189};
13190
13191static struct hda_verb alc268_dell_verbs[] = {
13192 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13193 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13194 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013195 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013196 { }
13197};
13198
13199/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013200static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013201{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013202 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013203
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013204 spec->autocfg.hp_pins[0] = 0x15;
13205 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013206 spec->ext_mic.pin = 0x18;
13207 spec->ext_mic.mux_idx = 0;
13208 spec->int_mic.pin = 0x19;
13209 spec->int_mic.mux_idx = 1;
13210 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013211}
13212
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013213static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13214 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13215 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13216 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13217 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13218 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13219 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
13220 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13221 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13222 { }
13223};
13224
13225static struct hda_verb alc267_quanta_il1_verbs[] = {
13226 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13227 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13228 { }
13229};
13230
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013231static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013232{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013233 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013234 spec->autocfg.hp_pins[0] = 0x15;
13235 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013236 spec->ext_mic.pin = 0x18;
13237 spec->ext_mic.mux_idx = 0;
13238 spec->int_mic.pin = 0x19;
13239 spec->int_mic.mux_idx = 1;
13240 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013241}
13242
Kailang Yanga361d842007-06-05 12:30:55 +020013243/*
13244 * generic initialization of ADC, input mixers and output mixers
13245 */
13246static struct hda_verb alc268_base_init_verbs[] = {
13247 /* Unmute DAC0-1 and set vol = 0 */
13248 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013249 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013250
13251 /*
13252 * Set up output mixers (0x0c - 0x0e)
13253 */
13254 /* set vol=0 to output mixers */
13255 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013256 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13257
13258 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13259 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13260
13261 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13262 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13263 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13264 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13265 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13266 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13267 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13268 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13269
13270 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13271 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13272 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13273 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013274 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013275
13276 /* set PCBEEP vol = 0, mute connections */
13277 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13278 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13279 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013280
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013281 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013282
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013283 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13284 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13285 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013287
Kailang Yanga361d842007-06-05 12:30:55 +020013288 { }
13289};
13290
13291/*
13292 * generic initialization of ADC, input mixers and output mixers
13293 */
13294static struct hda_verb alc268_volume_init_verbs[] = {
13295 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013296 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13297 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013298
13299 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13300 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13301 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13302 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13303 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13304
Kailang Yanga361d842007-06-05 12:30:55 +020013305 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013306 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13307 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13308
13309 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013310 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013311
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013312 /* set PCBEEP vol = 0, mute connections */
13313 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13314 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13315 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013316
13317 { }
13318};
13319
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013320static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13321 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13322 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13323 { } /* end */
13324};
13325
Kailang Yanga361d842007-06-05 12:30:55 +020013326static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13327 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13328 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013329 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013330 { } /* end */
13331};
13332
13333static struct snd_kcontrol_new alc268_capture_mixer[] = {
13334 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13335 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13336 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13337 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013338 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013339 { } /* end */
13340};
13341
13342static struct hda_input_mux alc268_capture_source = {
13343 .num_items = 4,
13344 .items = {
13345 { "Mic", 0x0 },
13346 { "Front Mic", 0x1 },
13347 { "Line", 0x2 },
13348 { "CD", 0x3 },
13349 },
13350};
13351
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013352static struct hda_input_mux alc268_acer_capture_source = {
13353 .num_items = 3,
13354 .items = {
13355 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013356 { "Internal Mic", 0x1 },
13357 { "Line", 0x2 },
13358 },
13359};
13360
13361static struct hda_input_mux alc268_acer_dmic_capture_source = {
13362 .num_items = 3,
13363 .items = {
13364 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013365 { "Internal Mic", 0x6 },
13366 { "Line", 0x2 },
13367 },
13368};
13369
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013370#ifdef CONFIG_SND_DEBUG
13371static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013372 /* Volume widgets */
13373 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13374 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13375 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13376 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13377 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13378 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13379 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13380 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13381 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13382 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13383 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13384 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13385 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013386 /* The below appears problematic on some hardwares */
13387 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013388 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13389 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13390 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13391 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13392
13393 /* Modes for retasking pin widgets */
13394 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13395 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13396 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13397 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13398
13399 /* Controls for GPIO pins, assuming they are configured as outputs */
13400 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13401 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13402 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13403 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13404
13405 /* Switches to allow the digital SPDIF output pin to be enabled.
13406 * The ALC268 does not have an SPDIF input.
13407 */
13408 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13409
13410 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13411 * this output to turn on an external amplifier.
13412 */
13413 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13414 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13415
13416 { } /* end */
13417};
13418#endif
13419
Kailang Yanga361d842007-06-05 12:30:55 +020013420/* create input playback/capture controls for the given pin */
13421static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13422 const char *ctlname, int idx)
13423{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013424 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013425 int err;
13426
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013427 switch (nid) {
13428 case 0x14:
13429 case 0x16:
13430 dac = 0x02;
13431 break;
13432 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013433 case 0x1a: /* ALC259/269 only */
13434 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013435 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013436 dac = 0x03;
13437 break;
13438 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013439 snd_printd(KERN_WARNING "hda_codec: "
13440 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013441 return 0;
13442 }
13443 if (spec->multiout.dac_nids[0] != dac &&
13444 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013445 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013446 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013447 HDA_OUTPUT));
13448 if (err < 0)
13449 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013450 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13451 }
13452
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013453 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013454 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013455 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013456 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013457 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013458 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013459 if (err < 0)
13460 return err;
13461 return 0;
13462}
13463
13464/* add playback controls from the parsed DAC table */
13465static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13466 const struct auto_pin_cfg *cfg)
13467{
13468 hda_nid_t nid;
13469 int err;
13470
Kailang Yanga361d842007-06-05 12:30:55 +020013471 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013472
13473 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013474 if (nid) {
13475 const char *name;
13476 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13477 name = "Speaker";
13478 else
13479 name = "Front";
13480 err = alc268_new_analog_output(spec, nid, name, 0);
13481 if (err < 0)
13482 return err;
13483 }
Kailang Yanga361d842007-06-05 12:30:55 +020013484
13485 nid = cfg->speaker_pins[0];
13486 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013487 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013488 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13489 if (err < 0)
13490 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013491 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013492 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13493 if (err < 0)
13494 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013495 }
13496 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013497 if (nid) {
13498 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13499 if (err < 0)
13500 return err;
13501 }
Kailang Yanga361d842007-06-05 12:30:55 +020013502
13503 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13504 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013505 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013506 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013507 if (err < 0)
13508 return err;
13509 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013510 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013511}
13512
13513/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013514static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013515 const struct auto_pin_cfg *cfg)
13516{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013517 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013518}
13519
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013520static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13521 hda_nid_t nid, int pin_type)
13522{
13523 int idx;
13524
13525 alc_set_pin_output(codec, nid, pin_type);
13526 if (nid == 0x14 || nid == 0x16)
13527 idx = 0;
13528 else
13529 idx = 1;
13530 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13531}
13532
13533static void alc268_auto_init_multi_out(struct hda_codec *codec)
13534{
13535 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013536 int i;
13537
13538 for (i = 0; i < spec->autocfg.line_outs; i++) {
13539 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013540 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13541 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13542 }
13543}
13544
13545static void alc268_auto_init_hp_out(struct hda_codec *codec)
13546{
13547 struct alc_spec *spec = codec->spec;
13548 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013549 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013550
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013551 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13552 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013553 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013554 }
13555 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13556 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013557 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013558 }
13559 if (spec->autocfg.mono_out_pin)
13560 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13561 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013562}
13563
Kailang Yanga361d842007-06-05 12:30:55 +020013564static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13565{
13566 struct alc_spec *spec = codec->spec;
13567 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13568 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13569 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13570 unsigned int dac_vol1, dac_vol2;
13571
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013572 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013573 snd_hda_codec_write(codec, speaker_nid, 0,
13574 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013575 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013576 snd_hda_codec_write(codec, 0x0f, 0,
13577 AC_VERB_SET_AMP_GAIN_MUTE,
13578 AMP_IN_UNMUTE(1));
13579 snd_hda_codec_write(codec, 0x10, 0,
13580 AC_VERB_SET_AMP_GAIN_MUTE,
13581 AMP_IN_UNMUTE(1));
13582 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013583 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013584 snd_hda_codec_write(codec, 0x0f, 0,
13585 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13586 snd_hda_codec_write(codec, 0x10, 0,
13587 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13588 }
13589
13590 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013591 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013592 dac_vol2 = AMP_OUT_ZERO;
13593 else if (line_nid == 0x15)
13594 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013595 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013596 dac_vol2 = AMP_OUT_ZERO;
13597 else if (hp_nid == 0x15)
13598 dac_vol1 = AMP_OUT_ZERO;
13599 if (line_nid != 0x16 || hp_nid != 0x16 ||
13600 spec->autocfg.line_out_pins[1] != 0x16 ||
13601 spec->autocfg.line_out_pins[2] != 0x16)
13602 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13603
13604 snd_hda_codec_write(codec, 0x02, 0,
13605 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13606 snd_hda_codec_write(codec, 0x03, 0,
13607 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13608}
13609
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013610/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013611#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13612#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013613#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013614#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13615
13616/*
13617 * BIOS auto configuration
13618 */
13619static int alc268_parse_auto_config(struct hda_codec *codec)
13620{
13621 struct alc_spec *spec = codec->spec;
13622 int err;
13623 static hda_nid_t alc268_ignore[] = { 0 };
13624
13625 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13626 alc268_ignore);
13627 if (err < 0)
13628 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013629 if (!spec->autocfg.line_outs) {
13630 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13631 spec->multiout.max_channels = 2;
13632 spec->no_analog = 1;
13633 goto dig_only;
13634 }
Kailang Yanga361d842007-06-05 12:30:55 +020013635 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013636 }
Kailang Yanga361d842007-06-05 12:30:55 +020013637 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13638 if (err < 0)
13639 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013640 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013641 if (err < 0)
13642 return err;
13643
13644 spec->multiout.max_channels = 2;
13645
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013646 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013647 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013648 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013649 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013650 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013651
Takashi Iwai892981f2009-03-02 08:04:35 +010013652 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013653 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013654
Takashi Iwaid88897e2008-10-31 15:01:37 +010013655 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013656 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013657 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013658
Takashi Iwai776e1842007-08-29 15:07:11 +020013659 err = alc_auto_add_mic_boost(codec);
13660 if (err < 0)
13661 return err;
13662
Kailang Yang6227cdc2010-02-25 08:36:52 +010013663 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013664
Kailang Yanga361d842007-06-05 12:30:55 +020013665 return 1;
13666}
13667
Kailang Yanga361d842007-06-05 12:30:55 +020013668#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13669
13670/* init callback for auto-configuration model -- overriding the default init */
13671static void alc268_auto_init(struct hda_codec *codec)
13672{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013673 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013674 alc268_auto_init_multi_out(codec);
13675 alc268_auto_init_hp_out(codec);
13676 alc268_auto_init_mono_speaker_out(codec);
13677 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013678 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013679 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013680 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013681}
13682
13683/*
13684 * configuration and preset
13685 */
13686static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013687 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013688 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013689 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013690 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013691 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013692 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013693 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013694 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013695#ifdef CONFIG_SND_DEBUG
13696 [ALC268_TEST] = "test",
13697#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013698 [ALC268_AUTO] = "auto",
13699};
13700
13701static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013702 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013703 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013704 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013705 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013706 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013707 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13708 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013709 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013710 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13711 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013712 /* almost compatible with toshiba but with optional digital outs;
13713 * auto-probing seems working fine
13714 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013715 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013716 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013717 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013718 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013719 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013720 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013721 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013722 {}
13723};
13724
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013725/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13726static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13727 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13728 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13729 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13730 ALC268_TOSHIBA),
13731 {}
13732};
13733
Kailang Yanga361d842007-06-05 12:30:55 +020013734static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013735 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013736 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13737 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013738 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13739 alc267_quanta_il1_verbs },
13740 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13741 .dac_nids = alc268_dac_nids,
13742 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13743 .adc_nids = alc268_adc_nids_alt,
13744 .hp_nid = 0x03,
13745 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13746 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013747 .unsol_event = alc_sku_unsol_event,
13748 .setup = alc267_quanta_il1_setup,
13749 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013750 },
Kailang Yanga361d842007-06-05 12:30:55 +020013751 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013752 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13753 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013754 .init_verbs = { alc268_base_init_verbs },
13755 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13756 .dac_nids = alc268_dac_nids,
13757 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13758 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013759 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013760 .hp_nid = 0x03,
13761 .dig_out_nid = ALC268_DIGOUT_NID,
13762 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13763 .channel_mode = alc268_modes,
13764 .input_mux = &alc268_capture_source,
13765 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013766 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013767 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013768 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013769 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13770 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013771 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13772 .dac_nids = alc268_dac_nids,
13773 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13774 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013775 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013776 .hp_nid = 0x03,
13777 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13778 .channel_mode = alc268_modes,
13779 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013780 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013781 .setup = alc268_toshiba_setup,
13782 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013783 },
13784 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013785 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013786 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013787 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13788 alc268_acer_verbs },
13789 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13790 .dac_nids = alc268_dac_nids,
13791 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13792 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013793 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013794 .hp_nid = 0x02,
13795 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13796 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013797 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013798 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013799 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013800 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013801 [ALC268_ACER_DMIC] = {
13802 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13803 alc268_beep_mixer },
13804 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13805 alc268_acer_verbs },
13806 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13807 .dac_nids = alc268_dac_nids,
13808 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13809 .adc_nids = alc268_adc_nids_alt,
13810 .capsrc_nids = alc268_capsrc_nids,
13811 .hp_nid = 0x02,
13812 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13813 .channel_mode = alc268_modes,
13814 .input_mux = &alc268_acer_dmic_capture_source,
13815 .unsol_event = alc268_acer_unsol_event,
13816 .init_hook = alc268_acer_init_hook,
13817 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013818 [ALC268_ACER_ASPIRE_ONE] = {
13819 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013820 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013821 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013822 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13823 alc268_acer_aspire_one_verbs },
13824 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13825 .dac_nids = alc268_dac_nids,
13826 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13827 .adc_nids = alc268_adc_nids_alt,
13828 .capsrc_nids = alc268_capsrc_nids,
13829 .hp_nid = 0x03,
13830 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13831 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013832 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013833 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013834 .init_hook = alc268_acer_lc_init_hook,
13835 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013836 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013837 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13838 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013839 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13840 alc268_dell_verbs },
13841 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13842 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013843 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13844 .adc_nids = alc268_adc_nids_alt,
13845 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013846 .hp_nid = 0x02,
13847 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13848 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013849 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013850 .setup = alc268_dell_setup,
13851 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013852 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013853 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013854 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13855 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013856 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13857 alc268_toshiba_verbs },
13858 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13859 .dac_nids = alc268_dac_nids,
13860 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13861 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013862 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013863 .hp_nid = 0x03,
13864 .dig_out_nid = ALC268_DIGOUT_NID,
13865 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13866 .channel_mode = alc268_modes,
13867 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013868 .setup = alc268_toshiba_setup,
13869 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013870 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013871#ifdef CONFIG_SND_DEBUG
13872 [ALC268_TEST] = {
13873 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13874 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13875 alc268_volume_init_verbs },
13876 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13877 .dac_nids = alc268_dac_nids,
13878 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13879 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013880 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013881 .hp_nid = 0x03,
13882 .dig_out_nid = ALC268_DIGOUT_NID,
13883 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13884 .channel_mode = alc268_modes,
13885 .input_mux = &alc268_capture_source,
13886 },
13887#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013888};
13889
13890static int patch_alc268(struct hda_codec *codec)
13891{
13892 struct alc_spec *spec;
13893 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013894 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013895
Julia Lawallef86f582009-12-19 08:18:03 +010013896 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013897 if (spec == NULL)
13898 return -ENOMEM;
13899
13900 codec->spec = spec;
13901
13902 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13903 alc268_models,
13904 alc268_cfg_tbl);
13905
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013906 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13907 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013908 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013909
Kailang Yanga361d842007-06-05 12:30:55 +020013910 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013911 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13912 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013913 board_config = ALC268_AUTO;
13914 }
13915
13916 if (board_config == ALC268_AUTO) {
13917 /* automatic parse from the BIOS config */
13918 err = alc268_parse_auto_config(codec);
13919 if (err < 0) {
13920 alc_free(codec);
13921 return err;
13922 } else if (!err) {
13923 printk(KERN_INFO
13924 "hda_codec: Cannot set up configuration "
13925 "from BIOS. Using base mode...\n");
13926 board_config = ALC268_3ST;
13927 }
13928 }
13929
13930 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013931 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013932
Kailang Yanga361d842007-06-05 12:30:55 +020013933 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13934 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013935 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013936
Kailang Yanga361d842007-06-05 12:30:55 +020013937 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13938
Takashi Iwai22971e32009-02-10 11:56:44 +010013939 has_beep = 0;
13940 for (i = 0; i < spec->num_mixers; i++) {
13941 if (spec->mixers[i] == alc268_beep_mixer) {
13942 has_beep = 1;
13943 break;
13944 }
13945 }
13946
13947 if (has_beep) {
13948 err = snd_hda_attach_beep_device(codec, 0x1);
13949 if (err < 0) {
13950 alc_free(codec);
13951 return err;
13952 }
13953 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13954 /* override the amp caps for beep generator */
13955 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013956 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13957 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13958 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13959 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013960 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013961
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013962 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013963 /* check whether NID 0x07 is valid */
13964 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013965 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013966
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013967 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013968 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013969 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013970 if (spec->auto_mic ||
13971 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013972 spec->adc_nids = alc268_adc_nids_alt;
13973 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013974 if (spec->auto_mic)
13975 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013976 if (spec->auto_mic || spec->input_mux->num_items == 1)
13977 add_mixer(spec, alc268_capture_nosrc_mixer);
13978 else
13979 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013980 } else {
13981 spec->adc_nids = alc268_adc_nids;
13982 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013983 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013984 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013985 /* set default input source */
13986 for (i = 0; i < spec->num_adc_nids; i++)
13987 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13988 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013989 i < spec->num_mux_defs ?
13990 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013991 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013992 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013993
13994 spec->vmaster_nid = 0x02;
13995
Kailang Yanga361d842007-06-05 12:30:55 +020013996 codec->patch_ops = alc_patch_ops;
13997 if (board_config == ALC268_AUTO)
13998 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013999
Kailang Yangbf1b0222010-10-21 08:49:56 +020014000 alc_init_jacks(codec);
14001
Kailang Yanga361d842007-06-05 12:30:55 +020014002 return 0;
14003}
14004
14005/*
Kailang Yangf6a92242007-12-13 16:52:54 +010014006 * ALC269 channel source setting (2 channel)
14007 */
14008#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
14009
14010#define alc269_dac_nids alc260_dac_nids
14011
14012static hda_nid_t alc269_adc_nids[1] = {
14013 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020014014 0x08,
14015};
14016
Takashi Iwaie01bf502008-08-21 16:25:07 +020014017static hda_nid_t alc269_capsrc_nids[1] = {
14018 0x23,
14019};
14020
Kailang Yang84898e82010-02-04 14:16:14 +010014021static hda_nid_t alc269vb_adc_nids[1] = {
14022 /* ADC1 */
14023 0x09,
14024};
14025
14026static hda_nid_t alc269vb_capsrc_nids[1] = {
14027 0x22,
14028};
14029
Takashi Iwai66946352010-03-29 17:21:45 +020014030static hda_nid_t alc269_adc_candidates[] = {
14031 0x08, 0x09, 0x07,
14032};
Takashi Iwaie01bf502008-08-21 16:25:07 +020014033
Kailang Yangf6a92242007-12-13 16:52:54 +010014034#define alc269_modes alc260_modes
14035#define alc269_capture_source alc880_lg_lw_capture_source
14036
14037static struct snd_kcontrol_new alc269_base_mixer[] = {
14038 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14039 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14040 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14041 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14042 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14043 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14044 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14045 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14046 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14047 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14048 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14049 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14050 { } /* end */
14051};
14052
Kailang Yang60db6b52008-08-26 13:13:00 +020014053static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14054 /* output mixer control */
14055 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14056 {
14057 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14058 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014059 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014060 .info = snd_hda_mixer_amp_switch_info,
14061 .get = snd_hda_mixer_amp_switch_get,
14062 .put = alc268_acer_master_sw_put,
14063 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14064 },
14065 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14066 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14067 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14068 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14069 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14070 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014071 { }
14072};
14073
Tony Vroon64154832008-11-06 15:08:49 +000014074static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14075 /* output mixer control */
14076 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14077 {
14078 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14079 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014080 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014081 .info = snd_hda_mixer_amp_switch_info,
14082 .get = snd_hda_mixer_amp_switch_get,
14083 .put = alc268_acer_master_sw_put,
14084 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14085 },
14086 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14087 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14088 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14089 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14090 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14091 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
14092 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14093 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
14094 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014095 { }
14096};
14097
Kailang Yang84898e82010-02-04 14:16:14 +010014098static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014099 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014100 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014101 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014102 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014103 { } /* end */
14104};
14105
Kailang Yang84898e82010-02-04 14:16:14 +010014106static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14107 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14108 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14109 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14110 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14111 { } /* end */
14112};
14113
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014114static struct snd_kcontrol_new alc269_asus_mixer[] = {
14115 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14116 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14117 { } /* end */
14118};
14119
Kailang Yangf6a92242007-12-13 16:52:54 +010014120/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014121static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14122 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14123 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
14124 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14125 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14126 { } /* end */
14127};
14128
14129static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014130 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14131 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014132 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14133 { } /* end */
14134};
14135
Kailang Yang84898e82010-02-04 14:16:14 +010014136static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14137 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14138 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14139 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14140 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14141 { } /* end */
14142};
14143
14144static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14145 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14146 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14147 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14148 { } /* end */
14149};
14150
Takashi Iwai26f5df22008-11-03 17:39:46 +010014151/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014152#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014153
Kailang Yang60db6b52008-08-26 13:13:00 +020014154static struct hda_verb alc269_quanta_fl1_verbs[] = {
14155 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14156 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14157 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14158 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14159 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14160 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14161 { }
14162};
14163
Tony Vroon64154832008-11-06 15:08:49 +000014164static struct hda_verb alc269_lifebook_verbs[] = {
14165 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14166 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14167 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14168 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14169 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14170 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14171 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14172 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14173 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14174 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14175 { }
14176};
14177
Kailang Yang60db6b52008-08-26 13:13:00 +020014178/* toggle speaker-output according to the hp-jack state */
14179static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14180{
14181 unsigned int present;
14182 unsigned char bits;
14183
Wu Fengguang864f92b2009-11-18 12:38:02 +080014184 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014185 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014186 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014187 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014188 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014189 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014190
14191 snd_hda_codec_write(codec, 0x20, 0,
14192 AC_VERB_SET_COEF_INDEX, 0x0c);
14193 snd_hda_codec_write(codec, 0x20, 0,
14194 AC_VERB_SET_PROC_COEF, 0x680);
14195
14196 snd_hda_codec_write(codec, 0x20, 0,
14197 AC_VERB_SET_COEF_INDEX, 0x0c);
14198 snd_hda_codec_write(codec, 0x20, 0,
14199 AC_VERB_SET_PROC_COEF, 0x480);
14200}
14201
Tony Vroon64154832008-11-06 15:08:49 +000014202/* toggle speaker-output according to the hp-jacks state */
14203static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14204{
14205 unsigned int present;
14206 unsigned char bits;
14207
14208 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014209 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014210
14211 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014212 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014213
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014214 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014215 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014216 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014217 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014218 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014219
14220 snd_hda_codec_write(codec, 0x20, 0,
14221 AC_VERB_SET_COEF_INDEX, 0x0c);
14222 snd_hda_codec_write(codec, 0x20, 0,
14223 AC_VERB_SET_PROC_COEF, 0x680);
14224
14225 snd_hda_codec_write(codec, 0x20, 0,
14226 AC_VERB_SET_COEF_INDEX, 0x0c);
14227 snd_hda_codec_write(codec, 0x20, 0,
14228 AC_VERB_SET_PROC_COEF, 0x480);
14229}
14230
Tony Vroon64154832008-11-06 15:08:49 +000014231static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14232{
14233 unsigned int present_laptop;
14234 unsigned int present_dock;
14235
Wu Fengguang864f92b2009-11-18 12:38:02 +080014236 present_laptop = snd_hda_jack_detect(codec, 0x18);
14237 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014238
14239 /* Laptop mic port overrides dock mic port, design decision */
14240 if (present_dock)
14241 snd_hda_codec_write(codec, 0x23, 0,
14242 AC_VERB_SET_CONNECT_SEL, 0x3);
14243 if (present_laptop)
14244 snd_hda_codec_write(codec, 0x23, 0,
14245 AC_VERB_SET_CONNECT_SEL, 0x0);
14246 if (!present_dock && !present_laptop)
14247 snd_hda_codec_write(codec, 0x23, 0,
14248 AC_VERB_SET_CONNECT_SEL, 0x1);
14249}
14250
Kailang Yang60db6b52008-08-26 13:13:00 +020014251static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14252 unsigned int res)
14253{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014254 switch (res >> 26) {
14255 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014256 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014257 break;
14258 case ALC880_MIC_EVENT:
14259 alc_mic_automute(codec);
14260 break;
14261 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014262}
14263
Tony Vroon64154832008-11-06 15:08:49 +000014264static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14265 unsigned int res)
14266{
14267 if ((res >> 26) == ALC880_HP_EVENT)
14268 alc269_lifebook_speaker_automute(codec);
14269 if ((res >> 26) == ALC880_MIC_EVENT)
14270 alc269_lifebook_mic_autoswitch(codec);
14271}
14272
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014273static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14274{
14275 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014276 spec->autocfg.hp_pins[0] = 0x15;
14277 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014278 spec->ext_mic.pin = 0x18;
14279 spec->ext_mic.mux_idx = 0;
14280 spec->int_mic.pin = 0x19;
14281 spec->int_mic.mux_idx = 1;
14282 spec->auto_mic = 1;
14283}
14284
Kailang Yang60db6b52008-08-26 13:13:00 +020014285static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14286{
14287 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014288 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014289}
14290
Tony Vroon64154832008-11-06 15:08:49 +000014291static void alc269_lifebook_init_hook(struct hda_codec *codec)
14292{
14293 alc269_lifebook_speaker_automute(codec);
14294 alc269_lifebook_mic_autoswitch(codec);
14295}
14296
Kailang Yang84898e82010-02-04 14:16:14 +010014297static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014298 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14299 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14300 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14301 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14302 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14303 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14304 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14305 {}
14306};
14307
Kailang Yang84898e82010-02-04 14:16:14 +010014308static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014309 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14310 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14311 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14312 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14313 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14314 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14315 {}
14316};
14317
Kailang Yang84898e82010-02-04 14:16:14 +010014318static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14319 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14320 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14321 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14322 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14323 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14324 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14325 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14326 {}
14327};
14328
14329static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14330 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14331 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14332 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14333 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14334 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14335 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14336 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14337 {}
14338};
14339
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014340static struct hda_verb alc271_acer_dmic_verbs[] = {
14341 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14342 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14343 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14344 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14345 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14346 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14347 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14348 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14349 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14350 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14351 { }
14352};
14353
Kailang Yang60db6b52008-08-26 13:13:00 +020014354/* toggle speaker-output according to the hp-jack state */
14355static void alc269_speaker_automute(struct hda_codec *codec)
14356{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014357 struct alc_spec *spec = codec->spec;
14358 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014359 unsigned int present;
14360 unsigned char bits;
14361
Kailang Yangebb83ee2009-12-17 12:23:00 +010014362 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014363 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014364 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014365 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014366 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014367 HDA_AMP_MUTE, bits);
Kailang Yangbf1b0222010-10-21 08:49:56 +020014368 alc_report_jack(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020014369}
14370
Kailang Yang60db6b52008-08-26 13:13:00 +020014371/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014372static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014373 unsigned int res)
14374{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014375 switch (res >> 26) {
14376 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014377 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014378 break;
14379 case ALC880_MIC_EVENT:
14380 alc_mic_automute(codec);
14381 break;
14382 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014383}
14384
Kailang Yang226b1ec2010-04-09 11:01:20 +020014385static void alc269_laptop_amic_setup(struct hda_codec *codec)
14386{
14387 struct alc_spec *spec = codec->spec;
14388 spec->autocfg.hp_pins[0] = 0x15;
14389 spec->autocfg.speaker_pins[0] = 0x14;
14390 spec->ext_mic.pin = 0x18;
14391 spec->ext_mic.mux_idx = 0;
14392 spec->int_mic.pin = 0x19;
14393 spec->int_mic.mux_idx = 1;
14394 spec->auto_mic = 1;
14395}
14396
Kailang Yang84898e82010-02-04 14:16:14 +010014397static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014398{
14399 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014400 spec->autocfg.hp_pins[0] = 0x15;
14401 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014402 spec->ext_mic.pin = 0x18;
14403 spec->ext_mic.mux_idx = 0;
14404 spec->int_mic.pin = 0x12;
14405 spec->int_mic.mux_idx = 5;
14406 spec->auto_mic = 1;
14407}
14408
Kailang Yang226b1ec2010-04-09 11:01:20 +020014409static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014410{
14411 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014412 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014413 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014414 spec->ext_mic.pin = 0x18;
14415 spec->ext_mic.mux_idx = 0;
14416 spec->int_mic.pin = 0x19;
14417 spec->int_mic.mux_idx = 1;
14418 spec->auto_mic = 1;
14419}
14420
Kailang Yang226b1ec2010-04-09 11:01:20 +020014421static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14422{
14423 struct alc_spec *spec = codec->spec;
14424 spec->autocfg.hp_pins[0] = 0x21;
14425 spec->autocfg.speaker_pins[0] = 0x14;
14426 spec->ext_mic.pin = 0x18;
14427 spec->ext_mic.mux_idx = 0;
14428 spec->int_mic.pin = 0x12;
14429 spec->int_mic.mux_idx = 6;
14430 spec->auto_mic = 1;
14431}
14432
Kailang Yang84898e82010-02-04 14:16:14 +010014433static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014434{
14435 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014436 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014437}
14438
Kailang Yangf6a92242007-12-13 16:52:54 +010014439/*
14440 * generic initialization of ADC, input mixers and output mixers
14441 */
14442static struct hda_verb alc269_init_verbs[] = {
14443 /*
14444 * Unmute ADC0 and set the default input to mic-in
14445 */
Kailang Yang84898e82010-02-04 14:16:14 +010014446 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014447
14448 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014449 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014450 */
14451 /* set vol=0 to output mixers */
14452 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14453 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14454
14455 /* set up input amps for analog loopback */
14456 /* Amp Indices: DAC = 0, mixer = 1 */
14457 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14458 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14459 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14460 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14461 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14462 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14463
14464 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14465 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14466 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14467 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14468 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14469 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14470 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14471
14472 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14473 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014474
Kailang Yang84898e82010-02-04 14:16:14 +010014475 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014476 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14477 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014478 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014479
14480 /* set EAPD */
14481 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014482 { }
14483};
14484
14485static struct hda_verb alc269vb_init_verbs[] = {
14486 /*
14487 * Unmute ADC0 and set the default input to mic-in
14488 */
14489 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14490
14491 /*
14492 * Set up output mixers (0x02 - 0x03)
14493 */
14494 /* set vol=0 to output mixers */
14495 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14496 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14497
14498 /* set up input amps for analog loopback */
14499 /* Amp Indices: DAC = 0, mixer = 1 */
14500 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14502 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14503 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14504 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14505 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14506
14507 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14508 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14509 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14510 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14511 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14512 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14513 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14514
14515 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14516 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14517
14518 /* FIXME: use Mux-type input source selection */
14519 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14520 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14521 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14522
14523 /* set EAPD */
14524 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014525 { }
14526};
14527
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014528#define alc269_auto_create_multi_out_ctls \
14529 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014530#define alc269_auto_create_input_ctls \
14531 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014532
14533#ifdef CONFIG_SND_HDA_POWER_SAVE
14534#define alc269_loopbacks alc880_loopbacks
14535#endif
14536
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014537/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014538#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14539#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14540#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14541#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14542
Takashi Iwaif03d3112009-03-05 14:18:16 +010014543static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14544 .substreams = 1,
14545 .channels_min = 2,
14546 .channels_max = 8,
14547 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14548 /* NID is set in alc_build_pcms */
14549 .ops = {
14550 .open = alc880_playback_pcm_open,
14551 .prepare = alc880_playback_pcm_prepare,
14552 .cleanup = alc880_playback_pcm_cleanup
14553 },
14554};
14555
14556static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14557 .substreams = 1,
14558 .channels_min = 2,
14559 .channels_max = 2,
14560 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14561 /* NID is set in alc_build_pcms */
14562};
14563
Takashi Iwaiad358792010-03-30 18:00:59 +020014564#ifdef CONFIG_SND_HDA_POWER_SAVE
14565static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14566{
14567 switch (codec->subsystem_id) {
14568 case 0x103c1586:
14569 return 1;
14570 }
14571 return 0;
14572}
14573
14574static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14575{
14576 /* update mute-LED according to the speaker mute state */
14577 if (nid == 0x01 || nid == 0x14) {
14578 int pinval;
14579 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14580 HDA_AMP_MUTE)
14581 pinval = 0x24;
14582 else
14583 pinval = 0x20;
14584 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014585 snd_hda_codec_update_cache(codec, 0x19, 0,
14586 AC_VERB_SET_PIN_WIDGET_CONTROL,
14587 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014588 }
14589 return alc_check_power_status(codec, nid);
14590}
14591#endif /* CONFIG_SND_HDA_POWER_SAVE */
14592
Takashi Iwai840b64c2010-07-13 22:49:01 +020014593static int alc275_setup_dual_adc(struct hda_codec *codec)
14594{
14595 struct alc_spec *spec = codec->spec;
14596
14597 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14598 return 0;
14599 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14600 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14601 if (spec->ext_mic.pin <= 0x12) {
14602 spec->private_adc_nids[0] = 0x08;
14603 spec->private_adc_nids[1] = 0x11;
14604 spec->private_capsrc_nids[0] = 0x23;
14605 spec->private_capsrc_nids[1] = 0x22;
14606 } else {
14607 spec->private_adc_nids[0] = 0x11;
14608 spec->private_adc_nids[1] = 0x08;
14609 spec->private_capsrc_nids[0] = 0x22;
14610 spec->private_capsrc_nids[1] = 0x23;
14611 }
14612 spec->adc_nids = spec->private_adc_nids;
14613 spec->capsrc_nids = spec->private_capsrc_nids;
14614 spec->num_adc_nids = 2;
14615 spec->dual_adc_switch = 1;
14616 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14617 spec->adc_nids[0], spec->adc_nids[1]);
14618 return 1;
14619 }
14620 return 0;
14621}
14622
Takashi Iwaid433a672010-09-20 15:11:54 +020014623/* different alc269-variants */
14624enum {
14625 ALC269_TYPE_NORMAL,
Kailang Yang48c88e82010-11-23 08:56:16 +010014626 ALC269_TYPE_ALC258,
Takashi Iwaid433a672010-09-20 15:11:54 +020014627 ALC269_TYPE_ALC259,
Kailang Yang48c88e82010-11-23 08:56:16 +010014628 ALC269_TYPE_ALC269VB,
14629 ALC269_TYPE_ALC270,
Takashi Iwaid433a672010-09-20 15:11:54 +020014630 ALC269_TYPE_ALC271X,
14631};
14632
Kailang Yangf6a92242007-12-13 16:52:54 +010014633/*
14634 * BIOS auto configuration
14635 */
14636static int alc269_parse_auto_config(struct hda_codec *codec)
14637{
14638 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014639 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014640 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14641
14642 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14643 alc269_ignore);
14644 if (err < 0)
14645 return err;
14646
14647 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14648 if (err < 0)
14649 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014650 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14651 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14652 else
14653 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14654 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014655 if (err < 0)
14656 return err;
14657
14658 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14659
Takashi Iwai757899a2010-07-30 10:48:14 +020014660 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014661
Takashi Iwai603c4012008-07-30 15:01:44 +020014662 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014663 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014664
Takashi Iwaid433a672010-09-20 15:11:54 +020014665 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014666 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014667 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014668 } else {
14669 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014670 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014671 }
14672
Kailang Yangf6a92242007-12-13 16:52:54 +010014673 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014674 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014675
14676 if (!alc275_setup_dual_adc(codec))
14677 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14678 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014679
Takashi Iwaie01bf502008-08-21 16:25:07 +020014680 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014681 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014682 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14683 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014684
14685 err = alc_auto_add_mic_boost(codec);
14686 if (err < 0)
14687 return err;
14688
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014689 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014690 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014691
Kailang Yangf6a92242007-12-13 16:52:54 +010014692 return 1;
14693}
14694
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014695#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14696#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014697#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14698
14699
14700/* init callback for auto-configuration model -- overriding the default init */
14701static void alc269_auto_init(struct hda_codec *codec)
14702{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014703 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014704 alc269_auto_init_multi_out(codec);
14705 alc269_auto_init_hp_out(codec);
14706 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014707 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014708 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014709 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014710}
14711
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014712#ifdef SND_HDA_NEEDS_RESUME
14713static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14714{
14715 int val = alc_read_coef_idx(codec, 0x04);
14716 if (power_up)
14717 val |= 1 << 11;
14718 else
14719 val &= ~(1 << 11);
14720 alc_write_coef_idx(codec, 0x04, val);
14721}
14722
Kailang Yang977ddd62010-09-15 10:02:29 +020014723#ifdef CONFIG_SND_HDA_POWER_SAVE
14724static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14725{
14726 struct alc_spec *spec = codec->spec;
Kailang Yang977ddd62010-09-15 10:02:29 +020014727
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014728 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14729 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014730 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014731 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014732 msleep(150);
14733 }
14734
14735 alc_shutup(codec);
14736 if (spec && spec->power_hook)
14737 spec->power_hook(codec);
14738 return 0;
14739}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014740#endif /* CONFIG_SND_HDA_POWER_SAVE */
14741
Kailang Yang977ddd62010-09-15 10:02:29 +020014742static int alc269_resume(struct hda_codec *codec)
14743{
Kailang Yang977ddd62010-09-15 10:02:29 +020014744 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014745 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014746 msleep(150);
14747 }
14748
14749 codec->patch_ops.init(codec);
14750
14751 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014752 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014753 msleep(200);
14754 }
14755
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014756 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14757 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014758
14759 snd_hda_codec_resume_amp(codec);
14760 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014761 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014762 return 0;
14763}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014764#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014765
Takashi Iwaiff818c22010-04-12 08:59:25 +020014766enum {
14767 ALC269_FIXUP_SONY_VAIO,
David Henningsson145a9022010-09-16 10:07:53 +020014768 ALC269_FIXUP_DELL_M101Z,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014769};
14770
Takashi Iwaiff818c22010-04-12 08:59:25 +020014771static const struct alc_fixup alc269_fixups[] = {
14772 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020014773 .verbs = (const struct hda_verb[]) {
14774 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14775 {}
14776 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014777 },
David Henningsson145a9022010-09-16 10:07:53 +020014778 [ALC269_FIXUP_DELL_M101Z] = {
14779 .verbs = (const struct hda_verb[]) {
14780 /* Enables internal speaker */
14781 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14782 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14783 {}
14784 }
14785 },
Takashi Iwaiff818c22010-04-12 08:59:25 +020014786};
14787
14788static struct snd_pci_quirk alc269_fixup_tbl[] = {
Takashi Iwaiabdd8f52010-09-21 17:38:14 +020014789 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014790 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014791 {}
14792};
14793
14794
Kailang Yangf6a92242007-12-13 16:52:54 +010014795/*
14796 * configuration and preset
14797 */
14798static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014799 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014800 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014801 [ALC269_AMIC] = "laptop-amic",
14802 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014803 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014804 [ALC269_LIFEBOOK] = "lifebook",
14805 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014806};
14807
14808static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014809 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014810 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014811 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014812 ALC269_AMIC),
14813 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14814 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14815 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14816 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14817 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14818 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14819 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14820 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14821 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14822 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14823 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14824 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14825 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14826 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14827 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14828 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14829 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14830 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14831 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14832 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14833 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14834 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14835 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14836 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14837 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14838 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14839 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14840 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14841 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14842 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14843 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14844 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14845 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14846 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14847 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14848 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014849 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014850 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014851 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014852 ALC269_DMIC),
14853 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14854 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014855 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014856 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014857 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14858 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14859 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14860 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14861 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14862 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014863 {}
14864};
14865
14866static struct alc_config_preset alc269_presets[] = {
14867 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014868 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014869 .init_verbs = { alc269_init_verbs },
14870 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14871 .dac_nids = alc269_dac_nids,
14872 .hp_nid = 0x03,
14873 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14874 .channel_mode = alc269_modes,
14875 .input_mux = &alc269_capture_source,
14876 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014877 [ALC269_QUANTA_FL1] = {
14878 .mixers = { alc269_quanta_fl1_mixer },
14879 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14880 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14881 .dac_nids = alc269_dac_nids,
14882 .hp_nid = 0x03,
14883 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14884 .channel_mode = alc269_modes,
14885 .input_mux = &alc269_capture_source,
14886 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014887 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014888 .init_hook = alc269_quanta_fl1_init_hook,
14889 },
Kailang Yang84898e82010-02-04 14:16:14 +010014890 [ALC269_AMIC] = {
14891 .mixers = { alc269_laptop_mixer },
14892 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014893 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014894 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014895 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14896 .dac_nids = alc269_dac_nids,
14897 .hp_nid = 0x03,
14898 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14899 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014900 .unsol_event = alc269_laptop_unsol_event,
14901 .setup = alc269_laptop_amic_setup,
14902 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014903 },
Kailang Yang84898e82010-02-04 14:16:14 +010014904 [ALC269_DMIC] = {
14905 .mixers = { alc269_laptop_mixer },
14906 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014907 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014908 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014909 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14910 .dac_nids = alc269_dac_nids,
14911 .hp_nid = 0x03,
14912 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14913 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014914 .unsol_event = alc269_laptop_unsol_event,
14915 .setup = alc269_laptop_dmic_setup,
14916 .init_hook = alc269_laptop_inithook,
14917 },
14918 [ALC269VB_AMIC] = {
14919 .mixers = { alc269vb_laptop_mixer },
14920 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14921 .init_verbs = { alc269vb_init_verbs,
14922 alc269vb_laptop_amic_init_verbs },
14923 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14924 .dac_nids = alc269_dac_nids,
14925 .hp_nid = 0x03,
14926 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14927 .channel_mode = alc269_modes,
14928 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014929 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014930 .init_hook = alc269_laptop_inithook,
14931 },
14932 [ALC269VB_DMIC] = {
14933 .mixers = { alc269vb_laptop_mixer },
14934 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14935 .init_verbs = { alc269vb_init_verbs,
14936 alc269vb_laptop_dmic_init_verbs },
14937 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14938 .dac_nids = alc269_dac_nids,
14939 .hp_nid = 0x03,
14940 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14941 .channel_mode = alc269_modes,
14942 .unsol_event = alc269_laptop_unsol_event,
14943 .setup = alc269vb_laptop_dmic_setup,
14944 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014945 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014946 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014947 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014948 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014949 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014950 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014951 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14952 .dac_nids = alc269_dac_nids,
14953 .hp_nid = 0x03,
14954 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14955 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014956 .unsol_event = alc269_laptop_unsol_event,
14957 .setup = alc269_laptop_dmic_setup,
14958 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014959 },
Tony Vroon64154832008-11-06 15:08:49 +000014960 [ALC269_LIFEBOOK] = {
14961 .mixers = { alc269_lifebook_mixer },
14962 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14963 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14964 .dac_nids = alc269_dac_nids,
14965 .hp_nid = 0x03,
14966 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14967 .channel_mode = alc269_modes,
14968 .input_mux = &alc269_capture_source,
14969 .unsol_event = alc269_lifebook_unsol_event,
14970 .init_hook = alc269_lifebook_init_hook,
14971 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014972 [ALC271_ACER] = {
14973 .mixers = { alc269_asus_mixer },
14974 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14975 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
14976 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14977 .dac_nids = alc269_dac_nids,
14978 .adc_nids = alc262_dmic_adc_nids,
14979 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
14980 .capsrc_nids = alc262_dmic_capsrc_nids,
14981 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14982 .channel_mode = alc269_modes,
14983 .input_mux = &alc269_capture_source,
14984 .dig_out_nid = ALC880_DIGOUT_NID,
14985 .unsol_event = alc_sku_unsol_event,
14986 .setup = alc269vb_laptop_dmic_setup,
14987 .init_hook = alc_inithook,
14988 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014989};
14990
Kailang Yang977ddd62010-09-15 10:02:29 +020014991static int alc269_fill_coef(struct hda_codec *codec)
14992{
14993 int val;
14994
14995 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
14996 alc_write_coef_idx(codec, 0xf, 0x960b);
14997 alc_write_coef_idx(codec, 0xe, 0x8817);
14998 }
14999
15000 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
15001 alc_write_coef_idx(codec, 0xf, 0x960b);
15002 alc_write_coef_idx(codec, 0xe, 0x8814);
15003 }
15004
15005 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
15006 val = alc_read_coef_idx(codec, 0x04);
15007 /* Power up output pin */
15008 alc_write_coef_idx(codec, 0x04, val | (1<<11));
15009 }
15010
15011 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
15012 val = alc_read_coef_idx(codec, 0xd);
15013 if ((val & 0x0c00) >> 10 != 0x1) {
15014 /* Capless ramp up clock control */
15015 alc_write_coef_idx(codec, 0xd, val | 1<<10);
15016 }
15017 val = alc_read_coef_idx(codec, 0x17);
15018 if ((val & 0x01c0) >> 6 != 0x4) {
15019 /* Class D power on reset */
15020 alc_write_coef_idx(codec, 0x17, val | 1<<7);
15021 }
15022 }
15023 return 0;
15024}
15025
Kailang Yangf6a92242007-12-13 16:52:54 +010015026static int patch_alc269(struct hda_codec *codec)
15027{
15028 struct alc_spec *spec;
Kailang Yang48c88e82010-11-23 08:56:16 +010015029 int board_config, coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010015030 int err;
15031
15032 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15033 if (spec == NULL)
15034 return -ENOMEM;
15035
15036 codec->spec = spec;
15037
Kailang Yangda00c242010-03-19 11:23:45 +010015038 alc_auto_parse_customize_define(codec);
15039
Kailang Yang48c88e82010-11-23 08:56:16 +010015040 coef = alc_read_coef_idx(codec, 0);
15041 if ((coef & 0x00f0) == 0x0010) {
Kailang Yangc027ddc2010-03-19 11:33:06 +010015042 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
Takashi Iwaid433a672010-09-20 15:11:54 +020015043 spec->cdefine.platform_type == 1) {
Kailang Yangc027ddc2010-03-19 11:33:06 +010015044 alc_codec_rename(codec, "ALC271X");
Takashi Iwaid433a672010-09-20 15:11:54 +020015045 spec->codec_variant = ALC269_TYPE_ALC271X;
Kailang Yang48c88e82010-11-23 08:56:16 +010015046 } else if ((coef & 0xf000) == 0x1000) {
15047 spec->codec_variant = ALC269_TYPE_ALC270;
15048 } else if ((coef & 0xf000) == 0x2000) {
Kailang Yangc027ddc2010-03-19 11:33:06 +010015049 alc_codec_rename(codec, "ALC259");
Takashi Iwaid433a672010-09-20 15:11:54 +020015050 spec->codec_variant = ALC269_TYPE_ALC259;
Kailang Yang48c88e82010-11-23 08:56:16 +010015051 } else if ((coef & 0xf000) == 0x3000) {
15052 alc_codec_rename(codec, "ALC258");
15053 spec->codec_variant = ALC269_TYPE_ALC258;
15054 } else {
15055 alc_codec_rename(codec, "ALC269VB");
15056 spec->codec_variant = ALC269_TYPE_ALC269VB;
Takashi Iwaid433a672010-09-20 15:11:54 +020015057 }
Kailang Yangc027ddc2010-03-19 11:33:06 +010015058 } else
15059 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010015060
Kailang Yang977ddd62010-09-15 10:02:29 +020015061 alc269_fill_coef(codec);
15062
Kailang Yangf6a92242007-12-13 16:52:54 +010015063 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15064 alc269_models,
15065 alc269_cfg_tbl);
15066
15067 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015068 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15069 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015070 board_config = ALC269_AUTO;
15071 }
15072
Takashi Iwaiff818c22010-04-12 08:59:25 +020015073 if (board_config == ALC269_AUTO)
15074 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
15075
Kailang Yangf6a92242007-12-13 16:52:54 +010015076 if (board_config == ALC269_AUTO) {
15077 /* automatic parse from the BIOS config */
15078 err = alc269_parse_auto_config(codec);
15079 if (err < 0) {
15080 alc_free(codec);
15081 return err;
15082 } else if (!err) {
15083 printk(KERN_INFO
15084 "hda_codec: Cannot set up configuration "
15085 "from BIOS. Using base mode...\n");
15086 board_config = ALC269_BASIC;
15087 }
15088 }
15089
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015090 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015091 err = snd_hda_attach_beep_device(codec, 0x1);
15092 if (err < 0) {
15093 alc_free(codec);
15094 return err;
15095 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015096 }
15097
Kailang Yangf6a92242007-12-13 16:52:54 +010015098 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015099 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015100
Kailang Yang84898e82010-02-04 14:16:14 +010015101 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015102 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15103 * fix the sample rate of analog I/O to 44.1kHz
15104 */
15105 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15106 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015107 } else if (spec->dual_adc_switch) {
15108 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15109 /* switch ADC dynamically */
15110 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015111 } else {
15112 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15113 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15114 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015115 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15116 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15117
Takashi Iwai66946352010-03-29 17:21:45 +020015118 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Kailang Yang1657cbd2010-11-23 08:53:32 +010015119 if (spec->codec_variant == ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015120 spec->adc_nids = alc269_adc_nids;
15121 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15122 spec->capsrc_nids = alc269_capsrc_nids;
15123 } else {
15124 spec->adc_nids = alc269vb_adc_nids;
15125 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15126 spec->capsrc_nids = alc269vb_capsrc_nids;
15127 }
Kailang Yang84898e82010-02-04 14:16:14 +010015128 }
15129
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015130 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015131 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015132 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015133 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015134
Takashi Iwaiff818c22010-04-12 08:59:25 +020015135 if (board_config == ALC269_AUTO)
15136 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
15137
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015138 spec->vmaster_nid = 0x02;
15139
Kailang Yangf6a92242007-12-13 16:52:54 +010015140 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015141#ifdef CONFIG_SND_HDA_POWER_SAVE
15142 codec->patch_ops.suspend = alc269_suspend;
15143#endif
15144#ifdef SND_HDA_NEEDS_RESUME
15145 codec->patch_ops.resume = alc269_resume;
15146#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015147 if (board_config == ALC269_AUTO)
15148 spec->init_hook = alc269_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020015149
15150 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010015151#ifdef CONFIG_SND_HDA_POWER_SAVE
15152 if (!spec->loopback.amplist)
15153 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015154 if (alc269_mic2_for_mute_led(codec))
15155 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015156#endif
15157
15158 return 0;
15159}
15160
15161/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015162 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15163 */
15164
15165/*
15166 * set the path ways for 2 channel output
15167 * need to set the codec line out and mic 1 pin widgets to inputs
15168 */
15169static struct hda_verb alc861_threestack_ch2_init[] = {
15170 /* set pin widget 1Ah (line in) for input */
15171 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015172 /* set pin widget 18h (mic1/2) for input, for mic also enable
15173 * the vref
15174 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015175 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15176
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015177 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15178#if 0
15179 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15180 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15181#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015182 { } /* end */
15183};
15184/*
15185 * 6ch mode
15186 * need to set the codec line out and mic 1 pin widgets to outputs
15187 */
15188static struct hda_verb alc861_threestack_ch6_init[] = {
15189 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15190 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15191 /* set pin widget 18h (mic1) for output (CLFE)*/
15192 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15193
15194 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015195 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015196
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015197 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15198#if 0
15199 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15200 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15201#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015202 { } /* end */
15203};
15204
15205static struct hda_channel_mode alc861_threestack_modes[2] = {
15206 { 2, alc861_threestack_ch2_init },
15207 { 6, alc861_threestack_ch6_init },
15208};
Takashi Iwai22309c32006-08-09 16:57:28 +020015209/* Set mic1 as input and unmute the mixer */
15210static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15211 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15212 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15213 { } /* end */
15214};
15215/* Set mic1 as output and mute mixer */
15216static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15217 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15218 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15219 { } /* end */
15220};
15221
15222static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15223 { 2, alc861_uniwill_m31_ch2_init },
15224 { 4, alc861_uniwill_m31_ch4_init },
15225};
Kailang Yangdf694da2005-12-05 19:42:22 +010015226
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015227/* Set mic1 and line-in as input and unmute the mixer */
15228static struct hda_verb alc861_asus_ch2_init[] = {
15229 /* set pin widget 1Ah (line in) for input */
15230 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015231 /* set pin widget 18h (mic1/2) for input, for mic also enable
15232 * the vref
15233 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015234 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15235
15236 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15237#if 0
15238 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15239 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15240#endif
15241 { } /* end */
15242};
15243/* Set mic1 nad line-in as output and mute mixer */
15244static struct hda_verb alc861_asus_ch6_init[] = {
15245 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15246 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15247 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15248 /* set pin widget 18h (mic1) for output (CLFE)*/
15249 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15250 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15251 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15252 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15253
15254 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15255#if 0
15256 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15257 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15258#endif
15259 { } /* end */
15260};
15261
15262static struct hda_channel_mode alc861_asus_modes[2] = {
15263 { 2, alc861_asus_ch2_init },
15264 { 6, alc861_asus_ch6_init },
15265};
15266
Kailang Yangdf694da2005-12-05 19:42:22 +010015267/* patch-ALC861 */
15268
15269static struct snd_kcontrol_new alc861_base_mixer[] = {
15270 /* output mixer control */
15271 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15272 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15273 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15274 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15275 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15276
15277 /*Input mixer control */
15278 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15279 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15280 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15281 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15282 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15283 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15284 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15285 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15286 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15287 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015288
Kailang Yangdf694da2005-12-05 19:42:22 +010015289 { } /* end */
15290};
15291
15292static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15293 /* output mixer control */
15294 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15295 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15296 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15297 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15298 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15299
15300 /* Input mixer control */
15301 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15302 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15303 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15304 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15305 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15306 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15307 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15308 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15309 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15310 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015311
Kailang Yangdf694da2005-12-05 19:42:22 +010015312 {
15313 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15314 .name = "Channel Mode",
15315 .info = alc_ch_mode_info,
15316 .get = alc_ch_mode_get,
15317 .put = alc_ch_mode_put,
15318 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15319 },
15320 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015321};
15322
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015323static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015324 /* output mixer control */
15325 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15326 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15327 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015328
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015329 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015330};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015331
Takashi Iwai22309c32006-08-09 16:57:28 +020015332static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15333 /* output mixer control */
15334 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15335 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15336 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15337 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15338 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15339
15340 /* Input mixer control */
15341 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15342 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15343 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15344 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15345 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15346 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15347 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15348 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15349 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15350 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015351
Takashi Iwai22309c32006-08-09 16:57:28 +020015352 {
15353 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15354 .name = "Channel Mode",
15355 .info = alc_ch_mode_info,
15356 .get = alc_ch_mode_get,
15357 .put = alc_ch_mode_put,
15358 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15359 },
15360 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015361};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015362
15363static struct snd_kcontrol_new alc861_asus_mixer[] = {
15364 /* output mixer control */
15365 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15366 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15367 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15368 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15369 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15370
15371 /* Input mixer control */
15372 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15373 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15374 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15375 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15376 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15377 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15378 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15379 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15380 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015381 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15382
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015383 {
15384 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15385 .name = "Channel Mode",
15386 .info = alc_ch_mode_info,
15387 .get = alc_ch_mode_get,
15388 .put = alc_ch_mode_put,
15389 .private_value = ARRAY_SIZE(alc861_asus_modes),
15390 },
15391 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015392};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015393
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015394/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015395static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015396 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15397 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015398 { }
15399};
15400
Kailang Yangdf694da2005-12-05 19:42:22 +010015401/*
15402 * generic initialization of ADC, input mixers and output mixers
15403 */
15404static struct hda_verb alc861_base_init_verbs[] = {
15405 /*
15406 * Unmute ADC0 and set the default input to mic-in
15407 */
15408 /* port-A for surround (rear panel) */
15409 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15410 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15411 /* port-B for mic-in (rear panel) with vref */
15412 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15413 /* port-C for line-in (rear panel) */
15414 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15415 /* port-D for Front */
15416 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15417 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15418 /* port-E for HP out (front panel) */
15419 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15420 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015421 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015422 /* port-F for mic-in (front panel) with vref */
15423 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15424 /* port-G for CLFE (rear panel) */
15425 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15426 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15427 /* port-H for side (rear panel) */
15428 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15429 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15430 /* CD-in */
15431 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15432 /* route front mic to ADC1*/
15433 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15434 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015435
Kailang Yangdf694da2005-12-05 19:42:22 +010015436 /* Unmute DAC0~3 & spdif out*/
15437 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15438 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15439 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15440 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15441 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015442
Kailang Yangdf694da2005-12-05 19:42:22 +010015443 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15444 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15445 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15446 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15447 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015448
Kailang Yangdf694da2005-12-05 19:42:22 +010015449 /* Unmute Stereo Mixer 15 */
15450 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15451 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15452 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015453 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015454
15455 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15456 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15457 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15458 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15459 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15460 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15461 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15462 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015463 /* hp used DAC 3 (Front) */
15464 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015465 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15466
15467 { }
15468};
15469
15470static struct hda_verb alc861_threestack_init_verbs[] = {
15471 /*
15472 * Unmute ADC0 and set the default input to mic-in
15473 */
15474 /* port-A for surround (rear panel) */
15475 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15476 /* port-B for mic-in (rear panel) with vref */
15477 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15478 /* port-C for line-in (rear panel) */
15479 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15480 /* port-D for Front */
15481 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15482 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15483 /* port-E for HP out (front panel) */
15484 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15485 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015486 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015487 /* port-F for mic-in (front panel) with vref */
15488 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15489 /* port-G for CLFE (rear panel) */
15490 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15491 /* port-H for side (rear panel) */
15492 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15493 /* CD-in */
15494 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15495 /* route front mic to ADC1*/
15496 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15497 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15498 /* Unmute DAC0~3 & spdif out*/
15499 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15500 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15501 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15502 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15503 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015504
Kailang Yangdf694da2005-12-05 19:42:22 +010015505 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15506 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15507 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15508 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15509 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015510
Kailang Yangdf694da2005-12-05 19:42:22 +010015511 /* Unmute Stereo Mixer 15 */
15512 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15513 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15514 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015515 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015516
15517 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15518 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15519 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15520 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15521 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15522 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15523 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15524 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015525 /* hp used DAC 3 (Front) */
15526 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015527 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15528 { }
15529};
Takashi Iwai22309c32006-08-09 16:57:28 +020015530
15531static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15532 /*
15533 * Unmute ADC0 and set the default input to mic-in
15534 */
15535 /* port-A for surround (rear panel) */
15536 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15537 /* port-B for mic-in (rear panel) with vref */
15538 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15539 /* port-C for line-in (rear panel) */
15540 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15541 /* port-D for Front */
15542 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15543 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15544 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015545 /* this has to be set to VREF80 */
15546 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015547 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015548 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015549 /* port-F for mic-in (front panel) with vref */
15550 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15551 /* port-G for CLFE (rear panel) */
15552 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15553 /* port-H for side (rear panel) */
15554 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15555 /* CD-in */
15556 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15557 /* route front mic to ADC1*/
15558 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15559 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15560 /* Unmute DAC0~3 & spdif out*/
15561 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15562 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15563 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15564 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15565 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015566
Takashi Iwai22309c32006-08-09 16:57:28 +020015567 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15568 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15569 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15570 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15571 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015572
Takashi Iwai22309c32006-08-09 16:57:28 +020015573 /* Unmute Stereo Mixer 15 */
15574 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15575 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15576 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015577 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015578
15579 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15580 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15581 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15582 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15583 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15584 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15585 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15586 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015587 /* hp used DAC 3 (Front) */
15588 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015589 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15590 { }
15591};
15592
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015593static struct hda_verb alc861_asus_init_verbs[] = {
15594 /*
15595 * Unmute ADC0 and set the default input to mic-in
15596 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015597 /* port-A for surround (rear panel)
15598 * according to codec#0 this is the HP jack
15599 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015600 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15601 /* route front PCM to HP */
15602 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15603 /* port-B for mic-in (rear panel) with vref */
15604 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15605 /* port-C for line-in (rear panel) */
15606 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15607 /* port-D for Front */
15608 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15609 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15610 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015611 /* this has to be set to VREF80 */
15612 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015613 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015614 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015615 /* port-F for mic-in (front panel) with vref */
15616 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15617 /* port-G for CLFE (rear panel) */
15618 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15619 /* port-H for side (rear panel) */
15620 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15621 /* CD-in */
15622 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15623 /* route front mic to ADC1*/
15624 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15625 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15626 /* Unmute DAC0~3 & spdif out*/
15627 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15628 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15629 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15630 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15631 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15632 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15633 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15634 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15635 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15636 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015637
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015638 /* Unmute Stereo Mixer 15 */
15639 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15640 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15641 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015642 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015643
15644 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15645 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15646 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15647 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15648 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15649 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15650 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15651 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015652 /* hp used DAC 3 (Front) */
15653 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015654 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15655 { }
15656};
15657
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015658/* additional init verbs for ASUS laptops */
15659static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15660 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15661 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15662 { }
15663};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015664
Kailang Yangdf694da2005-12-05 19:42:22 +010015665/*
15666 * generic initialization of ADC, input mixers and output mixers
15667 */
15668static struct hda_verb alc861_auto_init_verbs[] = {
15669 /*
15670 * Unmute ADC0 and set the default input to mic-in
15671 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015672 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015673 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015674
Kailang Yangdf694da2005-12-05 19:42:22 +010015675 /* Unmute DAC0~3 & spdif out*/
15676 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15677 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15678 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15679 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15680 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015681
Kailang Yangdf694da2005-12-05 19:42:22 +010015682 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15683 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15684 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15685 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15686 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015687
Kailang Yangdf694da2005-12-05 19:42:22 +010015688 /* Unmute Stereo Mixer 15 */
15689 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15690 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15691 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15692 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15693
Takashi Iwai1c209302009-07-22 15:17:45 +020015694 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15695 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15696 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15697 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15698 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15699 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15700 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15701 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015702
15703 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15704 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015705 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15706 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015707 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15708 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015709 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15710 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015711
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015712 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015713
15714 { }
15715};
15716
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015717static struct hda_verb alc861_toshiba_init_verbs[] = {
15718 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015719
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015720 { }
15721};
15722
15723/* toggle speaker-output according to the hp-jack state */
15724static void alc861_toshiba_automute(struct hda_codec *codec)
15725{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015726 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015727
Takashi Iwai47fd8302007-08-10 17:11:07 +020015728 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15729 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15730 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15731 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015732}
15733
15734static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15735 unsigned int res)
15736{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015737 if ((res >> 26) == ALC880_HP_EVENT)
15738 alc861_toshiba_automute(codec);
15739}
15740
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015741/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015742#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15743#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15744#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15745#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15746
15747
15748#define ALC861_DIGOUT_NID 0x07
15749
15750static struct hda_channel_mode alc861_8ch_modes[1] = {
15751 { 8, NULL }
15752};
15753
15754static hda_nid_t alc861_dac_nids[4] = {
15755 /* front, surround, clfe, side */
15756 0x03, 0x06, 0x05, 0x04
15757};
15758
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015759static hda_nid_t alc660_dac_nids[3] = {
15760 /* front, clfe, surround */
15761 0x03, 0x05, 0x06
15762};
15763
Kailang Yangdf694da2005-12-05 19:42:22 +010015764static hda_nid_t alc861_adc_nids[1] = {
15765 /* ADC0-2 */
15766 0x08,
15767};
15768
15769static struct hda_input_mux alc861_capture_source = {
15770 .num_items = 5,
15771 .items = {
15772 { "Mic", 0x0 },
15773 { "Front Mic", 0x3 },
15774 { "Line", 0x1 },
15775 { "CD", 0x4 },
15776 { "Mixer", 0x5 },
15777 },
15778};
15779
Takashi Iwai1c209302009-07-22 15:17:45 +020015780static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15781{
15782 struct alc_spec *spec = codec->spec;
15783 hda_nid_t mix, srcs[5];
15784 int i, j, num;
15785
15786 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15787 return 0;
15788 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15789 if (num < 0)
15790 return 0;
15791 for (i = 0; i < num; i++) {
15792 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015793 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015794 if (type != AC_WID_AUD_OUT)
15795 continue;
15796 for (j = 0; j < spec->multiout.num_dacs; j++)
15797 if (spec->multiout.dac_nids[j] == srcs[i])
15798 break;
15799 if (j >= spec->multiout.num_dacs)
15800 return srcs[i];
15801 }
15802 return 0;
15803}
15804
Kailang Yangdf694da2005-12-05 19:42:22 +010015805/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015806static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015807 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015808{
Takashi Iwai1c209302009-07-22 15:17:45 +020015809 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015810 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015811 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015812
15813 spec->multiout.dac_nids = spec->private_dac_nids;
15814 for (i = 0; i < cfg->line_outs; i++) {
15815 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015816 dac = alc861_look_for_dac(codec, nid);
15817 if (!dac)
15818 continue;
15819 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015820 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015821 return 0;
15822}
15823
Takashi Iwai1c209302009-07-22 15:17:45 +020015824static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15825 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015826{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015827 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015828 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15829}
15830
15831/* add playback controls from the parsed DAC table */
15832static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15833 const struct auto_pin_cfg *cfg)
15834{
15835 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015836 static const char *chname[4] = {
15837 "Front", "Surround", NULL /*CLFE*/, "Side"
15838 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015839 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015840 int i, err;
15841
15842 if (cfg->line_outs == 1) {
15843 const char *pfx = NULL;
15844 if (!cfg->hp_outs)
15845 pfx = "Master";
15846 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15847 pfx = "Speaker";
15848 if (pfx) {
15849 nid = spec->multiout.dac_nids[0];
15850 return alc861_create_out_sw(codec, pfx, nid, 3);
15851 }
15852 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015853
15854 for (i = 0; i < cfg->line_outs; i++) {
15855 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015856 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015857 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015858 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015859 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015860 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015861 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015862 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015863 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015864 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015865 return err;
15866 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015867 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015868 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015869 return err;
15870 }
15871 }
15872 return 0;
15873}
15874
Takashi Iwai1c209302009-07-22 15:17:45 +020015875static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015876{
Takashi Iwai1c209302009-07-22 15:17:45 +020015877 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015878 int err;
15879 hda_nid_t nid;
15880
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015881 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015882 return 0;
15883
15884 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015885 nid = alc861_look_for_dac(codec, pin);
15886 if (nid) {
15887 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15888 if (err < 0)
15889 return err;
15890 spec->multiout.hp_nid = nid;
15891 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015892 }
15893 return 0;
15894}
15895
15896/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015897static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015898 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015899{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015900 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015901}
15902
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015903static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15904 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015905 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015906{
Takashi Iwai1c209302009-07-22 15:17:45 +020015907 hda_nid_t mix, srcs[5];
15908 int i, num;
15909
Jacek Luczak564c5be2008-05-03 18:41:23 +020015910 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15911 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015912 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015913 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015914 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15915 return;
15916 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15917 if (num < 0)
15918 return;
15919 for (i = 0; i < num; i++) {
15920 unsigned int mute;
15921 if (srcs[i] == dac || srcs[i] == 0x15)
15922 mute = AMP_IN_UNMUTE(i);
15923 else
15924 mute = AMP_IN_MUTE(i);
15925 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15926 mute);
15927 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015928}
15929
15930static void alc861_auto_init_multi_out(struct hda_codec *codec)
15931{
15932 struct alc_spec *spec = codec->spec;
15933 int i;
15934
15935 for (i = 0; i < spec->autocfg.line_outs; i++) {
15936 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015937 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015938 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015939 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015940 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015941 }
15942}
15943
15944static void alc861_auto_init_hp_out(struct hda_codec *codec)
15945{
15946 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015947
Takashi Iwai15870f02009-10-05 08:25:13 +020015948 if (spec->autocfg.hp_outs)
15949 alc861_auto_set_output_and_unmute(codec,
15950 spec->autocfg.hp_pins[0],
15951 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015952 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015953 if (spec->autocfg.speaker_outs)
15954 alc861_auto_set_output_and_unmute(codec,
15955 spec->autocfg.speaker_pins[0],
15956 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015957 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015958}
15959
15960static void alc861_auto_init_analog_input(struct hda_codec *codec)
15961{
15962 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015963 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010015964 int i;
15965
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015966 for (i = 0; i < cfg->num_inputs; i++) {
15967 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010015968 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020015969 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015970 }
15971}
15972
15973/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015974/* return 1 if successful, 0 if the proper config is not found,
15975 * or a negative error code
15976 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015977static int alc861_parse_auto_config(struct hda_codec *codec)
15978{
15979 struct alc_spec *spec = codec->spec;
15980 int err;
15981 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15982
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015983 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15984 alc861_ignore);
15985 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015986 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015987 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015988 return 0; /* can't find valid BIOS pin config */
15989
Takashi Iwai1c209302009-07-22 15:17:45 +020015990 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015991 if (err < 0)
15992 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015993 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015994 if (err < 0)
15995 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015996 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015997 if (err < 0)
15998 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015999 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016000 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016001 return err;
16002
16003 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16004
Takashi Iwai757899a2010-07-30 10:48:14 +020016005 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016006
Takashi Iwai603c4012008-07-30 15:01:44 +020016007 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016008 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010016009
Takashi Iwaid88897e2008-10-31 15:01:37 +010016010 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010016011
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020016012 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016013 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010016014
16015 spec->adc_nids = alc861_adc_nids;
16016 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016017 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016018
Kailang Yang6227cdc2010-02-25 08:36:52 +010016019 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016020
Kailang Yangdf694da2005-12-05 19:42:22 +010016021 return 1;
16022}
16023
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016024/* additional initialization for auto-configuration model */
16025static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010016026{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016027 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016028 alc861_auto_init_multi_out(codec);
16029 alc861_auto_init_hp_out(codec);
16030 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016031 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016032 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016033 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016034}
16035
Takashi Iwaicb53c622007-08-10 17:21:45 +020016036#ifdef CONFIG_SND_HDA_POWER_SAVE
16037static struct hda_amp_list alc861_loopbacks[] = {
16038 { 0x15, HDA_INPUT, 0 },
16039 { 0x15, HDA_INPUT, 1 },
16040 { 0x15, HDA_INPUT, 2 },
16041 { 0x15, HDA_INPUT, 3 },
16042 { } /* end */
16043};
16044#endif
16045
Kailang Yangdf694da2005-12-05 19:42:22 +010016046
16047/*
16048 * configuration and preset
16049 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016050static const char *alc861_models[ALC861_MODEL_LAST] = {
16051 [ALC861_3ST] = "3stack",
16052 [ALC660_3ST] = "3stack-660",
16053 [ALC861_3ST_DIG] = "3stack-dig",
16054 [ALC861_6ST_DIG] = "6stack-dig",
16055 [ALC861_UNIWILL_M31] = "uniwill-m31",
16056 [ALC861_TOSHIBA] = "toshiba",
16057 [ALC861_ASUS] = "asus",
16058 [ALC861_ASUS_LAPTOP] = "asus-laptop",
16059 [ALC861_AUTO] = "auto",
16060};
16061
16062static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010016063 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016064 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16065 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16066 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016067 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016068 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016069 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016070 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16071 * Any other models that need this preset?
16072 */
16073 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016074 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16075 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016076 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16077 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16078 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16079 /* FIXME: the below seems conflict */
16080 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16081 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16082 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016083 {}
16084};
16085
16086static struct alc_config_preset alc861_presets[] = {
16087 [ALC861_3ST] = {
16088 .mixers = { alc861_3ST_mixer },
16089 .init_verbs = { alc861_threestack_init_verbs },
16090 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16091 .dac_nids = alc861_dac_nids,
16092 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16093 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016094 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016095 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16096 .adc_nids = alc861_adc_nids,
16097 .input_mux = &alc861_capture_source,
16098 },
16099 [ALC861_3ST_DIG] = {
16100 .mixers = { alc861_base_mixer },
16101 .init_verbs = { alc861_threestack_init_verbs },
16102 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16103 .dac_nids = alc861_dac_nids,
16104 .dig_out_nid = ALC861_DIGOUT_NID,
16105 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16106 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016107 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016108 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16109 .adc_nids = alc861_adc_nids,
16110 .input_mux = &alc861_capture_source,
16111 },
16112 [ALC861_6ST_DIG] = {
16113 .mixers = { alc861_base_mixer },
16114 .init_verbs = { alc861_base_init_verbs },
16115 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16116 .dac_nids = alc861_dac_nids,
16117 .dig_out_nid = ALC861_DIGOUT_NID,
16118 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16119 .channel_mode = alc861_8ch_modes,
16120 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16121 .adc_nids = alc861_adc_nids,
16122 .input_mux = &alc861_capture_source,
16123 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016124 [ALC660_3ST] = {
16125 .mixers = { alc861_3ST_mixer },
16126 .init_verbs = { alc861_threestack_init_verbs },
16127 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16128 .dac_nids = alc660_dac_nids,
16129 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16130 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016131 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016132 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16133 .adc_nids = alc861_adc_nids,
16134 .input_mux = &alc861_capture_source,
16135 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016136 [ALC861_UNIWILL_M31] = {
16137 .mixers = { alc861_uniwill_m31_mixer },
16138 .init_verbs = { alc861_uniwill_m31_init_verbs },
16139 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16140 .dac_nids = alc861_dac_nids,
16141 .dig_out_nid = ALC861_DIGOUT_NID,
16142 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16143 .channel_mode = alc861_uniwill_m31_modes,
16144 .need_dac_fix = 1,
16145 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16146 .adc_nids = alc861_adc_nids,
16147 .input_mux = &alc861_capture_source,
16148 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016149 [ALC861_TOSHIBA] = {
16150 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016151 .init_verbs = { alc861_base_init_verbs,
16152 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016153 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16154 .dac_nids = alc861_dac_nids,
16155 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16156 .channel_mode = alc883_3ST_2ch_modes,
16157 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16158 .adc_nids = alc861_adc_nids,
16159 .input_mux = &alc861_capture_source,
16160 .unsol_event = alc861_toshiba_unsol_event,
16161 .init_hook = alc861_toshiba_automute,
16162 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016163 [ALC861_ASUS] = {
16164 .mixers = { alc861_asus_mixer },
16165 .init_verbs = { alc861_asus_init_verbs },
16166 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16167 .dac_nids = alc861_dac_nids,
16168 .dig_out_nid = ALC861_DIGOUT_NID,
16169 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16170 .channel_mode = alc861_asus_modes,
16171 .need_dac_fix = 1,
16172 .hp_nid = 0x06,
16173 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16174 .adc_nids = alc861_adc_nids,
16175 .input_mux = &alc861_capture_source,
16176 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016177 [ALC861_ASUS_LAPTOP] = {
16178 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16179 .init_verbs = { alc861_asus_init_verbs,
16180 alc861_asus_laptop_init_verbs },
16181 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16182 .dac_nids = alc861_dac_nids,
16183 .dig_out_nid = ALC861_DIGOUT_NID,
16184 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16185 .channel_mode = alc883_3ST_2ch_modes,
16186 .need_dac_fix = 1,
16187 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16188 .adc_nids = alc861_adc_nids,
16189 .input_mux = &alc861_capture_source,
16190 },
16191};
Kailang Yangdf694da2005-12-05 19:42:22 +010016192
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016193/* Pin config fixes */
16194enum {
16195 PINFIX_FSC_AMILO_PI1505,
16196};
16197
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016198static const struct alc_fixup alc861_fixups[] = {
16199 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020016200 .pins = (const struct alc_pincfg[]) {
16201 { 0x0b, 0x0221101f }, /* HP */
16202 { 0x0f, 0x90170310 }, /* speaker */
16203 { }
16204 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016205 },
16206};
16207
16208static struct snd_pci_quirk alc861_fixup_tbl[] = {
16209 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16210 {}
16211};
Kailang Yangdf694da2005-12-05 19:42:22 +010016212
16213static int patch_alc861(struct hda_codec *codec)
16214{
16215 struct alc_spec *spec;
16216 int board_config;
16217 int err;
16218
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016219 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016220 if (spec == NULL)
16221 return -ENOMEM;
16222
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016223 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016224
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016225 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16226 alc861_models,
16227 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016228
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016229 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016230 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16231 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016232 board_config = ALC861_AUTO;
16233 }
16234
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016235 if (board_config == ALC861_AUTO)
16236 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016237
Kailang Yangdf694da2005-12-05 19:42:22 +010016238 if (board_config == ALC861_AUTO) {
16239 /* automatic parse from the BIOS config */
16240 err = alc861_parse_auto_config(codec);
16241 if (err < 0) {
16242 alc_free(codec);
16243 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016244 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016245 printk(KERN_INFO
16246 "hda_codec: Cannot set up configuration "
16247 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016248 board_config = ALC861_3ST_DIG;
16249 }
16250 }
16251
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016252 err = snd_hda_attach_beep_device(codec, 0x23);
16253 if (err < 0) {
16254 alc_free(codec);
16255 return err;
16256 }
16257
Kailang Yangdf694da2005-12-05 19:42:22 +010016258 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016259 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016260
Kailang Yangdf694da2005-12-05 19:42:22 +010016261 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16262 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16263
Kailang Yangdf694da2005-12-05 19:42:22 +010016264 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16265 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16266
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016267 if (!spec->cap_mixer)
16268 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016269 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16270
Takashi Iwai2134ea42008-01-10 16:53:55 +010016271 spec->vmaster_nid = 0x03;
16272
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016273 if (board_config == ALC861_AUTO)
16274 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
16275
Kailang Yangdf694da2005-12-05 19:42:22 +010016276 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016277 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016278 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016279#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016280 spec->power_hook = alc_power_eapd;
16281#endif
16282 }
16283#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016284 if (!spec->loopback.amplist)
16285 spec->loopback.amplist = alc861_loopbacks;
16286#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016287
Kailang Yangdf694da2005-12-05 19:42:22 +010016288 return 0;
16289}
16290
16291/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016292 * ALC861-VD support
16293 *
16294 * Based on ALC882
16295 *
16296 * In addition, an independent DAC
16297 */
16298#define ALC861VD_DIGOUT_NID 0x06
16299
16300static hda_nid_t alc861vd_dac_nids[4] = {
16301 /* front, surr, clfe, side surr */
16302 0x02, 0x03, 0x04, 0x05
16303};
16304
16305/* dac_nids for ALC660vd are in a different order - according to
16306 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016307 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016308 * of ALC660vd codecs, but for now there is only 3stack mixer
16309 * - and it is the same as in 861vd.
16310 * adc_nids in ALC660vd are (is) the same as in 861vd
16311 */
16312static hda_nid_t alc660vd_dac_nids[3] = {
16313 /* front, rear, clfe, rear_surr */
16314 0x02, 0x04, 0x03
16315};
16316
16317static hda_nid_t alc861vd_adc_nids[1] = {
16318 /* ADC0 */
16319 0x09,
16320};
16321
Takashi Iwaie1406342008-02-11 18:32:32 +010016322static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16323
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016324/* input MUX */
16325/* FIXME: should be a matrix-type input source selection */
16326static struct hda_input_mux alc861vd_capture_source = {
16327 .num_items = 4,
16328 .items = {
16329 { "Mic", 0x0 },
16330 { "Front Mic", 0x1 },
16331 { "Line", 0x2 },
16332 { "CD", 0x4 },
16333 },
16334};
16335
Kailang Yang272a5272007-05-14 11:00:38 +020016336static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016337 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016338 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010016339 { "Ext Mic", 0x0 },
16340 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016341 },
16342};
16343
Kailang Yangd1a991a2007-08-15 16:21:59 +020016344static struct hda_input_mux alc861vd_hp_capture_source = {
16345 .num_items = 2,
16346 .items = {
16347 { "Front Mic", 0x0 },
16348 { "ATAPI Mic", 0x1 },
16349 },
16350};
16351
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016352/*
16353 * 2ch mode
16354 */
16355static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16356 { 2, NULL }
16357};
16358
16359/*
16360 * 6ch mode
16361 */
16362static struct hda_verb alc861vd_6stack_ch6_init[] = {
16363 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16364 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16365 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16366 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16367 { } /* end */
16368};
16369
16370/*
16371 * 8ch mode
16372 */
16373static struct hda_verb alc861vd_6stack_ch8_init[] = {
16374 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16375 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16376 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16377 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16378 { } /* end */
16379};
16380
16381static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16382 { 6, alc861vd_6stack_ch6_init },
16383 { 8, alc861vd_6stack_ch8_init },
16384};
16385
16386static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16387 {
16388 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16389 .name = "Channel Mode",
16390 .info = alc_ch_mode_info,
16391 .get = alc_ch_mode_get,
16392 .put = alc_ch_mode_put,
16393 },
16394 { } /* end */
16395};
16396
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016397/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16398 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16399 */
16400static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16401 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16402 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16403
16404 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16405 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16406
16407 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16408 HDA_OUTPUT),
16409 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16410 HDA_OUTPUT),
16411 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16412 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16413
16414 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16415 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16416
16417 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16418
16419 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16420 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16421 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16422
16423 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16424 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16425 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16426
16427 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16428 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16429
16430 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16431 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16432
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016433 { } /* end */
16434};
16435
16436static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16437 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16438 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16439
16440 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16441
16442 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16443 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16444 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16445
16446 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16447 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16448 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16449
16450 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16451 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16452
16453 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16454 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16455
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016456 { } /* end */
16457};
16458
Kailang Yangbdd148a2007-05-08 15:19:08 +020016459static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16460 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16461 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16462 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16463
16464 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16465
16466 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16467 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16468 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16469
16470 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16471 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16472 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16473
16474 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16475 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16476
16477 { } /* end */
16478};
16479
Tobin Davisb419f342008-03-07 11:57:51 +010016480/* Pin assignment: Speaker=0x14, HP = 0x15,
16481 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016482 */
16483static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016484 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16485 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016486 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16487 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010016488 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16489 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16490 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16491 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16492 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16493 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016494 { } /* end */
16495};
16496
Kailang Yangd1a991a2007-08-15 16:21:59 +020016497/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16498 * Front Mic=0x18, ATAPI Mic = 0x19,
16499 */
16500static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16501 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16502 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16503 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16504 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16505 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16506 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16507 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16508 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016509
Kailang Yangd1a991a2007-08-15 16:21:59 +020016510 { } /* end */
16511};
16512
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016513/*
16514 * generic initialization of ADC, input mixers and output mixers
16515 */
16516static struct hda_verb alc861vd_volume_init_verbs[] = {
16517 /*
16518 * Unmute ADC0 and set the default input to mic-in
16519 */
16520 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16521 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16522
16523 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16524 * the analog-loopback mixer widget
16525 */
16526 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016527 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16529 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16530 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16531 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016532
16533 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016534 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16535 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16536 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016537 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016538
16539 /*
16540 * Set up output mixers (0x02 - 0x05)
16541 */
16542 /* set vol=0 to output mixers */
16543 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16544 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16545 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16546 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16547
16548 /* set up input amps for analog loopback */
16549 /* Amp Indices: DAC = 0, mixer = 1 */
16550 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16551 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16552 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16553 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16554 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16555 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16556 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16557 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16558
16559 { }
16560};
16561
16562/*
16563 * 3-stack pin configuration:
16564 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16565 */
16566static struct hda_verb alc861vd_3stack_init_verbs[] = {
16567 /*
16568 * Set pin mode and muting
16569 */
16570 /* set front pin widgets 0x14 for output */
16571 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16572 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16573 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16574
16575 /* Mic (rear) pin: input vref at 80% */
16576 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16577 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16578 /* Front Mic pin: input vref at 80% */
16579 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16580 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16581 /* Line In pin: input */
16582 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16583 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16584 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16585 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16586 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16587 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16588 /* CD pin widget for input */
16589 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16590
16591 { }
16592};
16593
16594/*
16595 * 6-stack pin configuration:
16596 */
16597static struct hda_verb alc861vd_6stack_init_verbs[] = {
16598 /*
16599 * Set pin mode and muting
16600 */
16601 /* set front pin widgets 0x14 for output */
16602 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16603 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16604 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16605
16606 /* Rear Pin: output 1 (0x0d) */
16607 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16608 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16609 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16610 /* CLFE Pin: output 2 (0x0e) */
16611 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16612 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16613 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16614 /* Side Pin: output 3 (0x0f) */
16615 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16616 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16617 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16618
16619 /* Mic (rear) pin: input vref at 80% */
16620 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16621 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16622 /* Front Mic pin: input vref at 80% */
16623 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16624 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16625 /* Line In pin: input */
16626 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16627 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16628 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16629 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16630 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16631 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16632 /* CD pin widget for input */
16633 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16634
16635 { }
16636};
16637
Kailang Yangbdd148a2007-05-08 15:19:08 +020016638static struct hda_verb alc861vd_eapd_verbs[] = {
16639 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16640 { }
16641};
16642
Kailang Yangf9423e72008-05-27 12:32:25 +020016643static struct hda_verb alc660vd_eapd_verbs[] = {
16644 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16645 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16646 { }
16647};
16648
Kailang Yangbdd148a2007-05-08 15:19:08 +020016649static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16650 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16651 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16652 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16653 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016654 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016655 {}
16656};
16657
Kailang Yangbdd148a2007-05-08 15:19:08 +020016658static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
16659{
16660 unsigned int present;
16661 unsigned char bits;
16662
Wu Fengguang864f92b2009-11-18 12:38:02 +080016663 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016664 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016665
Takashi Iwai47fd8302007-08-10 17:11:07 +020016666 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
16667 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016668}
16669
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016670static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016671{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016672 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016673 spec->autocfg.hp_pins[0] = 0x1b;
16674 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016675}
16676
16677static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16678{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016679 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016680 alc861vd_lenovo_mic_automute(codec);
16681}
16682
16683static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16684 unsigned int res)
16685{
16686 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016687 case ALC880_MIC_EVENT:
16688 alc861vd_lenovo_mic_automute(codec);
16689 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016690 default:
16691 alc_automute_amp_unsol_event(codec, res);
16692 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016693 }
16694}
16695
Kailang Yang272a5272007-05-14 11:00:38 +020016696static struct hda_verb alc861vd_dallas_verbs[] = {
16697 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16698 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16699 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16700 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16701
16702 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16703 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16704 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16705 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16706 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16707 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16708 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16709 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016710
Kailang Yang272a5272007-05-14 11:00:38 +020016711 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16712 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16713 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16714 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16715 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16716 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16717 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16718 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16719
16720 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16721 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16722 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16723 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16724 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16725 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16726 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16727 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16728
16729 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16730 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16731 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16732 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16733
16734 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016735 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016736 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16737
16738 { } /* end */
16739};
16740
16741/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016742static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016743{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016744 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016745
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016746 spec->autocfg.hp_pins[0] = 0x15;
16747 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016748}
16749
Takashi Iwaicb53c622007-08-10 17:21:45 +020016750#ifdef CONFIG_SND_HDA_POWER_SAVE
16751#define alc861vd_loopbacks alc880_loopbacks
16752#endif
16753
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016754/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016755#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16756#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16757#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16758#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16759
16760/*
16761 * configuration and preset
16762 */
16763static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16764 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016765 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016766 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016767 [ALC861VD_3ST] = "3stack",
16768 [ALC861VD_3ST_DIG] = "3stack-digout",
16769 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016770 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016771 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016772 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016773 [ALC861VD_AUTO] = "auto",
16774};
16775
16776static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016777 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16778 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016779 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016780 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016781 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016782 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016783 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016784 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016785 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016786 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016787 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016788 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016789 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016790 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016791 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016792 {}
16793};
16794
16795static struct alc_config_preset alc861vd_presets[] = {
16796 [ALC660VD_3ST] = {
16797 .mixers = { alc861vd_3st_mixer },
16798 .init_verbs = { alc861vd_volume_init_verbs,
16799 alc861vd_3stack_init_verbs },
16800 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16801 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016802 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16803 .channel_mode = alc861vd_3stack_2ch_modes,
16804 .input_mux = &alc861vd_capture_source,
16805 },
Mike Crash6963f842007-06-25 12:12:51 +020016806 [ALC660VD_3ST_DIG] = {
16807 .mixers = { alc861vd_3st_mixer },
16808 .init_verbs = { alc861vd_volume_init_verbs,
16809 alc861vd_3stack_init_verbs },
16810 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16811 .dac_nids = alc660vd_dac_nids,
16812 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016813 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16814 .channel_mode = alc861vd_3stack_2ch_modes,
16815 .input_mux = &alc861vd_capture_source,
16816 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016817 [ALC861VD_3ST] = {
16818 .mixers = { alc861vd_3st_mixer },
16819 .init_verbs = { alc861vd_volume_init_verbs,
16820 alc861vd_3stack_init_verbs },
16821 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16822 .dac_nids = alc861vd_dac_nids,
16823 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16824 .channel_mode = alc861vd_3stack_2ch_modes,
16825 .input_mux = &alc861vd_capture_source,
16826 },
16827 [ALC861VD_3ST_DIG] = {
16828 .mixers = { alc861vd_3st_mixer },
16829 .init_verbs = { alc861vd_volume_init_verbs,
16830 alc861vd_3stack_init_verbs },
16831 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16832 .dac_nids = alc861vd_dac_nids,
16833 .dig_out_nid = ALC861VD_DIGOUT_NID,
16834 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16835 .channel_mode = alc861vd_3stack_2ch_modes,
16836 .input_mux = &alc861vd_capture_source,
16837 },
16838 [ALC861VD_6ST_DIG] = {
16839 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16840 .init_verbs = { alc861vd_volume_init_verbs,
16841 alc861vd_6stack_init_verbs },
16842 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16843 .dac_nids = alc861vd_dac_nids,
16844 .dig_out_nid = ALC861VD_DIGOUT_NID,
16845 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16846 .channel_mode = alc861vd_6stack_modes,
16847 .input_mux = &alc861vd_capture_source,
16848 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016849 [ALC861VD_LENOVO] = {
16850 .mixers = { alc861vd_lenovo_mixer },
16851 .init_verbs = { alc861vd_volume_init_verbs,
16852 alc861vd_3stack_init_verbs,
16853 alc861vd_eapd_verbs,
16854 alc861vd_lenovo_unsol_verbs },
16855 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16856 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016857 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16858 .channel_mode = alc861vd_3stack_2ch_modes,
16859 .input_mux = &alc861vd_capture_source,
16860 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016861 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016862 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016863 },
Kailang Yang272a5272007-05-14 11:00:38 +020016864 [ALC861VD_DALLAS] = {
16865 .mixers = { alc861vd_dallas_mixer },
16866 .init_verbs = { alc861vd_dallas_verbs },
16867 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16868 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016869 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16870 .channel_mode = alc861vd_3stack_2ch_modes,
16871 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016872 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016873 .setup = alc861vd_dallas_setup,
16874 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016875 },
16876 [ALC861VD_HP] = {
16877 .mixers = { alc861vd_hp_mixer },
16878 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16879 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16880 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016881 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016882 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16883 .channel_mode = alc861vd_3stack_2ch_modes,
16884 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016885 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016886 .setup = alc861vd_dallas_setup,
16887 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016888 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016889 [ALC660VD_ASUS_V1S] = {
16890 .mixers = { alc861vd_lenovo_mixer },
16891 .init_verbs = { alc861vd_volume_init_verbs,
16892 alc861vd_3stack_init_verbs,
16893 alc861vd_eapd_verbs,
16894 alc861vd_lenovo_unsol_verbs },
16895 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16896 .dac_nids = alc660vd_dac_nids,
16897 .dig_out_nid = ALC861VD_DIGOUT_NID,
16898 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16899 .channel_mode = alc861vd_3stack_2ch_modes,
16900 .input_mux = &alc861vd_capture_source,
16901 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016902 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016903 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016904 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016905};
16906
16907/*
16908 * BIOS auto configuration
16909 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016910static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16911 const struct auto_pin_cfg *cfg)
16912{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016913 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016914}
16915
16916
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016917static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16918 hda_nid_t nid, int pin_type, int dac_idx)
16919{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016920 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016921}
16922
16923static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16924{
16925 struct alc_spec *spec = codec->spec;
16926 int i;
16927
16928 for (i = 0; i <= HDA_SIDE; i++) {
16929 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016930 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016931 if (nid)
16932 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016933 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016934 }
16935}
16936
16937
16938static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16939{
16940 struct alc_spec *spec = codec->spec;
16941 hda_nid_t pin;
16942
16943 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016944 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016945 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016946 pin = spec->autocfg.speaker_pins[0];
16947 if (pin)
16948 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016949}
16950
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016951#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16952
16953static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16954{
16955 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016956 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016957 int i;
16958
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016959 for (i = 0; i < cfg->num_inputs; i++) {
16960 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016961 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020016962 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016963 if (nid != ALC861VD_PIN_CD_NID &&
16964 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016965 snd_hda_codec_write(codec, nid, 0,
16966 AC_VERB_SET_AMP_GAIN_MUTE,
16967 AMP_OUT_MUTE);
16968 }
16969 }
16970}
16971
Takashi Iwaif511b012008-08-15 16:46:42 +020016972#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16973
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016974#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16975#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16976
16977/* add playback controls from the parsed DAC table */
16978/* Based on ALC880 version. But ALC861VD has separate,
16979 * different NIDs for mute/unmute switch and volume control */
16980static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16981 const struct auto_pin_cfg *cfg)
16982{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016983 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16984 hda_nid_t nid_v, nid_s;
16985 int i, err;
16986
16987 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016988 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016989 continue;
16990 nid_v = alc861vd_idx_to_mixer_vol(
16991 alc880_dac_to_idx(
16992 spec->multiout.dac_nids[i]));
16993 nid_s = alc861vd_idx_to_mixer_switch(
16994 alc880_dac_to_idx(
16995 spec->multiout.dac_nids[i]));
16996
16997 if (i == 2) {
16998 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016999 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17000 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017001 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
17002 HDA_OUTPUT));
17003 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017004 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017005 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17006 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017007 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
17008 HDA_OUTPUT));
17009 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017010 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017011 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17012 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017013 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
17014 HDA_INPUT));
17015 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017016 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017017 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17018 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017019 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
17020 HDA_INPUT));
17021 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017022 return err;
17023 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020017024 const char *pfx;
17025 if (cfg->line_outs == 1 &&
17026 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
17027 if (!cfg->hp_pins)
17028 pfx = "Speaker";
17029 else
17030 pfx = "PCM";
17031 } else
17032 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017033 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017034 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17035 HDA_OUTPUT));
17036 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017037 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020017038 if (cfg->line_outs == 1 &&
17039 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17040 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017041 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017042 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017043 HDA_INPUT));
17044 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017045 return err;
17046 }
17047 }
17048 return 0;
17049}
17050
17051/* add playback controls for speaker and HP outputs */
17052/* Based on ALC880 version. But ALC861VD has separate,
17053 * different NIDs for mute/unmute switch and volume control */
17054static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
17055 hda_nid_t pin, const char *pfx)
17056{
17057 hda_nid_t nid_v, nid_s;
17058 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017059
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017060 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017061 return 0;
17062
17063 if (alc880_is_fixed_pin(pin)) {
17064 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17065 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017066 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017067 spec->multiout.hp_nid = nid_v;
17068 else
17069 spec->multiout.extra_out_nid[0] = nid_v;
17070 /* control HP volume/switch on the output mixer amp */
17071 nid_v = alc861vd_idx_to_mixer_vol(
17072 alc880_fixed_pin_idx(pin));
17073 nid_s = alc861vd_idx_to_mixer_switch(
17074 alc880_fixed_pin_idx(pin));
17075
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017076 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017077 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17078 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017079 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017080 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017081 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17082 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017083 return err;
17084 } else if (alc880_is_multi_pin(pin)) {
17085 /* set manual connection */
17086 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017087 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017088 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17089 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017090 return err;
17091 }
17092 return 0;
17093}
17094
17095/* parse the BIOS configuration and set up the alc_spec
17096 * return 1 if successful, 0 if the proper config is not found,
17097 * or a negative error code
17098 * Based on ALC880 version - had to change it to override
17099 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17100static int alc861vd_parse_auto_config(struct hda_codec *codec)
17101{
17102 struct alc_spec *spec = codec->spec;
17103 int err;
17104 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17105
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017106 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17107 alc861vd_ignore);
17108 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017109 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017110 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017111 return 0; /* can't find valid BIOS pin config */
17112
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017113 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17114 if (err < 0)
17115 return err;
17116 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17117 if (err < 0)
17118 return err;
17119 err = alc861vd_auto_create_extra_out(spec,
17120 spec->autocfg.speaker_pins[0],
17121 "Speaker");
17122 if (err < 0)
17123 return err;
17124 err = alc861vd_auto_create_extra_out(spec,
17125 spec->autocfg.hp_pins[0],
17126 "Headphone");
17127 if (err < 0)
17128 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017129 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017130 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017131 return err;
17132
17133 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17134
Takashi Iwai757899a2010-07-30 10:48:14 +020017135 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017136
Takashi Iwai603c4012008-07-30 15:01:44 +020017137 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017138 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017139
Takashi Iwaid88897e2008-10-31 15:01:37 +010017140 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017141
17142 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017143 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017144
Takashi Iwai776e1842007-08-29 15:07:11 +020017145 err = alc_auto_add_mic_boost(codec);
17146 if (err < 0)
17147 return err;
17148
Kailang Yang6227cdc2010-02-25 08:36:52 +010017149 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017150
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017151 return 1;
17152}
17153
17154/* additional initialization for auto-configuration model */
17155static void alc861vd_auto_init(struct hda_codec *codec)
17156{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017157 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017158 alc861vd_auto_init_multi_out(codec);
17159 alc861vd_auto_init_hp_out(codec);
17160 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017161 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017162 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017163 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017164 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017165}
17166
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017167enum {
17168 ALC660VD_FIX_ASUS_GPIO1
17169};
17170
17171/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017172static const struct alc_fixup alc861vd_fixups[] = {
17173 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020017174 .verbs = (const struct hda_verb[]) {
17175 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17176 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17177 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17178 { }
17179 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017180 },
17181};
17182
17183static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17184 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17185 {}
17186};
17187
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017188static int patch_alc861vd(struct hda_codec *codec)
17189{
17190 struct alc_spec *spec;
17191 int err, board_config;
17192
17193 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17194 if (spec == NULL)
17195 return -ENOMEM;
17196
17197 codec->spec = spec;
17198
17199 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17200 alc861vd_models,
17201 alc861vd_cfg_tbl);
17202
17203 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017204 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17205 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017206 board_config = ALC861VD_AUTO;
17207 }
17208
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017209 if (board_config == ALC861VD_AUTO)
17210 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017211
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017212 if (board_config == ALC861VD_AUTO) {
17213 /* automatic parse from the BIOS config */
17214 err = alc861vd_parse_auto_config(codec);
17215 if (err < 0) {
17216 alc_free(codec);
17217 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017218 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017219 printk(KERN_INFO
17220 "hda_codec: Cannot set up configuration "
17221 "from BIOS. Using base mode...\n");
17222 board_config = ALC861VD_3ST;
17223 }
17224 }
17225
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017226 err = snd_hda_attach_beep_device(codec, 0x23);
17227 if (err < 0) {
17228 alc_free(codec);
17229 return err;
17230 }
17231
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017232 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017233 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017234
Kailang Yang2f893282008-05-27 12:14:47 +020017235 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017236 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017237 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017238 }
17239
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017240 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17241 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17242
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017243 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17244 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17245
Takashi Iwaidd704692009-08-11 08:45:11 +020017246 if (!spec->adc_nids) {
17247 spec->adc_nids = alc861vd_adc_nids;
17248 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17249 }
17250 if (!spec->capsrc_nids)
17251 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017252
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017253 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017254 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017255
Takashi Iwai2134ea42008-01-10 16:53:55 +010017256 spec->vmaster_nid = 0x02;
17257
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017258 if (board_config == ALC861VD_AUTO)
17259 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
17260
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017261 codec->patch_ops = alc_patch_ops;
17262
17263 if (board_config == ALC861VD_AUTO)
17264 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017265#ifdef CONFIG_SND_HDA_POWER_SAVE
17266 if (!spec->loopback.amplist)
17267 spec->loopback.amplist = alc861vd_loopbacks;
17268#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017269
17270 return 0;
17271}
17272
17273/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017274 * ALC662 support
17275 *
17276 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17277 * configuration. Each pin widget can choose any input DACs and a mixer.
17278 * Each ADC is connected from a mixer of all inputs. This makes possible
17279 * 6-channel independent captures.
17280 *
17281 * In addition, an independent DAC for the multi-playback (not used in this
17282 * driver yet).
17283 */
17284#define ALC662_DIGOUT_NID 0x06
17285#define ALC662_DIGIN_NID 0x0a
17286
17287static hda_nid_t alc662_dac_nids[4] = {
17288 /* front, rear, clfe, rear_surr */
17289 0x02, 0x03, 0x04
17290};
17291
Kailang Yang622e84c2009-04-21 07:39:04 +020017292static hda_nid_t alc272_dac_nids[2] = {
17293 0x02, 0x03
17294};
17295
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017296static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017297 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017298 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017299};
Takashi Iwaie1406342008-02-11 18:32:32 +010017300
Kailang Yang622e84c2009-04-21 07:39:04 +020017301static hda_nid_t alc272_adc_nids[1] = {
17302 /* ADC1-2 */
17303 0x08,
17304};
17305
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017306static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017307static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17308
Takashi Iwaie1406342008-02-11 18:32:32 +010017309
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017310/* input MUX */
17311/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017312static struct hda_input_mux alc662_capture_source = {
17313 .num_items = 4,
17314 .items = {
17315 { "Mic", 0x0 },
17316 { "Front Mic", 0x1 },
17317 { "Line", 0x2 },
17318 { "CD", 0x4 },
17319 },
17320};
17321
17322static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17323 .num_items = 2,
17324 .items = {
17325 { "Mic", 0x1 },
17326 { "Line", 0x2 },
17327 },
17328};
Kailang Yang291702f2007-10-16 14:28:03 +020017329
Kailang Yang6dda9f42008-05-27 12:05:31 +020017330static struct hda_input_mux alc663_capture_source = {
17331 .num_items = 3,
17332 .items = {
17333 { "Mic", 0x0 },
17334 { "Front Mic", 0x1 },
17335 { "Line", 0x2 },
17336 },
17337};
17338
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017339#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017340static struct hda_input_mux alc272_nc10_capture_source = {
17341 .num_items = 16,
17342 .items = {
17343 { "Autoselect Mic", 0x0 },
17344 { "Internal Mic", 0x1 },
17345 { "In-0x02", 0x2 },
17346 { "In-0x03", 0x3 },
17347 { "In-0x04", 0x4 },
17348 { "In-0x05", 0x5 },
17349 { "In-0x06", 0x6 },
17350 { "In-0x07", 0x7 },
17351 { "In-0x08", 0x8 },
17352 { "In-0x09", 0x9 },
17353 { "In-0x0a", 0x0a },
17354 { "In-0x0b", 0x0b },
17355 { "In-0x0c", 0x0c },
17356 { "In-0x0d", 0x0d },
17357 { "In-0x0e", 0x0e },
17358 { "In-0x0f", 0x0f },
17359 },
17360};
17361#endif
17362
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017363/*
17364 * 2ch mode
17365 */
17366static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17367 { 2, NULL }
17368};
17369
17370/*
17371 * 2ch mode
17372 */
17373static struct hda_verb alc662_3ST_ch2_init[] = {
17374 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17375 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17376 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17377 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17378 { } /* end */
17379};
17380
17381/*
17382 * 6ch mode
17383 */
17384static struct hda_verb alc662_3ST_ch6_init[] = {
17385 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17386 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17387 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17388 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17389 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17390 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17391 { } /* end */
17392};
17393
17394static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17395 { 2, alc662_3ST_ch2_init },
17396 { 6, alc662_3ST_ch6_init },
17397};
17398
17399/*
17400 * 2ch mode
17401 */
17402static struct hda_verb alc662_sixstack_ch6_init[] = {
17403 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17404 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17405 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17406 { } /* end */
17407};
17408
17409/*
17410 * 6ch mode
17411 */
17412static struct hda_verb alc662_sixstack_ch8_init[] = {
17413 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17414 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17415 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17416 { } /* end */
17417};
17418
17419static struct hda_channel_mode alc662_5stack_modes[2] = {
17420 { 2, alc662_sixstack_ch6_init },
17421 { 6, alc662_sixstack_ch8_init },
17422};
17423
17424/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17425 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17426 */
17427
17428static struct snd_kcontrol_new alc662_base_mixer[] = {
17429 /* output mixer control */
17430 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017431 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017432 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017433 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017434 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17435 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017436 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17437 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017438 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17439
17440 /*Input mixer control */
17441 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17442 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17443 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17444 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17445 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17446 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17447 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17448 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017449 { } /* end */
17450};
17451
17452static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17453 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017454 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017455 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17456 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17457 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17458 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17459 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17460 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17461 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17462 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17463 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017464 { } /* end */
17465};
17466
17467static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17468 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017469 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017470 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017471 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017472 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17473 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017474 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17475 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017476 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17477 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17478 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17479 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17480 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17481 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17482 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17483 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17484 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017485 { } /* end */
17486};
17487
17488static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17489 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17490 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017491 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17492 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017493 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17494 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17495 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17496 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17497 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017498 { } /* end */
17499};
17500
Kailang Yang291702f2007-10-16 14:28:03 +020017501static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017502 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17503 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017504
17505 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
17506 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17507 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17508
17509 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17510 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17511 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17512 { } /* end */
17513};
17514
Kailang Yang8c427222008-01-10 13:03:59 +010017515static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017516 ALC262_HIPPO_MASTER_SWITCH,
17517 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017518 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017519 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17520 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017521 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17522 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17523 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17524 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17525 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17526 { } /* end */
17527};
17528
Kailang Yangf1d4e282008-08-26 14:03:29 +020017529static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17530 .ops = &snd_hda_bind_vol,
17531 .values = {
17532 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17533 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17534 0
17535 },
17536};
17537
17538static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17539 .ops = &snd_hda_bind_sw,
17540 .values = {
17541 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17542 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17543 0
17544 },
17545};
17546
Kailang Yang6dda9f42008-05-27 12:05:31 +020017547static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017548 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17549 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17550 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17551 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17552 { } /* end */
17553};
17554
17555static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17556 .ops = &snd_hda_bind_sw,
17557 .values = {
17558 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17559 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17560 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17561 0
17562 },
17563};
17564
17565static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17566 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17567 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17568 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17569 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17570 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17571 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17572
17573 { } /* end */
17574};
17575
17576static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17577 .ops = &snd_hda_bind_sw,
17578 .values = {
17579 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17580 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17581 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17582 0
17583 },
17584};
17585
17586static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17587 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17588 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17589 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17590 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17591 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17592 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17593 { } /* end */
17594};
17595
17596static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017597 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17598 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017599 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17600 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17601 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17602 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17603 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17604 { } /* end */
17605};
17606
17607static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17608 .ops = &snd_hda_bind_vol,
17609 .values = {
17610 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17611 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17612 0
17613 },
17614};
17615
17616static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17617 .ops = &snd_hda_bind_sw,
17618 .values = {
17619 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17620 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17621 0
17622 },
17623};
17624
17625static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17626 HDA_BIND_VOL("Master Playback Volume",
17627 &alc663_asus_two_bind_master_vol),
17628 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17629 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017630 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17631 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17632 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017633 { } /* end */
17634};
17635
17636static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17637 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17638 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17639 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17640 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17641 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17642 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017643 { } /* end */
17644};
17645
17646static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17647 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17648 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17649 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17650 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17651 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17652
17653 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17654 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17655 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17656 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17657 { } /* end */
17658};
17659
17660static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17661 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17662 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17663 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17664
17665 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17666 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17667 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17668 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17669 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17670 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17671 { } /* end */
17672};
17673
Kailang Yangebb83ee2009-12-17 12:23:00 +010017674static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17675 .ops = &snd_hda_bind_sw,
17676 .values = {
17677 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17678 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17679 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17680 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17681 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17682 0
17683 },
17684};
17685
17686static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17687 .ops = &snd_hda_bind_sw,
17688 .values = {
17689 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17690 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17691 0
17692 },
17693};
17694
17695static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17696 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17697 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17698 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17699 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17700 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17701 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17702 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17703 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17704 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17705 { } /* end */
17706};
17707
17708static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17709 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17710 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17711 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17712 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17713 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17714 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17715 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17716 { } /* end */
17717};
17718
17719
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017720static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17721 {
17722 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17723 .name = "Channel Mode",
17724 .info = alc_ch_mode_info,
17725 .get = alc_ch_mode_get,
17726 .put = alc_ch_mode_put,
17727 },
17728 { } /* end */
17729};
17730
17731static struct hda_verb alc662_init_verbs[] = {
17732 /* ADC: mute amp left and right */
17733 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17734 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017735
Kailang Yangb60dd392007-09-20 12:50:29 +020017736 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17737 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17738 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17739 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17740 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17741 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017742
17743 /* Front Pin: output 0 (0x0c) */
17744 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17745 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17746
17747 /* Rear Pin: output 1 (0x0d) */
17748 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17749 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17750
17751 /* CLFE Pin: output 2 (0x0e) */
17752 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17753 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17754
17755 /* Mic (rear) pin: input vref at 80% */
17756 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17757 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17758 /* Front Mic pin: input vref at 80% */
17759 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17760 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17761 /* Line In pin: input */
17762 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17763 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17764 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17765 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17766 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17767 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17768 /* CD pin widget for input */
17769 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17770
17771 /* FIXME: use matrix-type input source selection */
17772 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17773 /* Input mixer */
17774 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017775 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017776
17777 /* always trun on EAPD */
17778 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17779 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17780
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017781 { }
17782};
17783
Kailang Yangcec27c82010-02-04 14:18:18 +010017784static struct hda_verb alc663_init_verbs[] = {
17785 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17786 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17787 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17788 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17789 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17790 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17791 { }
17792};
17793
17794static struct hda_verb alc272_init_verbs[] = {
17795 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17796 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17797 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17798 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17799 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17800 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17801 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17802 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17803 { }
17804};
17805
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017806static struct hda_verb alc662_sue_init_verbs[] = {
17807 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17808 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017809 {}
17810};
17811
17812static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17813 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17814 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17815 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017816};
17817
Kailang Yang8c427222008-01-10 13:03:59 +010017818/* Set Unsolicited Event*/
17819static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17820 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17821 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17822 {}
17823};
17824
Kailang Yang6dda9f42008-05-27 12:05:31 +020017825static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017826 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17827 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017828 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17829 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017830 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17831 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17832 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017833 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17834 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17835 {}
17836};
17837
Kailang Yangf1d4e282008-08-26 14:03:29 +020017838static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17839 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17840 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17841 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17842 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17843 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17844 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17845 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17846 {}
17847};
17848
17849static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17850 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17851 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17852 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17853 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17854 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17855 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17856 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17857 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17858 {}
17859};
17860
17861static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17862 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17863 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17864 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17865 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17866 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17867 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17868 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17869 {}
17870};
17871
17872static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17873 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17874 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17875 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17876 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17877 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17878 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17879 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17880 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17881 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17882 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17883 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17884 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17885 {}
17886};
17887
17888static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17889 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17890 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17891 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17892 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17893 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17894 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17895 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17896 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17897 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17898 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17899 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17900 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17901 {}
17902};
17903
Kailang Yang6dda9f42008-05-27 12:05:31 +020017904static struct hda_verb alc663_g71v_init_verbs[] = {
17905 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17906 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17907 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17908
17909 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17910 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17911 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17912
17913 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17914 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17915 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17916 {}
17917};
17918
17919static struct hda_verb alc663_g50v_init_verbs[] = {
17920 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17921 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17922 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17923
17924 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17925 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17926 {}
17927};
17928
Kailang Yangf1d4e282008-08-26 14:03:29 +020017929static struct hda_verb alc662_ecs_init_verbs[] = {
17930 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17931 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17932 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17933 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17934 {}
17935};
17936
Kailang Yang622e84c2009-04-21 07:39:04 +020017937static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17938 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17939 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17940 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17941 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17942 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17943 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17944 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17945 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17946 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17947 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17948 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17949 {}
17950};
17951
17952static struct hda_verb alc272_dell_init_verbs[] = {
17953 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17954 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17955 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17956 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17957 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17958 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17959 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17960 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17961 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17962 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17963 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17964 {}
17965};
17966
Kailang Yangebb83ee2009-12-17 12:23:00 +010017967static struct hda_verb alc663_mode7_init_verbs[] = {
17968 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17969 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17970 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17971 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17972 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17973 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17974 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17975 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17976 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17977 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17978 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17979 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17980 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17981 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17982 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17983 {}
17984};
17985
17986static struct hda_verb alc663_mode8_init_verbs[] = {
17987 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17988 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17989 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17990 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17991 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17992 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17993 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17994 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17995 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17996 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17997 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17998 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17999 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18000 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18001 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18002 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18003 {}
18004};
18005
Kailang Yangf1d4e282008-08-26 14:03:29 +020018006static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
18007 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
18008 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
18009 { } /* end */
18010};
18011
Kailang Yang622e84c2009-04-21 07:39:04 +020018012static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
18013 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18014 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18015 { } /* end */
18016};
18017
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018018static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
18019{
18020 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018021 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018022
Wu Fengguang864f92b2009-11-18 12:38:02 +080018023 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018024 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018025
Takashi Iwai47fd8302007-08-10 17:11:07 +020018026 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18027 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018028}
18029
18030static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
18031{
18032 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018033 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018034
Wu Fengguang864f92b2009-11-18 12:38:02 +080018035 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018036 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018037
Takashi Iwai47fd8302007-08-10 17:11:07 +020018038 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18039 HDA_AMP_MUTE, bits);
18040 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18041 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018042}
18043
18044static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
18045 unsigned int res)
18046{
18047 if ((res >> 26) == ALC880_HP_EVENT)
18048 alc662_lenovo_101e_all_automute(codec);
18049 if ((res >> 26) == ALC880_FRONT_EVENT)
18050 alc662_lenovo_101e_ispeaker_automute(codec);
18051}
18052
Kailang Yang291702f2007-10-16 14:28:03 +020018053/* unsolicited event for HP jack sensing */
18054static void alc662_eeepc_unsol_event(struct hda_codec *codec,
18055 unsigned int res)
18056{
Kailang Yang291702f2007-10-16 14:28:03 +020018057 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018058 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020018059 else
18060 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020018061}
18062
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018063static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020018064{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018065 struct alc_spec *spec = codec->spec;
18066
18067 alc262_hippo1_setup(codec);
18068 spec->ext_mic.pin = 0x18;
18069 spec->ext_mic.mux_idx = 0;
18070 spec->int_mic.pin = 0x19;
18071 spec->int_mic.mux_idx = 1;
18072 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018073}
18074
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018075static void alc662_eeepc_inithook(struct hda_codec *codec)
18076{
18077 alc262_hippo_automute(codec);
18078 alc_mic_automute(codec);
18079}
18080
18081static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018082{
Takashi Iwai42171c12009-05-08 14:11:43 +020018083 struct alc_spec *spec = codec->spec;
18084
18085 spec->autocfg.hp_pins[0] = 0x14;
18086 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010018087}
18088
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018089#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
18090
Kailang Yang6dda9f42008-05-27 12:05:31 +020018091static void alc663_m51va_speaker_automute(struct hda_codec *codec)
18092{
18093 unsigned int present;
18094 unsigned char bits;
18095
Wu Fengguang864f92b2009-11-18 12:38:02 +080018096 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018097 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018098 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018099 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018100 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018101 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018102}
18103
18104static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
18105{
18106 unsigned int present;
18107 unsigned char bits;
18108
Wu Fengguang864f92b2009-11-18 12:38:02 +080018109 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018110 bits = present ? HDA_AMP_MUTE : 0;
18111 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018112 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018113 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018114 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018115 snd_hda_codec_amp_stereo(codec, 0x0e, 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, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018118 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018119}
18120
18121static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18122{
18123 unsigned int present;
18124 unsigned char bits;
18125
Wu Fengguang864f92b2009-11-18 12:38:02 +080018126 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018127 bits = present ? HDA_AMP_MUTE : 0;
18128 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018129 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018130 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018131 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018132 snd_hda_codec_amp_stereo(codec, 0x0e, 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, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018135 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018136}
18137
18138static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18139{
18140 unsigned int present;
18141 unsigned char bits;
18142
Wu Fengguang864f92b2009-11-18 12:38:02 +080018143 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018144 bits = present ? 0 : PIN_OUT;
18145 snd_hda_codec_write(codec, 0x14, 0,
18146 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18147}
18148
18149static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18150{
18151 unsigned int present1, present2;
18152
Wu Fengguang864f92b2009-11-18 12:38:02 +080018153 present1 = snd_hda_jack_detect(codec, 0x21);
18154 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018155
18156 if (present1 || present2) {
18157 snd_hda_codec_write_cache(codec, 0x14, 0,
18158 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18159 } else {
18160 snd_hda_codec_write_cache(codec, 0x14, 0,
18161 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18162 }
18163}
18164
18165static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18166{
18167 unsigned int present1, present2;
18168
Wu Fengguang864f92b2009-11-18 12:38:02 +080018169 present1 = snd_hda_jack_detect(codec, 0x1b);
18170 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018171
18172 if (present1 || present2) {
18173 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018174 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018175 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018176 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018177 } else {
18178 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018179 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018180 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018181 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018182 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018183}
18184
Kailang Yangebb83ee2009-12-17 12:23:00 +010018185static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18186{
18187 unsigned int present1, present2;
18188
18189 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18190 AC_VERB_GET_PIN_SENSE, 0)
18191 & AC_PINSENSE_PRESENCE;
18192 present2 = snd_hda_codec_read(codec, 0x21, 0,
18193 AC_VERB_GET_PIN_SENSE, 0)
18194 & AC_PINSENSE_PRESENCE;
18195
18196 if (present1 || present2) {
18197 snd_hda_codec_write_cache(codec, 0x14, 0,
18198 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18199 snd_hda_codec_write_cache(codec, 0x17, 0,
18200 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18201 } else {
18202 snd_hda_codec_write_cache(codec, 0x14, 0,
18203 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18204 snd_hda_codec_write_cache(codec, 0x17, 0,
18205 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18206 }
18207}
18208
18209static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18210{
18211 unsigned int present1, present2;
18212
18213 present1 = snd_hda_codec_read(codec, 0x21, 0,
18214 AC_VERB_GET_PIN_SENSE, 0)
18215 & AC_PINSENSE_PRESENCE;
18216 present2 = snd_hda_codec_read(codec, 0x15, 0,
18217 AC_VERB_GET_PIN_SENSE, 0)
18218 & AC_PINSENSE_PRESENCE;
18219
18220 if (present1 || present2) {
18221 snd_hda_codec_write_cache(codec, 0x14, 0,
18222 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18223 snd_hda_codec_write_cache(codec, 0x17, 0,
18224 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18225 } else {
18226 snd_hda_codec_write_cache(codec, 0x14, 0,
18227 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18228 snd_hda_codec_write_cache(codec, 0x17, 0,
18229 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18230 }
18231}
18232
Kailang Yang6dda9f42008-05-27 12:05:31 +020018233static void alc663_m51va_unsol_event(struct hda_codec *codec,
18234 unsigned int res)
18235{
18236 switch (res >> 26) {
18237 case ALC880_HP_EVENT:
18238 alc663_m51va_speaker_automute(codec);
18239 break;
18240 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018241 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018242 break;
18243 }
18244}
18245
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018246static void alc663_m51va_setup(struct hda_codec *codec)
18247{
18248 struct alc_spec *spec = codec->spec;
18249 spec->ext_mic.pin = 0x18;
18250 spec->ext_mic.mux_idx = 0;
18251 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018252 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018253 spec->auto_mic = 1;
18254}
18255
Kailang Yang6dda9f42008-05-27 12:05:31 +020018256static void alc663_m51va_inithook(struct hda_codec *codec)
18257{
18258 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018259 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018260}
18261
Kailang Yangf1d4e282008-08-26 14:03:29 +020018262/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018263#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018264
18265static void alc663_mode1_setup(struct hda_codec *codec)
18266{
18267 struct alc_spec *spec = codec->spec;
18268 spec->ext_mic.pin = 0x18;
18269 spec->ext_mic.mux_idx = 0;
18270 spec->int_mic.pin = 0x19;
18271 spec->int_mic.mux_idx = 1;
18272 spec->auto_mic = 1;
18273}
18274
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018275#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018276
Kailang Yangf1d4e282008-08-26 14:03:29 +020018277/* ***************** Mode2 ******************************/
18278static void alc662_mode2_unsol_event(struct hda_codec *codec,
18279 unsigned int res)
18280{
18281 switch (res >> 26) {
18282 case ALC880_HP_EVENT:
18283 alc662_f5z_speaker_automute(codec);
18284 break;
18285 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018286 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018287 break;
18288 }
18289}
18290
Kailang Yangebb83ee2009-12-17 12:23:00 +010018291#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018292
Kailang Yangf1d4e282008-08-26 14:03:29 +020018293static void alc662_mode2_inithook(struct hda_codec *codec)
18294{
18295 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018296 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018297}
18298/* ***************** Mode3 ******************************/
18299static void alc663_mode3_unsol_event(struct hda_codec *codec,
18300 unsigned int res)
18301{
18302 switch (res >> 26) {
18303 case ALC880_HP_EVENT:
18304 alc663_two_hp_m1_speaker_automute(codec);
18305 break;
18306 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018307 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018308 break;
18309 }
18310}
18311
Kailang Yangebb83ee2009-12-17 12:23:00 +010018312#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018313
Kailang Yangf1d4e282008-08-26 14:03:29 +020018314static void alc663_mode3_inithook(struct hda_codec *codec)
18315{
18316 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018317 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018318}
18319/* ***************** Mode4 ******************************/
18320static void alc663_mode4_unsol_event(struct hda_codec *codec,
18321 unsigned int res)
18322{
18323 switch (res >> 26) {
18324 case ALC880_HP_EVENT:
18325 alc663_21jd_two_speaker_automute(codec);
18326 break;
18327 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018328 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018329 break;
18330 }
18331}
18332
Kailang Yangebb83ee2009-12-17 12:23:00 +010018333#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018334
Kailang Yangf1d4e282008-08-26 14:03:29 +020018335static void alc663_mode4_inithook(struct hda_codec *codec)
18336{
18337 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018338 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018339}
18340/* ***************** Mode5 ******************************/
18341static void alc663_mode5_unsol_event(struct hda_codec *codec,
18342 unsigned int res)
18343{
18344 switch (res >> 26) {
18345 case ALC880_HP_EVENT:
18346 alc663_15jd_two_speaker_automute(codec);
18347 break;
18348 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018349 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018350 break;
18351 }
18352}
18353
Kailang Yangebb83ee2009-12-17 12:23:00 +010018354#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018355
Kailang Yangf1d4e282008-08-26 14:03:29 +020018356static void alc663_mode5_inithook(struct hda_codec *codec)
18357{
18358 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018359 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018360}
18361/* ***************** Mode6 ******************************/
18362static void alc663_mode6_unsol_event(struct hda_codec *codec,
18363 unsigned int res)
18364{
18365 switch (res >> 26) {
18366 case ALC880_HP_EVENT:
18367 alc663_two_hp_m2_speaker_automute(codec);
18368 break;
18369 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018370 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018371 break;
18372 }
18373}
18374
Kailang Yangebb83ee2009-12-17 12:23:00 +010018375#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018376
Kailang Yangf1d4e282008-08-26 14:03:29 +020018377static void alc663_mode6_inithook(struct hda_codec *codec)
18378{
18379 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018380 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018381}
18382
Kailang Yangebb83ee2009-12-17 12:23:00 +010018383/* ***************** Mode7 ******************************/
18384static void alc663_mode7_unsol_event(struct hda_codec *codec,
18385 unsigned int res)
18386{
18387 switch (res >> 26) {
18388 case ALC880_HP_EVENT:
18389 alc663_two_hp_m7_speaker_automute(codec);
18390 break;
18391 case ALC880_MIC_EVENT:
18392 alc_mic_automute(codec);
18393 break;
18394 }
18395}
18396
18397#define alc663_mode7_setup alc663_mode1_setup
18398
18399static void alc663_mode7_inithook(struct hda_codec *codec)
18400{
18401 alc663_two_hp_m7_speaker_automute(codec);
18402 alc_mic_automute(codec);
18403}
18404
18405/* ***************** Mode8 ******************************/
18406static void alc663_mode8_unsol_event(struct hda_codec *codec,
18407 unsigned int res)
18408{
18409 switch (res >> 26) {
18410 case ALC880_HP_EVENT:
18411 alc663_two_hp_m8_speaker_automute(codec);
18412 break;
18413 case ALC880_MIC_EVENT:
18414 alc_mic_automute(codec);
18415 break;
18416 }
18417}
18418
18419#define alc663_mode8_setup alc663_m51va_setup
18420
18421static void alc663_mode8_inithook(struct hda_codec *codec)
18422{
18423 alc663_two_hp_m8_speaker_automute(codec);
18424 alc_mic_automute(codec);
18425}
18426
Kailang Yang6dda9f42008-05-27 12:05:31 +020018427static void alc663_g71v_hp_automute(struct hda_codec *codec)
18428{
18429 unsigned int present;
18430 unsigned char bits;
18431
Wu Fengguang864f92b2009-11-18 12:38:02 +080018432 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018433 bits = present ? HDA_AMP_MUTE : 0;
18434 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18435 HDA_AMP_MUTE, bits);
18436 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18437 HDA_AMP_MUTE, bits);
18438}
18439
18440static void alc663_g71v_front_automute(struct hda_codec *codec)
18441{
18442 unsigned int present;
18443 unsigned char bits;
18444
Wu Fengguang864f92b2009-11-18 12:38:02 +080018445 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018446 bits = present ? HDA_AMP_MUTE : 0;
18447 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18448 HDA_AMP_MUTE, bits);
18449}
18450
18451static void alc663_g71v_unsol_event(struct hda_codec *codec,
18452 unsigned int res)
18453{
18454 switch (res >> 26) {
18455 case ALC880_HP_EVENT:
18456 alc663_g71v_hp_automute(codec);
18457 break;
18458 case ALC880_FRONT_EVENT:
18459 alc663_g71v_front_automute(codec);
18460 break;
18461 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018462 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018463 break;
18464 }
18465}
18466
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018467#define alc663_g71v_setup alc663_m51va_setup
18468
Kailang Yang6dda9f42008-05-27 12:05:31 +020018469static void alc663_g71v_inithook(struct hda_codec *codec)
18470{
18471 alc663_g71v_front_automute(codec);
18472 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018473 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018474}
18475
18476static void alc663_g50v_unsol_event(struct hda_codec *codec,
18477 unsigned int res)
18478{
18479 switch (res >> 26) {
18480 case ALC880_HP_EVENT:
18481 alc663_m51va_speaker_automute(codec);
18482 break;
18483 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018484 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018485 break;
18486 }
18487}
18488
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018489#define alc663_g50v_setup alc663_m51va_setup
18490
Kailang Yang6dda9f42008-05-27 12:05:31 +020018491static void alc663_g50v_inithook(struct hda_codec *codec)
18492{
18493 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018494 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018495}
18496
Kailang Yangf1d4e282008-08-26 14:03:29 +020018497static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18498 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018499 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018500
18501 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
18502 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18503 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
18504
18505 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
18506 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18507 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18508 { } /* end */
18509};
18510
Chris Pockelé9541ba12009-05-12 08:08:53 +020018511static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18512 /* Master Playback automatically created from Speaker and Headphone */
18513 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18514 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18515 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18516 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18517
18518 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18519 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
18520 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
18521
18522 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18523 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18524 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
18525 { } /* end */
18526};
18527
Takashi Iwaicb53c622007-08-10 17:21:45 +020018528#ifdef CONFIG_SND_HDA_POWER_SAVE
18529#define alc662_loopbacks alc880_loopbacks
18530#endif
18531
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018532
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018533/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018534#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18535#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18536#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18537#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18538
18539/*
18540 * configuration and preset
18541 */
18542static const char *alc662_models[ALC662_MODEL_LAST] = {
18543 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18544 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18545 [ALC662_3ST_6ch] = "3stack-6ch",
18546 [ALC662_5ST_DIG] = "6stack-dig",
18547 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018548 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018549 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018550 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018551 [ALC663_ASUS_M51VA] = "m51va",
18552 [ALC663_ASUS_G71V] = "g71v",
18553 [ALC663_ASUS_H13] = "h13",
18554 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018555 [ALC663_ASUS_MODE1] = "asus-mode1",
18556 [ALC662_ASUS_MODE2] = "asus-mode2",
18557 [ALC663_ASUS_MODE3] = "asus-mode3",
18558 [ALC663_ASUS_MODE4] = "asus-mode4",
18559 [ALC663_ASUS_MODE5] = "asus-mode5",
18560 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018561 [ALC663_ASUS_MODE7] = "asus-mode7",
18562 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018563 [ALC272_DELL] = "dell",
18564 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018565 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018566 [ALC662_AUTO] = "auto",
18567};
18568
18569static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018570 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018571 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18572 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018573 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18574 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018575 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018576 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18577 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18578 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18579 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018580 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18581 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018582 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018583 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18584 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18585 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18586 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18587 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018588 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018589 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18590 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018591 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18592 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18593 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18594 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018595 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018596 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18597 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18598 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018599 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18600 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18601 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18602 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018603 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018604 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18605 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018606 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018607 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18608 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18609 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018610 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018611 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018612 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18613 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018614 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18615 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18616 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018617 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018618 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18619 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018620 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018621 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018622 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018623 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18624 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18625 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018626 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018627 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18628 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018629 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018630 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018631 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018632 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018633 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18634 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018635 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018636 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018637 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18638 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018639 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018640 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018641 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018642 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018643 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018644 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018645 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18646 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018647 {}
18648};
18649
18650static struct alc_config_preset alc662_presets[] = {
18651 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018652 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018653 .init_verbs = { alc662_init_verbs },
18654 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18655 .dac_nids = alc662_dac_nids,
18656 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018657 .dig_in_nid = ALC662_DIGIN_NID,
18658 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18659 .channel_mode = alc662_3ST_2ch_modes,
18660 .input_mux = &alc662_capture_source,
18661 },
18662 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018663 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018664 .init_verbs = { alc662_init_verbs },
18665 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18666 .dac_nids = alc662_dac_nids,
18667 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018668 .dig_in_nid = ALC662_DIGIN_NID,
18669 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18670 .channel_mode = alc662_3ST_6ch_modes,
18671 .need_dac_fix = 1,
18672 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018673 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018674 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018675 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018676 .init_verbs = { alc662_init_verbs },
18677 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18678 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018679 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18680 .channel_mode = alc662_3ST_6ch_modes,
18681 .need_dac_fix = 1,
18682 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018683 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018684 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018685 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018686 .init_verbs = { alc662_init_verbs },
18687 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18688 .dac_nids = alc662_dac_nids,
18689 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018690 .dig_in_nid = ALC662_DIGIN_NID,
18691 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18692 .channel_mode = alc662_5stack_modes,
18693 .input_mux = &alc662_capture_source,
18694 },
18695 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018696 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018697 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18698 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18699 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018700 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18701 .channel_mode = alc662_3ST_2ch_modes,
18702 .input_mux = &alc662_lenovo_101e_capture_source,
18703 .unsol_event = alc662_lenovo_101e_unsol_event,
18704 .init_hook = alc662_lenovo_101e_all_automute,
18705 },
Kailang Yang291702f2007-10-16 14:28:03 +020018706 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018707 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018708 .init_verbs = { alc662_init_verbs,
18709 alc662_eeepc_sue_init_verbs },
18710 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18711 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018712 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18713 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018714 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018715 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018716 .init_hook = alc662_eeepc_inithook,
18717 },
Kailang Yang8c427222008-01-10 13:03:59 +010018718 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018719 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018720 alc662_chmode_mixer },
18721 .init_verbs = { alc662_init_verbs,
18722 alc662_eeepc_ep20_sue_init_verbs },
18723 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18724 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018725 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18726 .channel_mode = alc662_3ST_6ch_modes,
18727 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018728 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018729 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018730 .init_hook = alc662_eeepc_ep20_inithook,
18731 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018732 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018733 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018734 .init_verbs = { alc662_init_verbs,
18735 alc662_ecs_init_verbs },
18736 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18737 .dac_nids = alc662_dac_nids,
18738 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18739 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018740 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018741 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018742 .init_hook = alc662_eeepc_inithook,
18743 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018744 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018745 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018746 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18747 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18748 .dac_nids = alc662_dac_nids,
18749 .dig_out_nid = ALC662_DIGOUT_NID,
18750 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18751 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018752 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018753 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018754 .init_hook = alc663_m51va_inithook,
18755 },
18756 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018757 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018758 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18759 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18760 .dac_nids = alc662_dac_nids,
18761 .dig_out_nid = ALC662_DIGOUT_NID,
18762 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18763 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018764 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018765 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018766 .init_hook = alc663_g71v_inithook,
18767 },
18768 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018769 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018770 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18771 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18772 .dac_nids = alc662_dac_nids,
18773 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18774 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018775 .unsol_event = alc663_m51va_unsol_event,
18776 .init_hook = alc663_m51va_inithook,
18777 },
18778 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018779 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018780 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18781 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18782 .dac_nids = alc662_dac_nids,
18783 .dig_out_nid = ALC662_DIGOUT_NID,
18784 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18785 .channel_mode = alc662_3ST_6ch_modes,
18786 .input_mux = &alc663_capture_source,
18787 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018788 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018789 .init_hook = alc663_g50v_inithook,
18790 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018791 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018792 .mixers = { alc663_m51va_mixer },
18793 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018794 .init_verbs = { alc662_init_verbs,
18795 alc663_21jd_amic_init_verbs },
18796 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18797 .hp_nid = 0x03,
18798 .dac_nids = alc662_dac_nids,
18799 .dig_out_nid = ALC662_DIGOUT_NID,
18800 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18801 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018802 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018803 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018804 .init_hook = alc663_mode1_inithook,
18805 },
18806 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018807 .mixers = { alc662_1bjd_mixer },
18808 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018809 .init_verbs = { alc662_init_verbs,
18810 alc662_1bjd_amic_init_verbs },
18811 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18812 .dac_nids = alc662_dac_nids,
18813 .dig_out_nid = ALC662_DIGOUT_NID,
18814 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18815 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018816 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018817 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018818 .init_hook = alc662_mode2_inithook,
18819 },
18820 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018821 .mixers = { alc663_two_hp_m1_mixer },
18822 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018823 .init_verbs = { alc662_init_verbs,
18824 alc663_two_hp_amic_m1_init_verbs },
18825 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18826 .hp_nid = 0x03,
18827 .dac_nids = alc662_dac_nids,
18828 .dig_out_nid = ALC662_DIGOUT_NID,
18829 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18830 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018831 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018832 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018833 .init_hook = alc663_mode3_inithook,
18834 },
18835 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018836 .mixers = { alc663_asus_21jd_clfe_mixer },
18837 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018838 .init_verbs = { alc662_init_verbs,
18839 alc663_21jd_amic_init_verbs},
18840 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18841 .hp_nid = 0x03,
18842 .dac_nids = alc662_dac_nids,
18843 .dig_out_nid = ALC662_DIGOUT_NID,
18844 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18845 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018846 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018847 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018848 .init_hook = alc663_mode4_inithook,
18849 },
18850 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018851 .mixers = { alc663_asus_15jd_clfe_mixer },
18852 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018853 .init_verbs = { alc662_init_verbs,
18854 alc663_15jd_amic_init_verbs },
18855 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18856 .hp_nid = 0x03,
18857 .dac_nids = alc662_dac_nids,
18858 .dig_out_nid = ALC662_DIGOUT_NID,
18859 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18860 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018861 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018862 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018863 .init_hook = alc663_mode5_inithook,
18864 },
18865 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018866 .mixers = { alc663_two_hp_m2_mixer },
18867 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018868 .init_verbs = { alc662_init_verbs,
18869 alc663_two_hp_amic_m2_init_verbs },
18870 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18871 .hp_nid = 0x03,
18872 .dac_nids = alc662_dac_nids,
18873 .dig_out_nid = ALC662_DIGOUT_NID,
18874 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18875 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018876 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018877 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018878 .init_hook = alc663_mode6_inithook,
18879 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018880 [ALC663_ASUS_MODE7] = {
18881 .mixers = { alc663_mode7_mixer },
18882 .cap_mixer = alc662_auto_capture_mixer,
18883 .init_verbs = { alc662_init_verbs,
18884 alc663_mode7_init_verbs },
18885 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18886 .hp_nid = 0x03,
18887 .dac_nids = alc662_dac_nids,
18888 .dig_out_nid = ALC662_DIGOUT_NID,
18889 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18890 .channel_mode = alc662_3ST_2ch_modes,
18891 .unsol_event = alc663_mode7_unsol_event,
18892 .setup = alc663_mode7_setup,
18893 .init_hook = alc663_mode7_inithook,
18894 },
18895 [ALC663_ASUS_MODE8] = {
18896 .mixers = { alc663_mode8_mixer },
18897 .cap_mixer = alc662_auto_capture_mixer,
18898 .init_verbs = { alc662_init_verbs,
18899 alc663_mode8_init_verbs },
18900 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18901 .hp_nid = 0x03,
18902 .dac_nids = alc662_dac_nids,
18903 .dig_out_nid = ALC662_DIGOUT_NID,
18904 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18905 .channel_mode = alc662_3ST_2ch_modes,
18906 .unsol_event = alc663_mode8_unsol_event,
18907 .setup = alc663_mode8_setup,
18908 .init_hook = alc663_mode8_inithook,
18909 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018910 [ALC272_DELL] = {
18911 .mixers = { alc663_m51va_mixer },
18912 .cap_mixer = alc272_auto_capture_mixer,
18913 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18914 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18915 .dac_nids = alc662_dac_nids,
18916 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18917 .adc_nids = alc272_adc_nids,
18918 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18919 .capsrc_nids = alc272_capsrc_nids,
18920 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018921 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018922 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018923 .init_hook = alc663_m51va_inithook,
18924 },
18925 [ALC272_DELL_ZM1] = {
18926 .mixers = { alc663_m51va_mixer },
18927 .cap_mixer = alc662_auto_capture_mixer,
18928 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18929 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18930 .dac_nids = alc662_dac_nids,
18931 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18932 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018933 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018934 .capsrc_nids = alc662_capsrc_nids,
18935 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018936 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018937 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018938 .init_hook = alc663_m51va_inithook,
18939 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018940 [ALC272_SAMSUNG_NC10] = {
18941 .mixers = { alc272_nc10_mixer },
18942 .init_verbs = { alc662_init_verbs,
18943 alc663_21jd_amic_init_verbs },
18944 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18945 .dac_nids = alc272_dac_nids,
18946 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18947 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018948 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018949 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018950 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018951 .init_hook = alc663_mode4_inithook,
18952 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018953};
18954
18955
18956/*
18957 * BIOS auto configuration
18958 */
18959
Takashi Iwai7085ec12009-10-02 09:03:58 +020018960/* convert from MIX nid to DAC */
18961static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18962{
18963 if (nid == 0x0f)
18964 return 0x02;
18965 else if (nid >= 0x0c && nid <= 0x0e)
18966 return nid - 0x0c + 0x02;
18967 else
18968 return 0;
18969}
18970
18971/* get MIX nid connected to the given pin targeted to DAC */
18972static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18973 hda_nid_t dac)
18974{
18975 hda_nid_t mix[4];
18976 int i, num;
18977
18978 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18979 for (i = 0; i < num; i++) {
18980 if (alc662_mix_to_dac(mix[i]) == dac)
18981 return mix[i];
18982 }
18983 return 0;
18984}
18985
18986/* look for an empty DAC slot */
18987static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18988{
18989 struct alc_spec *spec = codec->spec;
18990 hda_nid_t srcs[5];
18991 int i, j, num;
18992
18993 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18994 if (num < 0)
18995 return 0;
18996 for (i = 0; i < num; i++) {
18997 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18998 if (!nid)
18999 continue;
19000 for (j = 0; j < spec->multiout.num_dacs; j++)
19001 if (spec->multiout.dac_nids[j] == nid)
19002 break;
19003 if (j >= spec->multiout.num_dacs)
19004 return nid;
19005 }
19006 return 0;
19007}
19008
19009/* fill in the dac_nids table from the parsed pin configuration */
19010static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
19011 const struct auto_pin_cfg *cfg)
19012{
19013 struct alc_spec *spec = codec->spec;
19014 int i;
19015 hda_nid_t dac;
19016
19017 spec->multiout.dac_nids = spec->private_dac_nids;
19018 for (i = 0; i < cfg->line_outs; i++) {
19019 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
19020 if (!dac)
19021 continue;
19022 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19023 }
19024 return 0;
19025}
19026
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019027static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019028 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019029{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019030 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019031 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
19032}
19033
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019034static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019035 hda_nid_t nid, unsigned int chs)
19036{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019037 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019038 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
19039}
19040
19041#define alc662_add_stereo_vol(spec, pfx, nid) \
19042 alc662_add_vol_ctl(spec, pfx, nid, 3)
19043#define alc662_add_stereo_sw(spec, pfx, nid) \
19044 alc662_add_sw_ctl(spec, pfx, nid, 3)
19045
19046/* add playback controls from the parsed DAC table */
19047static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
19048 const struct auto_pin_cfg *cfg)
19049{
19050 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019051 static const char *chname[4] = {
19052 "Front", "Surround", NULL /*CLFE*/, "Side"
19053 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020019054 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019055 int i, err;
19056
19057 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019058 nid = spec->multiout.dac_nids[i];
19059 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019060 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019061 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
19062 if (!mix)
19063 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019064 if (i == 2) {
19065 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019066 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019067 if (err < 0)
19068 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019069 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019070 if (err < 0)
19071 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019072 err = alc662_add_sw_ctl(spec, "Center", mix, 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_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019076 if (err < 0)
19077 return err;
19078 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019079 const char *pfx;
19080 if (cfg->line_outs == 1 &&
19081 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019082 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019083 pfx = "Speaker";
19084 else
19085 pfx = "PCM";
19086 } else
19087 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019088 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019089 if (err < 0)
19090 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019091 if (cfg->line_outs == 1 &&
19092 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19093 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020019094 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019095 if (err < 0)
19096 return err;
19097 }
19098 }
19099 return 0;
19100}
19101
19102/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019103/* return DAC nid if any new DAC is assigned */
19104static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019105 const char *pfx)
19106{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019107 struct alc_spec *spec = codec->spec;
19108 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019109 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019110
19111 if (!pin)
19112 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019113 nid = alc662_look_for_dac(codec, pin);
19114 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019115 /* the corresponding DAC is already occupied */
19116 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19117 return 0; /* no way */
19118 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019119 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019120 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19121 }
19122
19123 mix = alc662_dac_to_mix(codec, pin, nid);
19124 if (!mix)
19125 return 0;
19126 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19127 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019128 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019129 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19130 if (err < 0)
19131 return err;
19132 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019133}
19134
19135/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019136#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019137 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019138
19139static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19140 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019141 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019142{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019143 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019144 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019145
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019146 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019147 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019148 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19149 if (num <= 1)
19150 return;
19151 for (i = 0; i < num; i++) {
19152 if (alc662_mix_to_dac(srcs[i]) != dac)
19153 continue;
19154 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19155 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019156 }
19157}
19158
19159static void alc662_auto_init_multi_out(struct hda_codec *codec)
19160{
19161 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019162 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019163 int i;
19164
19165 for (i = 0; i <= HDA_SIDE; i++) {
19166 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19167 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019168 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019169 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019170 }
19171}
19172
19173static void alc662_auto_init_hp_out(struct hda_codec *codec)
19174{
19175 struct alc_spec *spec = codec->spec;
19176 hda_nid_t pin;
19177
19178 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019179 if (pin)
19180 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19181 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019182 pin = spec->autocfg.speaker_pins[0];
19183 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019184 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19185 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019186}
19187
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019188#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19189
19190static void alc662_auto_init_analog_input(struct hda_codec *codec)
19191{
19192 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019193 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019194 int i;
19195
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019196 for (i = 0; i < cfg->num_inputs; i++) {
19197 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019198 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019199 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019200 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019201 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019202 snd_hda_codec_write(codec, nid, 0,
19203 AC_VERB_SET_AMP_GAIN_MUTE,
19204 AMP_OUT_MUTE);
19205 }
19206 }
19207}
19208
Takashi Iwaif511b012008-08-15 16:46:42 +020019209#define alc662_auto_init_input_src alc882_auto_init_input_src
19210
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019211static int alc662_parse_auto_config(struct hda_codec *codec)
19212{
19213 struct alc_spec *spec = codec->spec;
19214 int err;
19215 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19216
19217 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19218 alc662_ignore);
19219 if (err < 0)
19220 return err;
19221 if (!spec->autocfg.line_outs)
19222 return 0; /* can't find valid BIOS pin config */
19223
Takashi Iwai7085ec12009-10-02 09:03:58 +020019224 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019225 if (err < 0)
19226 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019227 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019228 if (err < 0)
19229 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019230 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019231 spec->autocfg.speaker_pins[0],
19232 "Speaker");
19233 if (err < 0)
19234 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019235 if (err)
19236 spec->multiout.extra_out_nid[0] = err;
19237 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019238 "Headphone");
19239 if (err < 0)
19240 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019241 if (err)
19242 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019243 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019244 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019245 return err;
19246
19247 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19248
Takashi Iwai757899a2010-07-30 10:48:14 +020019249 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019250
Takashi Iwai603c4012008-07-30 15:01:44 +020019251 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019252 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019253
19254 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019255 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019256
Kailang Yangcec27c82010-02-04 14:18:18 +010019257 add_verb(spec, alc662_init_verbs);
19258 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019259 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019260 add_verb(spec, alc663_init_verbs);
19261
19262 if (codec->vendor_id == 0x10ec0272)
19263 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019264
19265 err = alc_auto_add_mic_boost(codec);
19266 if (err < 0)
19267 return err;
19268
Kailang Yang6227cdc2010-02-25 08:36:52 +010019269 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19270 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19271 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19272 else
19273 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019274
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019275 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019276}
19277
19278/* additional initialization for auto-configuration model */
19279static void alc662_auto_init(struct hda_codec *codec)
19280{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019281 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019282 alc662_auto_init_multi_out(codec);
19283 alc662_auto_init_hp_out(codec);
19284 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019285 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019286 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019287 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019288 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019289}
19290
David Henningsson6cb3b702010-09-09 08:51:44 +020019291enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040019292 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019293 ALC662_FIXUP_IDEAPAD,
19294};
19295
19296static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019297 [ALC662_FIXUP_ASPIRE] = {
19298 .pins = (const struct alc_pincfg[]) {
19299 { 0x15, 0x99130112 }, /* subwoofer */
19300 { }
19301 }
19302 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019303 [ALC662_FIXUP_IDEAPAD] = {
19304 .pins = (const struct alc_pincfg[]) {
19305 { 0x17, 0x99130112 }, /* subwoofer */
19306 { }
19307 }
19308 },
19309};
19310
19311static struct snd_pci_quirk alc662_fixup_tbl[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019312 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050019313 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060019314 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020019315 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
19316 {}
19317};
19318
19319
19320
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019321static int patch_alc662(struct hda_codec *codec)
19322{
19323 struct alc_spec *spec;
19324 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020019325 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019326
19327 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19328 if (!spec)
19329 return -ENOMEM;
19330
19331 codec->spec = spec;
19332
Kailang Yangda00c242010-03-19 11:23:45 +010019333 alc_auto_parse_customize_define(codec);
19334
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019335 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19336
Kailang Yang693194f2010-10-21 08:51:48 +020019337 coef = alc_read_coef_idx(codec, 0);
19338 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019339 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020019340 else if (coef & (1 << 14) &&
19341 codec->bus->pci->subsystem_vendor == 0x1025 &&
19342 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019343 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019344 else if (coef == 0x4011)
19345 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019346
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019347 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19348 alc662_models,
19349 alc662_cfg_tbl);
19350 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019351 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19352 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019353 board_config = ALC662_AUTO;
19354 }
19355
19356 if (board_config == ALC662_AUTO) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019357 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019358 /* automatic parse from the BIOS config */
19359 err = alc662_parse_auto_config(codec);
19360 if (err < 0) {
19361 alc_free(codec);
19362 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019363 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019364 printk(KERN_INFO
19365 "hda_codec: Cannot set up configuration "
19366 "from BIOS. Using base mode...\n");
19367 board_config = ALC662_3ST_2ch_DIG;
19368 }
19369 }
19370
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019371 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019372 err = snd_hda_attach_beep_device(codec, 0x1);
19373 if (err < 0) {
19374 alc_free(codec);
19375 return err;
19376 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019377 }
19378
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019379 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019380 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019381
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019382 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19383 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19384
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019385 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19386 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19387
Takashi Iwaidd704692009-08-11 08:45:11 +020019388 if (!spec->adc_nids) {
19389 spec->adc_nids = alc662_adc_nids;
19390 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19391 }
19392 if (!spec->capsrc_nids)
19393 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019394
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019395 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019396 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019397
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019398 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019399 switch (codec->vendor_id) {
19400 case 0x10ec0662:
19401 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19402 break;
19403 case 0x10ec0272:
19404 case 0x10ec0663:
19405 case 0x10ec0665:
19406 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19407 break;
19408 case 0x10ec0273:
19409 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19410 break;
19411 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019412 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019413 spec->vmaster_nid = 0x02;
19414
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019415 codec->patch_ops = alc_patch_ops;
David Henningsson6cb3b702010-09-09 08:51:44 +020019416 if (board_config == ALC662_AUTO) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019417 spec->init_hook = alc662_auto_init;
David Henningsson6cb3b702010-09-09 08:51:44 +020019418 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 0);
19419 }
19420
Kailang Yangbf1b0222010-10-21 08:49:56 +020019421 alc_init_jacks(codec);
19422
Takashi Iwaicb53c622007-08-10 17:21:45 +020019423#ifdef CONFIG_SND_HDA_POWER_SAVE
19424 if (!spec->loopback.amplist)
19425 spec->loopback.amplist = alc662_loopbacks;
19426#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019427
19428 return 0;
19429}
19430
Kailang Yang274693f2009-12-03 10:07:50 +010019431static int patch_alc888(struct hda_codec *codec)
19432{
19433 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19434 kfree(codec->chip_name);
Kailang Yang01e0f132010-11-22 10:59:36 +010019435 if (codec->vendor_id == 0x10ec0887)
19436 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19437 else
19438 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019439 if (!codec->chip_name) {
19440 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019441 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019442 }
19443 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019444 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019445 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019446}
19447
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019448/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019449 * ALC680 support
19450 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019451#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019452#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19453#define alc680_modes alc260_modes
19454
19455static hda_nid_t alc680_dac_nids[3] = {
19456 /* Lout1, Lout2, hp */
19457 0x02, 0x03, 0x04
19458};
19459
19460static hda_nid_t alc680_adc_nids[3] = {
19461 /* ADC0-2 */
19462 /* DMIC, MIC, Line-in*/
19463 0x07, 0x08, 0x09
19464};
19465
Kailang Yangc69aefa2010-08-17 10:39:22 +020019466/*
19467 * Analog capture ADC cgange
19468 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019469static void alc680_rec_autoswitch(struct hda_codec *codec)
19470{
19471 struct alc_spec *spec = codec->spec;
19472 struct auto_pin_cfg *cfg = &spec->autocfg;
19473 int pin_found = 0;
19474 int type_found = AUTO_PIN_LAST;
19475 hda_nid_t nid;
19476 int i;
19477
19478 for (i = 0; i < cfg->num_inputs; i++) {
19479 nid = cfg->inputs[i].pin;
19480 if (!(snd_hda_query_pin_caps(codec, nid) &
19481 AC_PINCAP_PRES_DETECT))
19482 continue;
19483 if (snd_hda_jack_detect(codec, nid)) {
19484 if (cfg->inputs[i].type < type_found) {
19485 type_found = cfg->inputs[i].type;
19486 pin_found = nid;
19487 }
19488 }
19489 }
19490
19491 nid = 0x07;
19492 if (pin_found)
19493 snd_hda_get_connections(codec, pin_found, &nid, 1);
19494
19495 if (nid != spec->cur_adc)
19496 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19497 spec->cur_adc = nid;
19498 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19499 spec->cur_adc_format);
19500}
19501
Kailang Yangc69aefa2010-08-17 10:39:22 +020019502static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19503 struct hda_codec *codec,
19504 unsigned int stream_tag,
19505 unsigned int format,
19506 struct snd_pcm_substream *substream)
19507{
19508 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019509
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019510 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019511 spec->cur_adc_stream_tag = stream_tag;
19512 spec->cur_adc_format = format;
19513
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019514 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019515 return 0;
19516}
19517
19518static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19519 struct hda_codec *codec,
19520 struct snd_pcm_substream *substream)
19521{
19522 snd_hda_codec_cleanup_stream(codec, 0x07);
19523 snd_hda_codec_cleanup_stream(codec, 0x08);
19524 snd_hda_codec_cleanup_stream(codec, 0x09);
19525 return 0;
19526}
19527
19528static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19529 .substreams = 1, /* can be overridden */
19530 .channels_min = 2,
19531 .channels_max = 2,
19532 /* NID is set in alc_build_pcms */
19533 .ops = {
19534 .prepare = alc680_capture_pcm_prepare,
19535 .cleanup = alc680_capture_pcm_cleanup
19536 },
19537};
19538
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019539static struct snd_kcontrol_new alc680_base_mixer[] = {
19540 /* output mixer control */
19541 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19542 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19543 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19544 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019545 HDA_CODEC_VOLUME("Int Mic Boost", 0x12, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019546 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019547 HDA_CODEC_VOLUME("Line In Boost", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019548 { }
19549};
19550
Kailang Yangc69aefa2010-08-17 10:39:22 +020019551static struct hda_bind_ctls alc680_bind_cap_vol = {
19552 .ops = &snd_hda_bind_vol,
19553 .values = {
19554 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19555 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19556 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19557 0
19558 },
19559};
19560
19561static struct hda_bind_ctls alc680_bind_cap_switch = {
19562 .ops = &snd_hda_bind_sw,
19563 .values = {
19564 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19565 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19566 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19567 0
19568 },
19569};
19570
19571static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19572 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19573 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019574 { } /* end */
19575};
19576
19577/*
19578 * generic initialization of ADC, input mixers and output mixers
19579 */
19580static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019581 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19582 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19583 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019584
Kailang Yangc69aefa2010-08-17 10:39:22 +020019585 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19586 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19587 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19588 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19589 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19590 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019591
19592 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19593 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19594 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19595 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19596 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019597
19598 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19599 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019600 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019601
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019602 { }
19603};
19604
Kailang Yangc69aefa2010-08-17 10:39:22 +020019605/* toggle speaker-output according to the hp-jack state */
19606static void alc680_base_setup(struct hda_codec *codec)
19607{
19608 struct alc_spec *spec = codec->spec;
19609
19610 spec->autocfg.hp_pins[0] = 0x16;
19611 spec->autocfg.speaker_pins[0] = 0x14;
19612 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019613 spec->autocfg.num_inputs = 2;
19614 spec->autocfg.inputs[0].pin = 0x18;
19615 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19616 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019617 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019618}
19619
19620static void alc680_unsol_event(struct hda_codec *codec,
19621 unsigned int res)
19622{
19623 if ((res >> 26) == ALC880_HP_EVENT)
19624 alc_automute_amp(codec);
19625 if ((res >> 26) == ALC880_MIC_EVENT)
19626 alc680_rec_autoswitch(codec);
19627}
19628
19629static void alc680_inithook(struct hda_codec *codec)
19630{
19631 alc_automute_amp(codec);
19632 alc680_rec_autoswitch(codec);
19633}
19634
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019635/* create input playback/capture controls for the given pin */
19636static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19637 const char *ctlname, int idx)
19638{
19639 hda_nid_t dac;
19640 int err;
19641
19642 switch (nid) {
19643 case 0x14:
19644 dac = 0x02;
19645 break;
19646 case 0x15:
19647 dac = 0x03;
19648 break;
19649 case 0x16:
19650 dac = 0x04;
19651 break;
19652 default:
19653 return 0;
19654 }
19655 if (spec->multiout.dac_nids[0] != dac &&
19656 spec->multiout.dac_nids[1] != dac) {
19657 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19658 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19659 HDA_OUTPUT));
19660 if (err < 0)
19661 return err;
19662
19663 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19664 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19665
19666 if (err < 0)
19667 return err;
19668 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19669 }
19670
19671 return 0;
19672}
19673
19674/* add playback controls from the parsed DAC table */
19675static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19676 const struct auto_pin_cfg *cfg)
19677{
19678 hda_nid_t nid;
19679 int err;
19680
19681 spec->multiout.dac_nids = spec->private_dac_nids;
19682
19683 nid = cfg->line_out_pins[0];
19684 if (nid) {
19685 const char *name;
19686 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19687 name = "Speaker";
19688 else
19689 name = "Front";
19690 err = alc680_new_analog_output(spec, nid, name, 0);
19691 if (err < 0)
19692 return err;
19693 }
19694
19695 nid = cfg->speaker_pins[0];
19696 if (nid) {
19697 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19698 if (err < 0)
19699 return err;
19700 }
19701 nid = cfg->hp_pins[0];
19702 if (nid) {
19703 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19704 if (err < 0)
19705 return err;
19706 }
19707
19708 return 0;
19709}
19710
19711static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19712 hda_nid_t nid, int pin_type)
19713{
19714 alc_set_pin_output(codec, nid, pin_type);
19715}
19716
19717static void alc680_auto_init_multi_out(struct hda_codec *codec)
19718{
19719 struct alc_spec *spec = codec->spec;
19720 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19721 if (nid) {
19722 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19723 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19724 }
19725}
19726
19727static void alc680_auto_init_hp_out(struct hda_codec *codec)
19728{
19729 struct alc_spec *spec = codec->spec;
19730 hda_nid_t pin;
19731
19732 pin = spec->autocfg.hp_pins[0];
19733 if (pin)
19734 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19735 pin = spec->autocfg.speaker_pins[0];
19736 if (pin)
19737 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19738}
19739
19740/* pcm configuration: identical with ALC880 */
19741#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19742#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19743#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19744#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019745#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019746
19747/*
19748 * BIOS auto configuration
19749 */
19750static int alc680_parse_auto_config(struct hda_codec *codec)
19751{
19752 struct alc_spec *spec = codec->spec;
19753 int err;
19754 static hda_nid_t alc680_ignore[] = { 0 };
19755
19756 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19757 alc680_ignore);
19758 if (err < 0)
19759 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019760
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019761 if (!spec->autocfg.line_outs) {
19762 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19763 spec->multiout.max_channels = 2;
19764 spec->no_analog = 1;
19765 goto dig_only;
19766 }
19767 return 0; /* can't find valid BIOS pin config */
19768 }
19769 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19770 if (err < 0)
19771 return err;
19772
19773 spec->multiout.max_channels = 2;
19774
19775 dig_only:
19776 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019777 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019778 if (spec->kctls.list)
19779 add_mixer(spec, spec->kctls.list);
19780
19781 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019782
19783 err = alc_auto_add_mic_boost(codec);
19784 if (err < 0)
19785 return err;
19786
19787 return 1;
19788}
19789
19790#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19791
19792/* init callback for auto-configuration model -- overriding the default init */
19793static void alc680_auto_init(struct hda_codec *codec)
19794{
19795 struct alc_spec *spec = codec->spec;
19796 alc680_auto_init_multi_out(codec);
19797 alc680_auto_init_hp_out(codec);
19798 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019799 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019800 if (spec->unsol_event)
19801 alc_inithook(codec);
19802}
19803
19804/*
19805 * configuration and preset
19806 */
19807static const char *alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019808 [ALC680_BASE] = "base",
19809 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019810};
19811
19812static struct snd_pci_quirk alc680_cfg_tbl[] = {
19813 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19814 {}
19815};
19816
19817static struct alc_config_preset alc680_presets[] = {
19818 [ALC680_BASE] = {
19819 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019820 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019821 .init_verbs = { alc680_init_verbs },
19822 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19823 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019824 .dig_out_nid = ALC680_DIGOUT_NID,
19825 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19826 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019827 .unsol_event = alc680_unsol_event,
19828 .setup = alc680_base_setup,
19829 .init_hook = alc680_inithook,
19830
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019831 },
19832};
19833
19834static int patch_alc680(struct hda_codec *codec)
19835{
19836 struct alc_spec *spec;
19837 int board_config;
19838 int err;
19839
19840 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19841 if (spec == NULL)
19842 return -ENOMEM;
19843
19844 codec->spec = spec;
19845
19846 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19847 alc680_models,
19848 alc680_cfg_tbl);
19849
19850 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19851 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19852 codec->chip_name);
19853 board_config = ALC680_AUTO;
19854 }
19855
19856 if (board_config == ALC680_AUTO) {
19857 /* automatic parse from the BIOS config */
19858 err = alc680_parse_auto_config(codec);
19859 if (err < 0) {
19860 alc_free(codec);
19861 return err;
19862 } else if (!err) {
19863 printk(KERN_INFO
19864 "hda_codec: Cannot set up configuration "
19865 "from BIOS. Using base mode...\n");
19866 board_config = ALC680_BASE;
19867 }
19868 }
19869
19870 if (board_config != ALC680_AUTO)
19871 setup_preset(codec, &alc680_presets[board_config]);
19872
19873 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019874 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019875 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019876 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019877
19878 if (!spec->adc_nids) {
19879 spec->adc_nids = alc680_adc_nids;
19880 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
19881 }
19882
19883 if (!spec->cap_mixer)
19884 set_capture_mixer(codec);
19885
19886 spec->vmaster_nid = 0x02;
19887
19888 codec->patch_ops = alc_patch_ops;
19889 if (board_config == ALC680_AUTO)
19890 spec->init_hook = alc680_auto_init;
19891
19892 return 0;
19893}
19894
19895/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019896 * patch entries
19897 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019898static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070019899 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019900 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019901 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020019902 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019903 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019904 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020019905 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019906 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019907 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019908 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019909 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
19910 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
19911 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019912 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019913 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019914 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
19915 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020019916 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010019917 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010019918 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019919 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019920 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019921 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019922 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020019923 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019924 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020019925 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019926 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019927 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yang01e0f132010-11-22 10:59:36 +010019928 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
Kailang Yang44426082008-10-15 11:18:05 +020019929 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019930 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019931 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019932 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019933 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019934 {} /* terminator */
19935};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019936
19937MODULE_ALIAS("snd-hda-codec-id:10ec*");
19938
19939MODULE_LICENSE("GPL");
19940MODULE_DESCRIPTION("Realtek HD-audio codec");
19941
19942static struct hda_codec_preset_list realtek_list = {
19943 .preset = snd_hda_preset_realtek,
19944 .owner = THIS_MODULE,
19945};
19946
19947static int __init patch_realtek_init(void)
19948{
19949 return snd_hda_add_codec_preset(&realtek_list);
19950}
19951
19952static void __exit patch_realtek_exit(void)
19953{
19954 snd_hda_delete_codec_preset(&realtek_list);
19955}
19956
19957module_init(patch_realtek_init)
19958module_exit(patch_realtek_exit)