blob: 8e7948f56106c565aa7c68116baaa1cd143cb318 [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ünther3e1647c2009-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:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +01001617 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001618 spec->init_amp = ALC_INIT_DEFAULT;
1619 break;
1620 }
1621
1622 /* is laptop or Desktop and enable the function "Mute internal speaker
1623 * when the external headphone out jack is plugged"
1624 */
1625 if (!(ass & 0x8000))
1626 return 1;
1627 /*
1628 * 10~8 : Jack location
1629 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1630 * 14~13: Resvered
1631 * 15 : 1 --> enable the function "Mute internal speaker
1632 * when the external headphone out jack is plugged"
1633 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001634 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001635 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001636 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1637 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001638 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001639 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001640 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001641 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001642 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001643 else if (tmp == 3)
1644 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001645 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001646 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001647 for (i = 0; i < spec->autocfg.line_outs; i++)
1648 if (spec->autocfg.line_out_pins[i] == nid)
1649 return 1;
1650 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001651 }
1652
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001653 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001654 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001655 return 1;
1656}
Kailang Yangea1fb292008-08-26 12:58:38 +02001657
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001658static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001659 hda_nid_t porta, hda_nid_t porte,
1660 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001661{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001662 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001663 struct alc_spec *spec = codec->spec;
1664 snd_printd("realtek: "
1665 "Enable default setup for auto mode as fallback\n");
1666 spec->init_amp = ALC_INIT_DEFAULT;
1667 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001668 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001669 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001670}
1671
Takashi Iwai41e41f12005-06-08 14:48:49 +02001672/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001673 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001674 */
1675
1676struct alc_pincfg {
1677 hda_nid_t nid;
1678 u32 val;
1679};
1680
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001681struct alc_fixup {
David Henningsson90622912010-10-14 14:50:18 +02001682 unsigned int sku;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001683 const struct alc_pincfg *pins;
1684 const struct hda_verb *verbs;
1685};
1686
1687static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001688 const struct snd_pci_quirk *quirk,
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001689 const struct alc_fixup *fix,
1690 int pre_init)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001691{
1692 const struct alc_pincfg *cfg;
David Henningsson90622912010-10-14 14:50:18 +02001693 struct alc_spec *spec;
Takashi Iwaif95474e2007-07-10 00:47:43 +02001694
1695 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1696 if (!quirk)
1697 return;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001698 fix += quirk->value;
1699 cfg = fix->pins;
David Henningsson90622912010-10-14 14:50:18 +02001700 if (pre_init && fix->sku) {
1701#ifdef CONFIG_SND_DEBUG_VERBOSE
1702 snd_printdd(KERN_INFO "hda_codec: %s: Apply sku override for %s\n",
1703 codec->chip_name, quirk->name);
1704#endif
1705 spec = codec->spec;
1706 spec->cdefine.sku_cfg = fix->sku;
1707 spec->cdefine.fixup = 1;
1708 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001709 if (pre_init && cfg) {
1710#ifdef CONFIG_SND_DEBUG_VERBOSE
1711 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1712 codec->chip_name, quirk->name);
1713#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001714 for (; cfg->nid; cfg++)
1715 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1716 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001717 if (!pre_init && fix->verbs) {
1718#ifdef CONFIG_SND_DEBUG_VERBOSE
1719 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1720 codec->chip_name, quirk->name);
1721#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001722 add_verb(codec->spec, fix->verbs);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001723 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001724}
1725
Kailang Yang274693f2009-12-03 10:07:50 +01001726static int alc_read_coef_idx(struct hda_codec *codec,
1727 unsigned int coef_idx)
1728{
1729 unsigned int val;
1730 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1731 coef_idx);
1732 val = snd_hda_codec_read(codec, 0x20, 0,
1733 AC_VERB_GET_PROC_COEF, 0);
1734 return val;
1735}
1736
Kailang Yang977ddd62010-09-15 10:02:29 +02001737static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1738 unsigned int coef_val)
1739{
1740 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1741 coef_idx);
1742 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1743 coef_val);
1744}
1745
Takashi Iwai757899a2010-07-30 10:48:14 +02001746/* set right pin controls for digital I/O */
1747static void alc_auto_init_digital(struct hda_codec *codec)
1748{
1749 struct alc_spec *spec = codec->spec;
1750 int i;
1751 hda_nid_t pin;
1752
1753 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1754 pin = spec->autocfg.dig_out_pins[i];
1755 if (pin) {
1756 snd_hda_codec_write(codec, pin, 0,
1757 AC_VERB_SET_PIN_WIDGET_CONTROL,
1758 PIN_OUT);
1759 }
1760 }
1761 pin = spec->autocfg.dig_in_pin;
1762 if (pin)
1763 snd_hda_codec_write(codec, pin, 0,
1764 AC_VERB_SET_PIN_WIDGET_CONTROL,
1765 PIN_IN);
1766}
1767
1768/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1769static void alc_auto_parse_digital(struct hda_codec *codec)
1770{
1771 struct alc_spec *spec = codec->spec;
1772 int i, err;
1773 hda_nid_t dig_nid;
1774
1775 /* support multiple SPDIFs; the secondary is set up as a slave */
1776 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1777 err = snd_hda_get_connections(codec,
1778 spec->autocfg.dig_out_pins[i],
1779 &dig_nid, 1);
1780 if (err < 0)
1781 continue;
1782 if (!i) {
1783 spec->multiout.dig_out_nid = dig_nid;
1784 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1785 } else {
1786 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1787 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1788 break;
1789 spec->slave_dig_outs[i - 1] = dig_nid;
1790 }
1791 }
1792
1793 if (spec->autocfg.dig_in_pin) {
Takashi Iwai01fdf182010-09-24 09:09:42 +02001794 dig_nid = codec->start_nid;
1795 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1796 unsigned int wcaps = get_wcaps(codec, dig_nid);
1797 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1798 continue;
1799 if (!(wcaps & AC_WCAP_DIGITAL))
1800 continue;
1801 if (!(wcaps & AC_WCAP_CONN_LIST))
1802 continue;
1803 err = get_connection_index(codec, dig_nid,
1804 spec->autocfg.dig_in_pin);
1805 if (err >= 0) {
1806 spec->dig_in_nid = dig_nid;
1807 break;
1808 }
1809 }
Takashi Iwai757899a2010-07-30 10:48:14 +02001810 }
1811}
1812
Takashi Iwaif95474e2007-07-10 00:47:43 +02001813/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001814 * ALC888
1815 */
1816
1817/*
1818 * 2ch mode
1819 */
1820static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1821/* Mic-in jack as mic in */
1822 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1823 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1824/* Line-in jack as Line in */
1825 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1826 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1827/* Line-Out as Front */
1828 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1829 { } /* end */
1830};
1831
1832/*
1833 * 4ch mode
1834 */
1835static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1836/* Mic-in jack as mic in */
1837 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1838 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1839/* Line-in jack as Surround */
1840 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1841 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1842/* Line-Out as Front */
1843 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1844 { } /* end */
1845};
1846
1847/*
1848 * 6ch mode
1849 */
1850static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1851/* Mic-in jack as CLFE */
1852 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1853 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1854/* Line-in jack as Surround */
1855 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1856 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1857/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1858 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1859 { } /* end */
1860};
1861
1862/*
1863 * 8ch mode
1864 */
1865static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1866/* Mic-in jack as CLFE */
1867 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1868 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1869/* Line-in jack as Surround */
1870 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1871 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1872/* Line-Out as Side */
1873 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1874 { } /* end */
1875};
1876
1877static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1878 { 2, alc888_4ST_ch2_intel_init },
1879 { 4, alc888_4ST_ch4_intel_init },
1880 { 6, alc888_4ST_ch6_intel_init },
1881 { 8, alc888_4ST_ch8_intel_init },
1882};
1883
1884/*
1885 * ALC888 Fujitsu Siemens Amillo xa3530
1886 */
1887
1888static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1889/* Front Mic: set to PIN_IN (empty by default) */
1890 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1891/* Connect Internal HP to Front */
1892 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1893 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1894 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1895/* Connect Bass HP to Front */
1896 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1897 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1898 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1899/* Connect Line-Out side jack (SPDIF) to Side */
1900 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1901 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1902 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1903/* Connect Mic jack to CLFE */
1904 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1905 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1906 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1907/* Connect Line-in jack to Surround */
1908 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1909 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1910 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1911/* Connect HP out jack to Front */
1912 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1913 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1914 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1915/* Enable unsolicited event for HP jack and Line-out jack */
1916 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1917 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1918 {}
1919};
1920
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001921static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001922{
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001923 alc_automute_speaker(codec, 0);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001924}
1925
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001926static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1927 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001928{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001929 if (codec->vendor_id == 0x10ec0880)
1930 res >>= 28;
1931 else
1932 res >>= 26;
1933 if (res == ALC880_HP_EVENT)
1934 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001935}
1936
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001937static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001938{
1939 struct alc_spec *spec = codec->spec;
1940
1941 spec->autocfg.hp_pins[0] = 0x15;
1942 spec->autocfg.speaker_pins[0] = 0x14;
1943 spec->autocfg.speaker_pins[1] = 0x16;
1944 spec->autocfg.speaker_pins[2] = 0x17;
1945 spec->autocfg.speaker_pins[3] = 0x19;
1946 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001947}
1948
1949static void alc889_intel_init_hook(struct hda_codec *codec)
1950{
1951 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001952 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001953}
1954
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001955static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001956{
1957 struct alc_spec *spec = codec->spec;
1958
1959 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1960 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1961 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1962 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001963}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001964
1965/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001966 * ALC888 Acer Aspire 4930G model
1967 */
1968
1969static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1970/* Front Mic: set to PIN_IN (empty by default) */
1971 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1972/* Unselect Front Mic by default in input mixer 3 */
1973 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001974/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001975 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1976/* Connect Internal HP to front */
1977 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1978 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1979 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1980/* Connect HP out to front */
1981 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1982 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1983 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1984 { }
1985};
1986
Hector Martin3b315d72009-06-02 10:54:19 +02001987/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001988 * ALC888 Acer Aspire 6530G model
1989 */
1990
1991static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01001992/* Route to built-in subwoofer as well as speakers */
1993 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1994 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1995 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1996 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001997/* Bias voltage on for external mic port */
1998 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001999/* Front Mic: set to PIN_IN (empty by default) */
2000 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2001/* Unselect Front Mic by default in input mixer 3 */
2002 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002003/* Enable unsolicited event for HP jack */
2004 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2005/* Enable speaker output */
2006 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2007 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01002008 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002009/* Enable headphone output */
2010 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2011 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2012 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01002013 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002014 { }
2015};
2016
2017/*
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002018 *ALC888 Acer Aspire 7730G model
2019 */
2020
2021static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
2022/* Bias voltage on for external mic port */
2023 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2024/* Front Mic: set to PIN_IN (empty by default) */
2025 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2026/* Unselect Front Mic by default in input mixer 3 */
2027 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2028/* Enable unsolicited event for HP jack */
2029 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2030/* Enable speaker output */
2031 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2032 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2033 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
2034/* Enable headphone output */
2035 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2036 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2037 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2038 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2039/*Enable internal subwoofer */
2040 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2041 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2042 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
2043 {0x17, AC_VERB_SET_EAPD_BTLENABLE, 2},
2044 { }
2045};
2046
2047/*
Hector Martin018df412009-06-04 00:13:40 +02002048 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02002049 */
2050
Hector Martin018df412009-06-04 00:13:40 +02002051static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02002052/* Front Mic: set to PIN_IN (empty by default) */
2053 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2054/* Unselect Front Mic by default in input mixer 3 */
2055 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2056/* Enable unsolicited event for HP jack */
2057 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2058/* Connect Internal Front to Front */
2059 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2060 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2061 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2062/* Connect Internal Rear to Rear */
2063 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2064 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2065 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
2066/* Connect Internal CLFE to CLFE */
2067 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2068 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2069 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2070/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02002071 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02002072 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2073 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2074/* Enable all DACs */
2075/* DAC DISABLE/MUTE 1? */
2076/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2077 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2078 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2079/* DAC DISABLE/MUTE 2? */
2080/* some bit here disables the other DACs. Init=0x4900 */
2081 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2082 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002083/* DMIC fix
2084 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2085 * which makes the stereo useless. However, either the mic or the ALC889
2086 * makes the signal become a difference/sum signal instead of standard
2087 * stereo, which is annoying. So instead we flip this bit which makes the
2088 * codec replicate the sum signal to both channels, turning it into a
2089 * normal mono mic.
2090 */
2091/* DMIC_CONTROL? Init value = 0x0001 */
2092 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2093 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002094 { }
2095};
2096
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002097static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002098 /* Front mic only available on one ADC */
2099 {
2100 .num_items = 4,
2101 .items = {
2102 { "Mic", 0x0 },
2103 { "Line", 0x2 },
2104 { "CD", 0x4 },
2105 { "Front Mic", 0xb },
2106 },
2107 },
2108 {
2109 .num_items = 3,
2110 .items = {
2111 { "Mic", 0x0 },
2112 { "Line", 0x2 },
2113 { "CD", 0x4 },
2114 },
2115 }
2116};
2117
Tony Vroond2fd4b02009-06-21 00:40:10 +01002118static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2119 /* Interal mic only available on one ADC */
2120 {
Tony Vroon684a8842009-06-26 09:27:50 +01002121 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002122 .items = {
2123 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002124 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002125 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002126 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002127 { "Int Mic", 0xb },
2128 },
2129 },
2130 {
Tony Vroon684a8842009-06-26 09:27:50 +01002131 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002132 .items = {
2133 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002134 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002135 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002136 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002137 },
2138 }
2139};
2140
Hector Martin018df412009-06-04 00:13:40 +02002141static struct hda_input_mux alc889_capture_sources[3] = {
2142 /* Digital mic only available on first "ADC" */
2143 {
2144 .num_items = 5,
2145 .items = {
2146 { "Mic", 0x0 },
2147 { "Line", 0x2 },
2148 { "CD", 0x4 },
2149 { "Front Mic", 0xb },
2150 { "Input Mix", 0xa },
2151 },
2152 },
2153 {
2154 .num_items = 4,
2155 .items = {
2156 { "Mic", 0x0 },
2157 { "Line", 0x2 },
2158 { "CD", 0x4 },
2159 { "Input Mix", 0xa },
2160 },
2161 },
2162 {
2163 .num_items = 4,
2164 .items = {
2165 { "Mic", 0x0 },
2166 { "Line", 0x2 },
2167 { "CD", 0x4 },
2168 { "Input Mix", 0xa },
2169 },
2170 }
2171};
2172
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002173static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002174 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2175 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2176 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2177 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2178 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2179 HDA_OUTPUT),
2180 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2181 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2182 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2183 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2184 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2185 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2186 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2187 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2188 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2189 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2190 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2191 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002192 { } /* end */
2193};
2194
Hector Martin556eea92009-12-20 22:51:23 +01002195static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2196 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2197 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2198 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2199 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2200 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2201 HDA_OUTPUT),
2202 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2203 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2204 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2205 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2206 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2207 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2208 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2209 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2210 { } /* end */
2211};
2212
2213
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002214static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002215{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002216 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002217
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002218 spec->autocfg.hp_pins[0] = 0x15;
2219 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002220 spec->autocfg.speaker_pins[1] = 0x16;
2221 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002222}
2223
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002224static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002225{
2226 struct alc_spec *spec = codec->spec;
2227
2228 spec->autocfg.hp_pins[0] = 0x15;
2229 spec->autocfg.speaker_pins[0] = 0x14;
2230 spec->autocfg.speaker_pins[1] = 0x16;
2231 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002232}
2233
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002234static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
2235{
2236 struct alc_spec *spec = codec->spec;
2237
2238 spec->autocfg.hp_pins[0] = 0x15;
2239 spec->autocfg.speaker_pins[0] = 0x14;
2240 spec->autocfg.speaker_pins[1] = 0x16;
2241 spec->autocfg.speaker_pins[2] = 0x17;
2242}
2243
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002244static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002245{
2246 struct alc_spec *spec = codec->spec;
2247
2248 spec->autocfg.hp_pins[0] = 0x15;
2249 spec->autocfg.speaker_pins[0] = 0x14;
2250 spec->autocfg.speaker_pins[1] = 0x16;
2251 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002252}
2253
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002254/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002255 * ALC880 3-stack model
2256 *
2257 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002258 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2259 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002260 */
2261
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002262static hda_nid_t alc880_dac_nids[4] = {
2263 /* front, rear, clfe, rear_surr */
2264 0x02, 0x05, 0x04, 0x03
2265};
2266
2267static hda_nid_t alc880_adc_nids[3] = {
2268 /* ADC0-2 */
2269 0x07, 0x08, 0x09,
2270};
2271
2272/* The datasheet says the node 0x07 is connected from inputs,
2273 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002274 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002275 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002276static hda_nid_t alc880_adc_nids_alt[2] = {
2277 /* ADC1-2 */
2278 0x08, 0x09,
2279};
2280
2281#define ALC880_DIGOUT_NID 0x06
2282#define ALC880_DIGIN_NID 0x0a
2283
2284static struct hda_input_mux alc880_capture_source = {
2285 .num_items = 4,
2286 .items = {
2287 { "Mic", 0x0 },
2288 { "Front Mic", 0x3 },
2289 { "Line", 0x2 },
2290 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002291 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002292};
2293
2294/* channel source setting (2/6 channel selection for 3-stack) */
2295/* 2ch mode */
2296static struct hda_verb alc880_threestack_ch2_init[] = {
2297 /* set line-in to input, mute it */
2298 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2299 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2300 /* set mic-in to input vref 80%, mute it */
2301 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2302 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002303 { } /* end */
2304};
2305
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002306/* 6ch mode */
2307static struct hda_verb alc880_threestack_ch6_init[] = {
2308 /* set line-in to output, unmute it */
2309 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2310 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2311 /* set mic-in to output, unmute it */
2312 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2313 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2314 { } /* end */
2315};
2316
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002317static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002318 { 2, alc880_threestack_ch2_init },
2319 { 6, alc880_threestack_ch6_init },
2320};
2321
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002322static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002323 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002324 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002325 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002326 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002327 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2328 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002329 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2330 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002331 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2332 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2333 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2334 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2336 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2337 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2338 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002339 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002340 {
2341 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2342 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002343 .info = alc_ch_mode_info,
2344 .get = alc_ch_mode_get,
2345 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002346 },
2347 { } /* end */
2348};
2349
2350/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002351static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2352 struct snd_ctl_elem_info *uinfo)
2353{
2354 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2355 struct alc_spec *spec = codec->spec;
2356 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002357
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002358 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002359 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2360 HDA_INPUT);
2361 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002362 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002363 return err;
2364}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002365
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002366static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2367 unsigned int size, unsigned int __user *tlv)
2368{
2369 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2370 struct alc_spec *spec = codec->spec;
2371 int err;
2372
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002373 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002374 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2375 HDA_INPUT);
2376 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002377 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002378 return err;
2379}
2380
2381typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2382 struct snd_ctl_elem_value *ucontrol);
2383
2384static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2385 struct snd_ctl_elem_value *ucontrol,
2386 getput_call_t func)
2387{
2388 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2389 struct alc_spec *spec = codec->spec;
2390 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2391 int err;
2392
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002393 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002394 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2395 3, 0, HDA_INPUT);
2396 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002397 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002398 return err;
2399}
2400
2401static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2402 struct snd_ctl_elem_value *ucontrol)
2403{
2404 return alc_cap_getput_caller(kcontrol, ucontrol,
2405 snd_hda_mixer_amp_volume_get);
2406}
2407
2408static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2409 struct snd_ctl_elem_value *ucontrol)
2410{
2411 return alc_cap_getput_caller(kcontrol, ucontrol,
2412 snd_hda_mixer_amp_volume_put);
2413}
2414
2415/* capture mixer elements */
2416#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2417
2418static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2419 struct snd_ctl_elem_value *ucontrol)
2420{
2421 return alc_cap_getput_caller(kcontrol, ucontrol,
2422 snd_hda_mixer_amp_switch_get);
2423}
2424
2425static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2426 struct snd_ctl_elem_value *ucontrol)
2427{
2428 return alc_cap_getput_caller(kcontrol, ucontrol,
2429 snd_hda_mixer_amp_switch_put);
2430}
2431
Takashi Iwaia23b6882009-03-23 15:21:36 +01002432#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002433 { \
2434 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2435 .name = "Capture Switch", \
2436 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2437 .count = num, \
2438 .info = alc_cap_sw_info, \
2439 .get = alc_cap_sw_get, \
2440 .put = alc_cap_sw_put, \
2441 }, \
2442 { \
2443 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2444 .name = "Capture Volume", \
2445 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2446 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2447 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2448 .count = num, \
2449 .info = alc_cap_vol_info, \
2450 .get = alc_cap_vol_get, \
2451 .put = alc_cap_vol_put, \
2452 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002453 }
2454
2455#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002456 { \
2457 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2458 /* .name = "Capture Source", */ \
2459 .name = "Input Source", \
2460 .count = num, \
2461 .info = alc_mux_enum_info, \
2462 .get = alc_mux_enum_get, \
2463 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002464 }
2465
2466#define DEFINE_CAPMIX(num) \
2467static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2468 _DEFINE_CAPMIX(num), \
2469 _DEFINE_CAPSRC(num), \
2470 { } /* end */ \
2471}
2472
2473#define DEFINE_CAPMIX_NOSRC(num) \
2474static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2475 _DEFINE_CAPMIX(num), \
2476 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002477}
2478
2479/* up to three ADCs */
2480DEFINE_CAPMIX(1);
2481DEFINE_CAPMIX(2);
2482DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002483DEFINE_CAPMIX_NOSRC(1);
2484DEFINE_CAPMIX_NOSRC(2);
2485DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002486
2487/*
2488 * ALC880 5-stack model
2489 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002490 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2491 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002492 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2493 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2494 */
2495
2496/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002497static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002498 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002499 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002500 { } /* end */
2501};
2502
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002503/* channel source setting (6/8 channel selection for 5-stack) */
2504/* 6ch mode */
2505static struct hda_verb alc880_fivestack_ch6_init[] = {
2506 /* set line-in to input, mute it */
2507 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2508 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002509 { } /* end */
2510};
2511
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002512/* 8ch mode */
2513static struct hda_verb alc880_fivestack_ch8_init[] = {
2514 /* set line-in to output, unmute it */
2515 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2516 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2517 { } /* end */
2518};
2519
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002520static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002521 { 6, alc880_fivestack_ch6_init },
2522 { 8, alc880_fivestack_ch8_init },
2523};
2524
2525
2526/*
2527 * ALC880 6-stack model
2528 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002529 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2530 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002531 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2532 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2533 */
2534
2535static hda_nid_t alc880_6st_dac_nids[4] = {
2536 /* front, rear, clfe, rear_surr */
2537 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002538};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002539
2540static struct hda_input_mux alc880_6stack_capture_source = {
2541 .num_items = 4,
2542 .items = {
2543 { "Mic", 0x0 },
2544 { "Front Mic", 0x1 },
2545 { "Line", 0x2 },
2546 { "CD", 0x4 },
2547 },
2548};
2549
2550/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002551static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002552 { 8, NULL },
2553};
2554
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002555static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002556 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002557 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002558 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002559 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002560 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2561 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002562 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2563 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002564 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002565 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002566 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2567 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2568 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2569 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2570 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2571 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2572 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2573 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002574 {
2575 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2576 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002577 .info = alc_ch_mode_info,
2578 .get = alc_ch_mode_get,
2579 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002580 },
2581 { } /* end */
2582};
2583
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002584
2585/*
2586 * ALC880 W810 model
2587 *
2588 * W810 has rear IO for:
2589 * Front (DAC 02)
2590 * Surround (DAC 03)
2591 * Center/LFE (DAC 04)
2592 * Digital out (06)
2593 *
2594 * The system also has a pair of internal speakers, and a headphone jack.
2595 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002596 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002597 * There is a variable resistor to control the speaker or headphone
2598 * volume. This is a hardware-only device without a software API.
2599 *
2600 * Plugging headphones in will disable the internal speakers. This is
2601 * implemented in hardware, not via the driver using jack sense. In
2602 * a similar fashion, plugging into the rear socket marked "front" will
2603 * disable both the speakers and headphones.
2604 *
2605 * For input, there's a microphone jack, and an "audio in" jack.
2606 * These may not do anything useful with this driver yet, because I
2607 * haven't setup any initialization verbs for these yet...
2608 */
2609
2610static hda_nid_t alc880_w810_dac_nids[3] = {
2611 /* front, rear/surround, clfe */
2612 0x02, 0x03, 0x04
2613};
2614
2615/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002616static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002617 { 6, NULL }
2618};
2619
2620/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002621static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002622 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002623 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002624 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002625 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002626 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2627 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002628 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2629 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002630 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2631 { } /* end */
2632};
2633
2634
2635/*
2636 * Z710V model
2637 *
2638 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002639 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2640 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002641 */
2642
2643static hda_nid_t alc880_z71v_dac_nids[1] = {
2644 0x02
2645};
2646#define ALC880_Z71V_HP_DAC 0x03
2647
2648/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002649static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002650 { 2, NULL }
2651};
2652
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002653static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002654 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002655 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002656 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002657 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002658 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2659 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2660 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2661 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2662 { } /* end */
2663};
2664
2665
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002666/*
2667 * ALC880 F1734 model
2668 *
2669 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2670 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2671 */
2672
2673static hda_nid_t alc880_f1734_dac_nids[1] = {
2674 0x03
2675};
2676#define ALC880_F1734_HP_DAC 0x02
2677
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002678static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002679 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002680 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002681 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2682 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002683 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2684 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002685 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2686 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002687 { } /* end */
2688};
2689
Takashi Iwai937b4162008-02-11 14:52:36 +01002690static struct hda_input_mux alc880_f1734_capture_source = {
2691 .num_items = 2,
2692 .items = {
2693 { "Mic", 0x1 },
2694 { "CD", 0x4 },
2695 },
2696};
2697
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002698
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002699/*
2700 * ALC880 ASUS model
2701 *
2702 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2703 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2704 * Mic = 0x18, Line = 0x1a
2705 */
2706
2707#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2708#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2709
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002710static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002711 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002712 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002713 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002714 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002715 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2716 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002717 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2718 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002719 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2720 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2721 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2722 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2723 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2724 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002725 {
2726 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2727 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002728 .info = alc_ch_mode_info,
2729 .get = alc_ch_mode_get,
2730 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002731 },
2732 { } /* end */
2733};
2734
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002735/*
2736 * ALC880 ASUS W1V model
2737 *
2738 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2739 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2740 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2741 */
2742
2743/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002744static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002745 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2746 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002747 { } /* end */
2748};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002749
Kailang Yangdf694da2005-12-05 19:42:22 +01002750/* TCL S700 */
2751static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2752 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2753 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2754 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2755 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2756 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2757 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2758 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2759 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2760 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002761 { } /* end */
2762};
2763
Kailang Yangccc656c2006-10-17 12:32:26 +02002764/* Uniwill */
2765static struct snd_kcontrol_new alc880_uniwill_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_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2771 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2772 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2773 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2774 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2775 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2776 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2777 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2778 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2779 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2780 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2781 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002782 {
2783 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2784 .name = "Channel Mode",
2785 .info = alc_ch_mode_info,
2786 .get = alc_ch_mode_get,
2787 .put = alc_ch_mode_put,
2788 },
2789 { } /* end */
2790};
2791
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002792static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2793 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2794 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2795 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2796 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2797 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2798 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2799 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2800 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2801 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2802 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2803 { } /* end */
2804};
2805
Kailang Yangccc656c2006-10-17 12:32:26 +02002806static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002807 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2808 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2809 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2810 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2812 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2813 { } /* end */
2814};
2815
Linus Torvalds1da177e2005-04-16 15:20:36 -07002816/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002817 * virtual master controls
2818 */
2819
2820/*
2821 * slave controls for virtual master
2822 */
2823static const char *alc_slave_vols[] = {
2824 "Front Playback Volume",
2825 "Surround Playback Volume",
2826 "Center Playback Volume",
2827 "LFE Playback Volume",
2828 "Side Playback Volume",
2829 "Headphone Playback Volume",
2830 "Speaker Playback Volume",
2831 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002832 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002833 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002834 NULL,
2835};
2836
2837static const char *alc_slave_sws[] = {
2838 "Front Playback Switch",
2839 "Surround Playback Switch",
2840 "Center Playback Switch",
2841 "LFE Playback Switch",
2842 "Side Playback Switch",
2843 "Headphone Playback Switch",
2844 "Speaker Playback Switch",
2845 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002846 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002847 "Line-Out Playback Switch",
2848 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002849 NULL,
2850};
2851
2852/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002853 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002854 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002855
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002856#define NID_MAPPING (-1)
2857
2858#define SUBDEV_SPEAKER_ (0 << 6)
2859#define SUBDEV_HP_ (1 << 6)
2860#define SUBDEV_LINE_ (2 << 6)
2861#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2862#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2863#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2864
Takashi Iwai603c4012008-07-30 15:01:44 +02002865static void alc_free_kctls(struct hda_codec *codec);
2866
Takashi Iwai67d634c2009-11-16 15:35:59 +01002867#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002868/* additional beep mixers; the actual parameters are overwritten at build */
2869static struct snd_kcontrol_new alc_beep_mixer[] = {
2870 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002871 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002872 { } /* end */
2873};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002874#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002875
Linus Torvalds1da177e2005-04-16 15:20:36 -07002876static int alc_build_controls(struct hda_codec *codec)
2877{
2878 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002879 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002880 struct snd_kcontrol_new *knew;
2881 int i, j, err;
2882 unsigned int u;
2883 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002884
2885 for (i = 0; i < spec->num_mixers; i++) {
2886 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2887 if (err < 0)
2888 return err;
2889 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002890 if (spec->cap_mixer) {
2891 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2892 if (err < 0)
2893 return err;
2894 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002895 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002896 err = snd_hda_create_spdif_out_ctls(codec,
2897 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002898 if (err < 0)
2899 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002900 if (!spec->no_analog) {
2901 err = snd_hda_create_spdif_share_sw(codec,
2902 &spec->multiout);
2903 if (err < 0)
2904 return err;
2905 spec->multiout.share_spdif = 1;
2906 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002907 }
2908 if (spec->dig_in_nid) {
2909 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2910 if (err < 0)
2911 return err;
2912 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002913
Takashi Iwai67d634c2009-11-16 15:35:59 +01002914#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002915 /* create beep controls if needed */
2916 if (spec->beep_amp) {
2917 struct snd_kcontrol_new *knew;
2918 for (knew = alc_beep_mixer; knew->name; knew++) {
2919 struct snd_kcontrol *kctl;
2920 kctl = snd_ctl_new1(knew, codec);
2921 if (!kctl)
2922 return -ENOMEM;
2923 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002924 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002925 if (err < 0)
2926 return err;
2927 }
2928 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002929#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002930
Takashi Iwai2134ea42008-01-10 16:53:55 +01002931 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002932 if (!spec->no_analog &&
2933 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002934 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002935 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002936 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002937 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002938 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002939 if (err < 0)
2940 return err;
2941 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002942 if (!spec->no_analog &&
2943 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002944 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2945 NULL, alc_slave_sws);
2946 if (err < 0)
2947 return err;
2948 }
2949
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002950 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002951 if (spec->capsrc_nids || spec->adc_nids) {
2952 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2953 if (!kctl)
2954 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2955 for (i = 0; kctl && i < kctl->count; i++) {
2956 hda_nid_t *nids = spec->capsrc_nids;
2957 if (!nids)
2958 nids = spec->adc_nids;
2959 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
2960 if (err < 0)
2961 return err;
2962 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002963 }
2964 if (spec->cap_mixer) {
2965 const char *kname = kctl ? kctl->id.name : NULL;
2966 for (knew = spec->cap_mixer; knew->name; knew++) {
2967 if (kname && strcmp(knew->name, kname) == 0)
2968 continue;
2969 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2970 for (i = 0; kctl && i < kctl->count; i++) {
2971 err = snd_hda_add_nid(codec, kctl, i,
2972 spec->adc_nids[i]);
2973 if (err < 0)
2974 return err;
2975 }
2976 }
2977 }
2978
2979 /* other nid->control mapping */
2980 for (i = 0; i < spec->num_mixers; i++) {
2981 for (knew = spec->mixers[i]; knew->name; knew++) {
2982 if (knew->iface != NID_MAPPING)
2983 continue;
2984 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2985 if (kctl == NULL)
2986 continue;
2987 u = knew->subdevice;
2988 for (j = 0; j < 4; j++, u >>= 8) {
2989 nid = u & 0x3f;
2990 if (nid == 0)
2991 continue;
2992 switch (u & 0xc0) {
2993 case SUBDEV_SPEAKER_:
2994 nid = spec->autocfg.speaker_pins[nid];
2995 break;
2996 case SUBDEV_LINE_:
2997 nid = spec->autocfg.line_out_pins[nid];
2998 break;
2999 case SUBDEV_HP_:
3000 nid = spec->autocfg.hp_pins[nid];
3001 break;
3002 default:
3003 continue;
3004 }
3005 err = snd_hda_add_nid(codec, kctl, 0, nid);
3006 if (err < 0)
3007 return err;
3008 }
3009 u = knew->private_value;
3010 for (j = 0; j < 4; j++, u >>= 8) {
3011 nid = u & 0xff;
3012 if (nid == 0)
3013 continue;
3014 err = snd_hda_add_nid(codec, kctl, 0, nid);
3015 if (err < 0)
3016 return err;
3017 }
3018 }
3019 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01003020
3021 alc_free_kctls(codec); /* no longer needed */
3022
Linus Torvalds1da177e2005-04-16 15:20:36 -07003023 return 0;
3024}
3025
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003026
Linus Torvalds1da177e2005-04-16 15:20:36 -07003027/*
3028 * initialize the codec volumes, etc
3029 */
3030
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003031/*
3032 * generic initialization of ADC, input mixers and output mixers
3033 */
3034static struct hda_verb alc880_volume_init_verbs[] = {
3035 /*
3036 * Unmute ADC0-2 and set the default input to mic-in
3037 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003038 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003039 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003040 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003041 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003042 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003043 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003044
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003045 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3046 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003047 * Note: PASD motherboards uses the Line In 2 as the input for front
3048 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003049 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003050 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003051 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3052 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3053 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3054 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3055 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3056 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3057 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003058
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003059 /*
3060 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003061 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003062 /* set vol=0 to output mixers */
3063 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3064 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3065 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3066 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3067 /* set up input amps for analog loopback */
3068 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003069 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3070 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003071 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3072 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003073 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3074 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003075 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3076 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003077
3078 { }
3079};
3080
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003081/*
3082 * 3-stack pin configuration:
3083 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3084 */
3085static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3086 /*
3087 * preset connection lists of input pins
3088 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3089 */
3090 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3091 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3092 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3093
3094 /*
3095 * Set pin mode and muting
3096 */
3097 /* set front pin widgets 0x14 for output */
3098 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3099 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3100 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3101 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3102 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3103 /* Mic2 (as headphone out) for HP output */
3104 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3105 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3106 /* Line In pin widget for input */
3107 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3108 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3109 /* Line2 (as front mic) pin widget for input and vref at 80% */
3110 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3111 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3112 /* CD pin widget for input */
3113 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3114
3115 { }
3116};
3117
3118/*
3119 * 5-stack pin configuration:
3120 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3121 * line-in/side = 0x1a, f-mic = 0x1b
3122 */
3123static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3124 /*
3125 * preset connection lists of input pins
3126 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3127 */
3128 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3129 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3130
3131 /*
3132 * Set pin mode and muting
3133 */
3134 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003135 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3136 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3137 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3138 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003139 /* unmute pins for output (no gain on this amp) */
3140 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3141 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3142 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3143 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3144
Linus Torvalds1da177e2005-04-16 15:20:36 -07003145 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003146 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003147 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3148 /* Mic2 (as headphone out) for HP output */
3149 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003150 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003151 /* Line In pin widget for input */
3152 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3153 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3154 /* Line2 (as front mic) pin widget for input and vref at 80% */
3155 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3156 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3157 /* CD pin widget for input */
3158 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003159
3160 { }
3161};
3162
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003163/*
3164 * W810 pin configuration:
3165 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3166 */
3167static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003168 /* hphone/speaker input selector: front DAC */
3169 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3170
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003171 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3172 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3173 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3174 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3175 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3176 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3177
3178 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003179 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003180
Linus Torvalds1da177e2005-04-16 15:20:36 -07003181 { }
3182};
3183
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003184/*
3185 * Z71V pin configuration:
3186 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3187 */
3188static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003189 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003190 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003191 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003193
Takashi Iwai16ded522005-06-10 19:58:24 +02003194 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003195 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003196 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003197 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003198
3199 { }
3200};
3201
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003202/*
3203 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003204 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3205 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003206 */
3207static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3208 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3209
Takashi Iwai16ded522005-06-10 19:58:24 +02003210 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003211 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003212 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003213 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003214 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003215 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003216 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003217 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3218
Takashi Iwai16ded522005-06-10 19:58:24 +02003219 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003220 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003221 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003222 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003223 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003224 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003225 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003226 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003227 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003228
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003229 { }
3230};
Takashi Iwai16ded522005-06-10 19:58:24 +02003231
Kailang Yangccc656c2006-10-17 12:32:26 +02003232/*
3233 * Uniwill pin configuration:
3234 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3235 * line = 0x1a
3236 */
3237static struct hda_verb alc880_uniwill_init_verbs[] = {
3238 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3239
3240 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3241 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3242 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3243 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3244 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3245 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3246 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3247 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3248 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3249 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3250 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3251 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3252 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3253 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3254
3255 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3256 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3257 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3258 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3259 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3260 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3261 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3262 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3263 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3264
3265 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3266 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3267
3268 { }
3269};
3270
3271/*
3272* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003273* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003274 */
3275static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3276 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3277
3278 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3279 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3280 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3281 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3282 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3283 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3284 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3285 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3286 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3287 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3288 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3289 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3290
3291 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3292 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3293 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3294 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3295 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3296 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3297
3298 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3299 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3300
3301 { }
3302};
3303
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003304static struct hda_verb alc880_beep_init_verbs[] = {
3305 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3306 { }
3307};
3308
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003309/* auto-toggle front mic */
3310static void alc880_uniwill_mic_automute(struct hda_codec *codec)
3311{
3312 unsigned int present;
3313 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003314
Wu Fengguang864f92b2009-11-18 12:38:02 +08003315 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003316 bits = present ? HDA_AMP_MUTE : 0;
3317 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003318}
3319
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003320static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003321{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003322 struct alc_spec *spec = codec->spec;
3323
3324 spec->autocfg.hp_pins[0] = 0x14;
3325 spec->autocfg.speaker_pins[0] = 0x15;
3326 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003327}
3328
3329static void alc880_uniwill_init_hook(struct hda_codec *codec)
3330{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003331 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003332 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003333}
3334
3335static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3336 unsigned int res)
3337{
3338 /* Looks like the unsol event is incompatible with the standard
3339 * definition. 4bit tag is placed at 28 bit!
3340 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003341 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003342 case ALC880_MIC_EVENT:
3343 alc880_uniwill_mic_automute(codec);
3344 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003345 default:
3346 alc_automute_amp_unsol_event(codec, res);
3347 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003348 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003349}
3350
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003351static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003352{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003353 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003354
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003355 spec->autocfg.hp_pins[0] = 0x14;
3356 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003357}
3358
3359static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3360{
3361 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003362
Kailang Yangccc656c2006-10-17 12:32:26 +02003363 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003364 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3365 present &= HDA_AMP_VOLMASK;
3366 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3367 HDA_AMP_VOLMASK, present);
3368 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3369 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003370}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003371
Kailang Yangccc656c2006-10-17 12:32:26 +02003372static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3373 unsigned int res)
3374{
3375 /* Looks like the unsol event is incompatible with the standard
3376 * definition. 4bit tag is placed at 28 bit!
3377 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003378 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003379 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003380 else
3381 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003382}
3383
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003384/*
3385 * F1734 pin configuration:
3386 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3387 */
3388static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003389 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003390 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3391 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3392 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3393 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3394
3395 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3396 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3397 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3398 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3399
3400 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3401 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003402 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003403 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3404 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3405 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3406 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3407 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3408 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003409
Takashi Iwai937b4162008-02-11 14:52:36 +01003410 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3411 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3412
Takashi Iwai16ded522005-06-10 19:58:24 +02003413 { }
3414};
3415
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003416/*
3417 * ASUS pin configuration:
3418 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3419 */
3420static struct hda_verb alc880_pin_asus_init_verbs[] = {
3421 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3422 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3423 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3424 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3425
3426 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3427 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3428 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3429 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3430 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3431 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3432 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3433 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3434
3435 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3436 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3437 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3438 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3439 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3440 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3441 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3442 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3443 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003444
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003445 { }
3446};
3447
3448/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003449#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3450#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003451#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003452
Kailang Yangdf694da2005-12-05 19:42:22 +01003453/* Clevo m520g init */
3454static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3455 /* headphone output */
3456 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3457 /* line-out */
3458 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3459 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3460 /* Line-in */
3461 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3462 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3463 /* CD */
3464 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3465 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3466 /* Mic1 (rear panel) */
3467 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3468 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3469 /* Mic2 (front panel) */
3470 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3471 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3472 /* headphone */
3473 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3474 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3475 /* change to EAPD mode */
3476 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3477 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3478
3479 { }
3480};
3481
3482static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003483 /* change to EAPD mode */
3484 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3485 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3486
Kailang Yangdf694da2005-12-05 19:42:22 +01003487 /* Headphone output */
3488 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3489 /* Front output*/
3490 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3491 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3492
3493 /* Line In pin widget for input */
3494 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3495 /* CD pin widget for input */
3496 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3497 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3498 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3499
3500 /* change to EAPD mode */
3501 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3502 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3503
3504 { }
3505};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003506
3507/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003508 * LG m1 express dual
3509 *
3510 * Pin assignment:
3511 * Rear Line-In/Out (blue): 0x14
3512 * Build-in Mic-In: 0x15
3513 * Speaker-out: 0x17
3514 * HP-Out (green): 0x1b
3515 * Mic-In/Out (red): 0x19
3516 * SPDIF-Out: 0x1e
3517 */
3518
3519/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3520static hda_nid_t alc880_lg_dac_nids[3] = {
3521 0x05, 0x02, 0x03
3522};
3523
3524/* seems analog CD is not working */
3525static struct hda_input_mux alc880_lg_capture_source = {
3526 .num_items = 3,
3527 .items = {
3528 { "Mic", 0x1 },
3529 { "Line", 0x5 },
3530 { "Internal Mic", 0x6 },
3531 },
3532};
3533
3534/* 2,4,6 channel modes */
3535static struct hda_verb alc880_lg_ch2_init[] = {
3536 /* set line-in and mic-in to input */
3537 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3538 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3539 { }
3540};
3541
3542static struct hda_verb alc880_lg_ch4_init[] = {
3543 /* set line-in to out and mic-in to input */
3544 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3545 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3546 { }
3547};
3548
3549static struct hda_verb alc880_lg_ch6_init[] = {
3550 /* set line-in and mic-in to output */
3551 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3552 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3553 { }
3554};
3555
3556static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3557 { 2, alc880_lg_ch2_init },
3558 { 4, alc880_lg_ch4_init },
3559 { 6, alc880_lg_ch6_init },
3560};
3561
3562static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003563 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3564 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003565 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3566 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3567 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3568 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3569 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3570 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3571 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3572 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3573 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3574 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3575 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3576 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3577 {
3578 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3579 .name = "Channel Mode",
3580 .info = alc_ch_mode_info,
3581 .get = alc_ch_mode_get,
3582 .put = alc_ch_mode_put,
3583 },
3584 { } /* end */
3585};
3586
3587static struct hda_verb alc880_lg_init_verbs[] = {
3588 /* set capture source to mic-in */
3589 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3590 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3591 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3592 /* mute all amp mixer inputs */
3593 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003594 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3595 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003596 /* line-in to input */
3597 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3598 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3599 /* built-in mic */
3600 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3601 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3602 /* speaker-out */
3603 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3604 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3605 /* mic-in to input */
3606 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3607 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3608 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3609 /* HP-out */
3610 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3611 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3612 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3613 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003614 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003615 { }
3616};
3617
3618/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003619static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003620{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003621 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003622
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003623 spec->autocfg.hp_pins[0] = 0x1b;
3624 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003625}
3626
3627/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003628 * LG LW20
3629 *
3630 * Pin assignment:
3631 * Speaker-out: 0x14
3632 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003633 * Built-in Mic-In: 0x19
3634 * Line-In: 0x1b
3635 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003636 * SPDIF-Out: 0x1e
3637 */
3638
Takashi Iwaid6815182006-03-23 16:06:23 +01003639static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003640 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003641 .items = {
3642 { "Mic", 0x0 },
3643 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003644 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003645 },
3646};
3647
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003648#define alc880_lg_lw_modes alc880_threestack_modes
3649
Takashi Iwaid6815182006-03-23 16:06:23 +01003650static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003651 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3652 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3653 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3654 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3655 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3656 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3657 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3658 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3659 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3660 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003661 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3662 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3663 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3664 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003665 {
3666 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3667 .name = "Channel Mode",
3668 .info = alc_ch_mode_info,
3669 .get = alc_ch_mode_get,
3670 .put = alc_ch_mode_put,
3671 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003672 { } /* end */
3673};
3674
3675static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003676 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3677 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3678 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3679
Takashi Iwaid6815182006-03-23 16:06:23 +01003680 /* set capture source to mic-in */
3681 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3682 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3683 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003684 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003685 /* speaker-out */
3686 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3687 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3688 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003689 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3690 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3691 /* mic-in to input */
3692 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3693 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3694 /* built-in mic */
3695 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3696 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3697 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003698 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003699 { }
3700};
3701
3702/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003703static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003704{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003705 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003706
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003707 spec->autocfg.hp_pins[0] = 0x1b;
3708 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003709}
3710
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003711static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3712 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3713 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3714 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3715 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3716 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3717 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3718 { } /* end */
3719};
3720
3721static struct hda_input_mux alc880_medion_rim_capture_source = {
3722 .num_items = 2,
3723 .items = {
3724 { "Mic", 0x0 },
3725 { "Internal Mic", 0x1 },
3726 },
3727};
3728
3729static struct hda_verb alc880_medion_rim_init_verbs[] = {
3730 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3731
3732 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3733 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3734
3735 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3736 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3737 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3738 /* Mic2 (as headphone out) for HP output */
3739 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3740 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3741 /* Internal Speaker */
3742 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3743 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3744
3745 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3746 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3747
3748 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3749 { }
3750};
3751
3752/* toggle speaker-output according to the hp-jack state */
3753static void alc880_medion_rim_automute(struct hda_codec *codec)
3754{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003755 struct alc_spec *spec = codec->spec;
3756 alc_automute_amp(codec);
3757 /* toggle EAPD */
3758 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003759 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3760 else
3761 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3762}
3763
3764static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3765 unsigned int res)
3766{
3767 /* Looks like the unsol event is incompatible with the standard
3768 * definition. 4bit tag is placed at 28 bit!
3769 */
3770 if ((res >> 28) == ALC880_HP_EVENT)
3771 alc880_medion_rim_automute(codec);
3772}
3773
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003774static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003775{
3776 struct alc_spec *spec = codec->spec;
3777
3778 spec->autocfg.hp_pins[0] = 0x14;
3779 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003780}
3781
Takashi Iwaicb53c622007-08-10 17:21:45 +02003782#ifdef CONFIG_SND_HDA_POWER_SAVE
3783static struct hda_amp_list alc880_loopbacks[] = {
3784 { 0x0b, HDA_INPUT, 0 },
3785 { 0x0b, HDA_INPUT, 1 },
3786 { 0x0b, HDA_INPUT, 2 },
3787 { 0x0b, HDA_INPUT, 3 },
3788 { 0x0b, HDA_INPUT, 4 },
3789 { } /* end */
3790};
3791
3792static struct hda_amp_list alc880_lg_loopbacks[] = {
3793 { 0x0b, HDA_INPUT, 1 },
3794 { 0x0b, HDA_INPUT, 6 },
3795 { 0x0b, HDA_INPUT, 7 },
3796 { } /* end */
3797};
3798#endif
3799
Takashi Iwaid6815182006-03-23 16:06:23 +01003800/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003801 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003802 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003803
Linus Torvalds1da177e2005-04-16 15:20:36 -07003804static int alc_init(struct hda_codec *codec)
3805{
3806 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003807 unsigned int i;
3808
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003809 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003810 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003811
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003812 for (i = 0; i < spec->num_init_verbs; i++)
3813 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003814
3815 if (spec->init_hook)
3816 spec->init_hook(codec);
3817
Takashi Iwai9e5341b2010-09-21 09:57:06 +02003818 hda_call_check_power_status(codec, 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003819 return 0;
3820}
3821
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003822static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3823{
3824 struct alc_spec *spec = codec->spec;
3825
3826 if (spec->unsol_event)
3827 spec->unsol_event(codec, res);
3828}
3829
Takashi Iwaicb53c622007-08-10 17:21:45 +02003830#ifdef CONFIG_SND_HDA_POWER_SAVE
3831static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3832{
3833 struct alc_spec *spec = codec->spec;
3834 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3835}
3836#endif
3837
Linus Torvalds1da177e2005-04-16 15:20:36 -07003838/*
3839 * Analog playback callbacks
3840 */
3841static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3842 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003843 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003844{
3845 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003846 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3847 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003848}
3849
3850static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3851 struct hda_codec *codec,
3852 unsigned int stream_tag,
3853 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003854 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003855{
3856 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003857 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3858 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003859}
3860
3861static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3862 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003863 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003864{
3865 struct alc_spec *spec = codec->spec;
3866 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3867}
3868
3869/*
3870 * Digital out
3871 */
3872static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3873 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003874 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003875{
3876 struct alc_spec *spec = codec->spec;
3877 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3878}
3879
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003880static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3881 struct hda_codec *codec,
3882 unsigned int stream_tag,
3883 unsigned int format,
3884 struct snd_pcm_substream *substream)
3885{
3886 struct alc_spec *spec = codec->spec;
3887 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3888 stream_tag, format, substream);
3889}
3890
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003891static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3892 struct hda_codec *codec,
3893 struct snd_pcm_substream *substream)
3894{
3895 struct alc_spec *spec = codec->spec;
3896 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3897}
3898
Linus Torvalds1da177e2005-04-16 15:20:36 -07003899static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3900 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003901 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003902{
3903 struct alc_spec *spec = codec->spec;
3904 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3905}
3906
3907/*
3908 * Analog capture
3909 */
Takashi Iwai63300792008-01-24 15:31:36 +01003910static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003911 struct hda_codec *codec,
3912 unsigned int stream_tag,
3913 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003914 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003915{
3916 struct alc_spec *spec = codec->spec;
3917
Takashi Iwai63300792008-01-24 15:31:36 +01003918 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003919 stream_tag, 0, format);
3920 return 0;
3921}
3922
Takashi Iwai63300792008-01-24 15:31:36 +01003923static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003924 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003925 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003926{
3927 struct alc_spec *spec = codec->spec;
3928
Takashi Iwai888afa12008-03-18 09:57:50 +01003929 snd_hda_codec_cleanup_stream(codec,
3930 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003931 return 0;
3932}
3933
Takashi Iwai840b64c2010-07-13 22:49:01 +02003934/* analog capture with dynamic dual-adc changes */
3935static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3936 struct hda_codec *codec,
3937 unsigned int stream_tag,
3938 unsigned int format,
3939 struct snd_pcm_substream *substream)
3940{
3941 struct alc_spec *spec = codec->spec;
3942 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3943 spec->cur_adc_stream_tag = stream_tag;
3944 spec->cur_adc_format = format;
3945 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3946 return 0;
3947}
3948
3949static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3950 struct hda_codec *codec,
3951 struct snd_pcm_substream *substream)
3952{
3953 struct alc_spec *spec = codec->spec;
3954 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
3955 spec->cur_adc = 0;
3956 return 0;
3957}
3958
3959static struct hda_pcm_stream dualmic_pcm_analog_capture = {
3960 .substreams = 1,
3961 .channels_min = 2,
3962 .channels_max = 2,
3963 .nid = 0, /* fill later */
3964 .ops = {
3965 .prepare = dualmic_capture_pcm_prepare,
3966 .cleanup = dualmic_capture_pcm_cleanup
3967 },
3968};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003969
3970/*
3971 */
3972static struct hda_pcm_stream alc880_pcm_analog_playback = {
3973 .substreams = 1,
3974 .channels_min = 2,
3975 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003976 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003977 .ops = {
3978 .open = alc880_playback_pcm_open,
3979 .prepare = alc880_playback_pcm_prepare,
3980 .cleanup = alc880_playback_pcm_cleanup
3981 },
3982};
3983
3984static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003985 .substreams = 1,
3986 .channels_min = 2,
3987 .channels_max = 2,
3988 /* NID is set in alc_build_pcms */
3989};
3990
3991static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3992 .substreams = 1,
3993 .channels_min = 2,
3994 .channels_max = 2,
3995 /* NID is set in alc_build_pcms */
3996};
3997
3998static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3999 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004000 .channels_min = 2,
4001 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004002 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004003 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01004004 .prepare = alc880_alt_capture_pcm_prepare,
4005 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004006 },
4007};
4008
4009static struct hda_pcm_stream alc880_pcm_digital_playback = {
4010 .substreams = 1,
4011 .channels_min = 2,
4012 .channels_max = 2,
4013 /* NID is set in alc_build_pcms */
4014 .ops = {
4015 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004016 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004017 .prepare = alc880_dig_playback_pcm_prepare,
4018 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004019 },
4020};
4021
4022static struct hda_pcm_stream alc880_pcm_digital_capture = {
4023 .substreams = 1,
4024 .channels_min = 2,
4025 .channels_max = 2,
4026 /* NID is set in alc_build_pcms */
4027};
4028
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004029/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01004030static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004031 .substreams = 0,
4032 .channels_min = 0,
4033 .channels_max = 0,
4034};
4035
Linus Torvalds1da177e2005-04-16 15:20:36 -07004036static int alc_build_pcms(struct hda_codec *codec)
4037{
4038 struct alc_spec *spec = codec->spec;
4039 struct hda_pcm *info = spec->pcm_rec;
4040 int i;
4041
4042 codec->num_pcms = 1;
4043 codec->pcm_info = info;
4044
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004045 if (spec->no_analog)
4046 goto skip_analog;
4047
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004048 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
4049 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004050 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01004051
Takashi Iwai4a471b72005-12-07 13:56:29 +01004052 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004053 if (snd_BUG_ON(!spec->multiout.dac_nids))
4054 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004055 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
4056 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
4057 }
4058 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004059 if (snd_BUG_ON(!spec->adc_nids))
4060 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004061 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
4062 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
4063 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004064
Takashi Iwai4a471b72005-12-07 13:56:29 +01004065 if (spec->channel_mode) {
4066 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
4067 for (i = 0; i < spec->num_channel_mode; i++) {
4068 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
4069 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
4070 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004071 }
4072 }
4073
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004074 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02004075 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004076 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004077 snprintf(spec->stream_name_digital,
4078 sizeof(spec->stream_name_digital),
4079 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02004080 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08004081 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004082 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004083 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004084 if (spec->dig_out_type)
4085 info->pcm_type = spec->dig_out_type;
4086 else
4087 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004088 if (spec->multiout.dig_out_nid &&
4089 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004090 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4091 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4092 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004093 if (spec->dig_in_nid &&
4094 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004095 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4096 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4097 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004098 /* FIXME: do we need this for all Realtek codec models? */
4099 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004100 }
4101
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004102 if (spec->no_analog)
4103 return 0;
4104
Takashi Iwaie08a0072006-09-07 17:52:14 +02004105 /* If the use of more than one ADC is requested for the current
4106 * model, configure a second analog capture-only PCM.
4107 */
4108 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004109 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4110 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004111 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004112 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004113 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004114 if (spec->alt_dac_nid) {
4115 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4116 *spec->stream_analog_alt_playback;
4117 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4118 spec->alt_dac_nid;
4119 } else {
4120 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4121 alc_pcm_null_stream;
4122 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4123 }
4124 if (spec->num_adc_nids > 1) {
4125 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4126 *spec->stream_analog_alt_capture;
4127 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4128 spec->adc_nids[1];
4129 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4130 spec->num_adc_nids - 1;
4131 } else {
4132 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4133 alc_pcm_null_stream;
4134 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004135 }
4136 }
4137
Linus Torvalds1da177e2005-04-16 15:20:36 -07004138 return 0;
4139}
4140
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004141static inline void alc_shutup(struct hda_codec *codec)
4142{
4143 snd_hda_shutup_pins(codec);
4144}
4145
Takashi Iwai603c4012008-07-30 15:01:44 +02004146static void alc_free_kctls(struct hda_codec *codec)
4147{
4148 struct alc_spec *spec = codec->spec;
4149
4150 if (spec->kctls.list) {
4151 struct snd_kcontrol_new *kctl = spec->kctls.list;
4152 int i;
4153 for (i = 0; i < spec->kctls.used; i++)
4154 kfree(kctl[i].name);
4155 }
4156 snd_array_free(&spec->kctls);
4157}
4158
Linus Torvalds1da177e2005-04-16 15:20:36 -07004159static void alc_free(struct hda_codec *codec)
4160{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004161 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004162
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004163 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004164 return;
4165
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004166 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004167 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004168 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004169 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004170}
4171
Hector Martinf5de24b2009-12-20 22:51:31 +01004172#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004173static void alc_power_eapd(struct hda_codec *codec)
4174{
4175 /* We currently only handle front, HP */
4176 switch (codec->vendor_id) {
4177 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004178 set_eapd(codec, 0x0f, 0);
4179 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004180 break;
4181 case 0x10ec0262:
4182 case 0x10ec0267:
4183 case 0x10ec0268:
4184 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004185 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05004186 case 0x10ec0272:
4187 case 0x10ec0660:
4188 case 0x10ec0662:
4189 case 0x10ec0663:
4190 case 0x10ec0862:
4191 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004192 set_eapd(codec, 0x14, 0);
4193 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004194 break;
4195 }
4196}
4197
Hector Martinf5de24b2009-12-20 22:51:31 +01004198static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4199{
4200 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004201 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004202 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004203 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004204 return 0;
4205}
4206#endif
4207
Takashi Iwaie044c392008-10-27 16:56:24 +01004208#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004209static int alc_resume(struct hda_codec *codec)
4210{
Takashi Iwaie044c392008-10-27 16:56:24 +01004211 codec->patch_ops.init(codec);
4212 snd_hda_codec_resume_amp(codec);
4213 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004214 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +01004215 return 0;
4216}
Takashi Iwaie044c392008-10-27 16:56:24 +01004217#endif
4218
Linus Torvalds1da177e2005-04-16 15:20:36 -07004219/*
4220 */
4221static struct hda_codec_ops alc_patch_ops = {
4222 .build_controls = alc_build_controls,
4223 .build_pcms = alc_build_pcms,
4224 .init = alc_init,
4225 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004226 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004227#ifdef SND_HDA_NEEDS_RESUME
4228 .resume = alc_resume,
4229#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004230#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004231 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004232 .check_power_status = alc_check_power_status,
4233#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004234 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004235};
4236
Kailang Yangc027ddc2010-03-19 11:33:06 +01004237/* replace the codec chip_name with the given string */
4238static int alc_codec_rename(struct hda_codec *codec, const char *name)
4239{
4240 kfree(codec->chip_name);
4241 codec->chip_name = kstrdup(name, GFP_KERNEL);
4242 if (!codec->chip_name) {
4243 alc_free(codec);
4244 return -ENOMEM;
4245 }
4246 return 0;
4247}
4248
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004249/*
4250 * Test configuration for debugging
4251 *
4252 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4253 * enum controls.
4254 */
4255#ifdef CONFIG_SND_DEBUG
4256static hda_nid_t alc880_test_dac_nids[4] = {
4257 0x02, 0x03, 0x04, 0x05
4258};
4259
4260static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004261 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004262 .items = {
4263 { "In-1", 0x0 },
4264 { "In-2", 0x1 },
4265 { "In-3", 0x2 },
4266 { "In-4", 0x3 },
4267 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004268 { "Front", 0x5 },
4269 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004270 },
4271};
4272
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004273static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004274 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004275 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004276 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004277 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004278};
4279
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004280static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4281 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004282{
4283 static char *texts[] = {
4284 "N/A", "Line Out", "HP Out",
4285 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4286 };
4287 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4288 uinfo->count = 1;
4289 uinfo->value.enumerated.items = 8;
4290 if (uinfo->value.enumerated.item >= 8)
4291 uinfo->value.enumerated.item = 7;
4292 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4293 return 0;
4294}
4295
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004296static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4297 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004298{
4299 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4300 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4301 unsigned int pin_ctl, item = 0;
4302
4303 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4304 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4305 if (pin_ctl & AC_PINCTL_OUT_EN) {
4306 if (pin_ctl & AC_PINCTL_HP_EN)
4307 item = 2;
4308 else
4309 item = 1;
4310 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4311 switch (pin_ctl & AC_PINCTL_VREFEN) {
4312 case AC_PINCTL_VREF_HIZ: item = 3; break;
4313 case AC_PINCTL_VREF_50: item = 4; break;
4314 case AC_PINCTL_VREF_GRD: item = 5; break;
4315 case AC_PINCTL_VREF_80: item = 6; break;
4316 case AC_PINCTL_VREF_100: item = 7; break;
4317 }
4318 }
4319 ucontrol->value.enumerated.item[0] = item;
4320 return 0;
4321}
4322
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004323static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4324 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004325{
4326 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4327 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4328 static unsigned int ctls[] = {
4329 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4330 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4331 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4332 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4333 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4334 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4335 };
4336 unsigned int old_ctl, new_ctl;
4337
4338 old_ctl = snd_hda_codec_read(codec, nid, 0,
4339 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4340 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4341 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004342 int val;
4343 snd_hda_codec_write_cache(codec, nid, 0,
4344 AC_VERB_SET_PIN_WIDGET_CONTROL,
4345 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004346 val = ucontrol->value.enumerated.item[0] >= 3 ?
4347 HDA_AMP_MUTE : 0;
4348 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4349 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004350 return 1;
4351 }
4352 return 0;
4353}
4354
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004355static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4356 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004357{
4358 static char *texts[] = {
4359 "Front", "Surround", "CLFE", "Side"
4360 };
4361 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4362 uinfo->count = 1;
4363 uinfo->value.enumerated.items = 4;
4364 if (uinfo->value.enumerated.item >= 4)
4365 uinfo->value.enumerated.item = 3;
4366 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4367 return 0;
4368}
4369
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004370static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4371 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004372{
4373 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4374 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4375 unsigned int sel;
4376
4377 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4378 ucontrol->value.enumerated.item[0] = sel & 3;
4379 return 0;
4380}
4381
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004382static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4383 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004384{
4385 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4386 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4387 unsigned int sel;
4388
4389 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4390 if (ucontrol->value.enumerated.item[0] != sel) {
4391 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004392 snd_hda_codec_write_cache(codec, nid, 0,
4393 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004394 return 1;
4395 }
4396 return 0;
4397}
4398
4399#define PIN_CTL_TEST(xname,nid) { \
4400 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4401 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004402 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004403 .info = alc_test_pin_ctl_info, \
4404 .get = alc_test_pin_ctl_get, \
4405 .put = alc_test_pin_ctl_put, \
4406 .private_value = nid \
4407 }
4408
4409#define PIN_SRC_TEST(xname,nid) { \
4410 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4411 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004412 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004413 .info = alc_test_pin_src_info, \
4414 .get = alc_test_pin_src_get, \
4415 .put = alc_test_pin_src_put, \
4416 .private_value = nid \
4417 }
4418
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004419static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004420 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4421 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4422 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4423 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004424 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4425 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4426 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4427 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004428 PIN_CTL_TEST("Front Pin Mode", 0x14),
4429 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4430 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4431 PIN_CTL_TEST("Side Pin Mode", 0x17),
4432 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4433 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4434 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4435 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4436 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4437 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4438 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4439 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4440 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4441 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4442 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4443 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4444 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4445 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4446 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4447 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4448 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4449 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004450 {
4451 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4452 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004453 .info = alc_ch_mode_info,
4454 .get = alc_ch_mode_get,
4455 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004456 },
4457 { } /* end */
4458};
4459
4460static struct hda_verb alc880_test_init_verbs[] = {
4461 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4464 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4465 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4466 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4467 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4468 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4469 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004470 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004471 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4472 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4473 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4474 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004475 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004476 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4477 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4478 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4479 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004480 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004481 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4482 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4483 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4484 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004485 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004486 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4487 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004488 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4489 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4490 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004491 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004492 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4493 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4494 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4495 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004496 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004497 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004498 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004499 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004500 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004501 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004502 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004503 /* Analog input/passthru */
4504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4505 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4506 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4507 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4508 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004509 { }
4510};
4511#endif
4512
Linus Torvalds1da177e2005-04-16 15:20:36 -07004513/*
4514 */
4515
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004516static const char *alc880_models[ALC880_MODEL_LAST] = {
4517 [ALC880_3ST] = "3stack",
4518 [ALC880_TCL_S700] = "tcl",
4519 [ALC880_3ST_DIG] = "3stack-digout",
4520 [ALC880_CLEVO] = "clevo",
4521 [ALC880_5ST] = "5stack",
4522 [ALC880_5ST_DIG] = "5stack-digout",
4523 [ALC880_W810] = "w810",
4524 [ALC880_Z71V] = "z71v",
4525 [ALC880_6ST] = "6stack",
4526 [ALC880_6ST_DIG] = "6stack-digout",
4527 [ALC880_ASUS] = "asus",
4528 [ALC880_ASUS_W1V] = "asus-w1v",
4529 [ALC880_ASUS_DIG] = "asus-dig",
4530 [ALC880_ASUS_DIG2] = "asus-dig2",
4531 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004532 [ALC880_UNIWILL_P53] = "uniwill-p53",
4533 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004534 [ALC880_F1734] = "F1734",
4535 [ALC880_LG] = "lg",
4536 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004537 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004538#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004539 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004540#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004541 [ALC880_AUTO] = "auto",
4542};
4543
4544static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004545 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004546 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4547 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4548 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4549 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4550 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4551 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4552 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4553 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004554 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4555 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004556 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4557 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4558 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4559 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4560 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4561 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4562 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4563 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4564 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4565 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004566 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004567 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4568 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4569 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004570 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004571 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004572 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4573 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004574 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4575 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004576 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4577 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4578 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4579 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004580 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4581 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004582 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004583 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004584 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004585 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004586 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4587 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004588 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004589 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004590 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004591 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004592 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004593 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004594 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004595 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004596 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004597 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
Daniel T Chen77c4d5c2010-12-02 22:45:45 -05004598 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004599 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004600 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004601 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4602 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4603 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4604 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004605 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4606 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004607 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004608 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004609 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4610 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004611 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4612 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4613 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004614 /* default Intel */
4615 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004616 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4617 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004618 {}
4619};
4620
Takashi Iwai16ded522005-06-10 19:58:24 +02004621/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004622 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004623 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004624static struct alc_config_preset alc880_presets[] = {
4625 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004626 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004627 .init_verbs = { alc880_volume_init_verbs,
4628 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004629 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004630 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004631 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4632 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004633 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004634 .input_mux = &alc880_capture_source,
4635 },
4636 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004637 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004638 .init_verbs = { alc880_volume_init_verbs,
4639 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004640 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004641 .dac_nids = alc880_dac_nids,
4642 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004643 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4644 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004645 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004646 .input_mux = &alc880_capture_source,
4647 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004648 [ALC880_TCL_S700] = {
4649 .mixers = { alc880_tcl_s700_mixer },
4650 .init_verbs = { alc880_volume_init_verbs,
4651 alc880_pin_tcl_S700_init_verbs,
4652 alc880_gpio2_init_verbs },
4653 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4654 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004655 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4656 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004657 .hp_nid = 0x03,
4658 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4659 .channel_mode = alc880_2_jack_modes,
4660 .input_mux = &alc880_capture_source,
4661 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004662 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004663 .mixers = { alc880_three_stack_mixer,
4664 alc880_five_stack_mixer},
4665 .init_verbs = { alc880_volume_init_verbs,
4666 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004667 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4668 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004669 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4670 .channel_mode = alc880_fivestack_modes,
4671 .input_mux = &alc880_capture_source,
4672 },
4673 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004674 .mixers = { alc880_three_stack_mixer,
4675 alc880_five_stack_mixer },
4676 .init_verbs = { alc880_volume_init_verbs,
4677 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004678 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4679 .dac_nids = alc880_dac_nids,
4680 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004681 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4682 .channel_mode = alc880_fivestack_modes,
4683 .input_mux = &alc880_capture_source,
4684 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004685 [ALC880_6ST] = {
4686 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004687 .init_verbs = { alc880_volume_init_verbs,
4688 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004689 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4690 .dac_nids = alc880_6st_dac_nids,
4691 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4692 .channel_mode = alc880_sixstack_modes,
4693 .input_mux = &alc880_6stack_capture_source,
4694 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004695 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004696 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004697 .init_verbs = { alc880_volume_init_verbs,
4698 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004699 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4700 .dac_nids = alc880_6st_dac_nids,
4701 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004702 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4703 .channel_mode = alc880_sixstack_modes,
4704 .input_mux = &alc880_6stack_capture_source,
4705 },
4706 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004707 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004708 .init_verbs = { alc880_volume_init_verbs,
4709 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004710 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004711 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4712 .dac_nids = alc880_w810_dac_nids,
4713 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004714 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4715 .channel_mode = alc880_w810_modes,
4716 .input_mux = &alc880_capture_source,
4717 },
4718 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004719 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004720 .init_verbs = { alc880_volume_init_verbs,
4721 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004722 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4723 .dac_nids = alc880_z71v_dac_nids,
4724 .dig_out_nid = ALC880_DIGOUT_NID,
4725 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004726 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4727 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004728 .input_mux = &alc880_capture_source,
4729 },
4730 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004731 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004732 .init_verbs = { alc880_volume_init_verbs,
4733 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004734 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4735 .dac_nids = alc880_f1734_dac_nids,
4736 .hp_nid = 0x02,
4737 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4738 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004739 .input_mux = &alc880_f1734_capture_source,
4740 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004741 .setup = alc880_uniwill_p53_setup,
4742 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004743 },
4744 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004745 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004746 .init_verbs = { alc880_volume_init_verbs,
4747 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004748 alc880_gpio1_init_verbs },
4749 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4750 .dac_nids = alc880_asus_dac_nids,
4751 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4752 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004753 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004754 .input_mux = &alc880_capture_source,
4755 },
4756 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004757 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004758 .init_verbs = { alc880_volume_init_verbs,
4759 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004760 alc880_gpio1_init_verbs },
4761 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4762 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004763 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004764 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4765 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004766 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004767 .input_mux = &alc880_capture_source,
4768 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004769 [ALC880_ASUS_DIG2] = {
4770 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004771 .init_verbs = { alc880_volume_init_verbs,
4772 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004773 alc880_gpio2_init_verbs }, /* use GPIO2 */
4774 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4775 .dac_nids = alc880_asus_dac_nids,
4776 .dig_out_nid = ALC880_DIGOUT_NID,
4777 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4778 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004779 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004780 .input_mux = &alc880_capture_source,
4781 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004782 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004783 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004784 .init_verbs = { alc880_volume_init_verbs,
4785 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004786 alc880_gpio1_init_verbs },
4787 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4788 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004789 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004790 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4791 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004792 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004793 .input_mux = &alc880_capture_source,
4794 },
4795 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004796 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004797 .init_verbs = { alc880_volume_init_verbs,
4798 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004799 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4800 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004801 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004802 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4803 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004804 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004805 .input_mux = &alc880_capture_source,
4806 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004807 [ALC880_UNIWILL] = {
4808 .mixers = { alc880_uniwill_mixer },
4809 .init_verbs = { alc880_volume_init_verbs,
4810 alc880_uniwill_init_verbs },
4811 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4812 .dac_nids = alc880_asus_dac_nids,
4813 .dig_out_nid = ALC880_DIGOUT_NID,
4814 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4815 .channel_mode = alc880_threestack_modes,
4816 .need_dac_fix = 1,
4817 .input_mux = &alc880_capture_source,
4818 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004819 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004820 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004821 },
4822 [ALC880_UNIWILL_P53] = {
4823 .mixers = { alc880_uniwill_p53_mixer },
4824 .init_verbs = { alc880_volume_init_verbs,
4825 alc880_uniwill_p53_init_verbs },
4826 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4827 .dac_nids = alc880_asus_dac_nids,
4828 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004829 .channel_mode = alc880_threestack_modes,
4830 .input_mux = &alc880_capture_source,
4831 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004832 .setup = alc880_uniwill_p53_setup,
4833 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004834 },
4835 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004836 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004837 .init_verbs = { alc880_volume_init_verbs,
4838 alc880_uniwill_p53_init_verbs,
4839 alc880_beep_init_verbs },
4840 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4841 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004842 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004843 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4844 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004845 .input_mux = &alc880_capture_source,
4846 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004847 .setup = alc880_uniwill_p53_setup,
4848 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004849 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004850 [ALC880_CLEVO] = {
4851 .mixers = { alc880_three_stack_mixer },
4852 .init_verbs = { alc880_volume_init_verbs,
4853 alc880_pin_clevo_init_verbs },
4854 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4855 .dac_nids = alc880_dac_nids,
4856 .hp_nid = 0x03,
4857 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4858 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004859 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004860 .input_mux = &alc880_capture_source,
4861 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004862 [ALC880_LG] = {
4863 .mixers = { alc880_lg_mixer },
4864 .init_verbs = { alc880_volume_init_verbs,
4865 alc880_lg_init_verbs },
4866 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4867 .dac_nids = alc880_lg_dac_nids,
4868 .dig_out_nid = ALC880_DIGOUT_NID,
4869 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4870 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004871 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004872 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004873 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004874 .setup = alc880_lg_setup,
4875 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004876#ifdef CONFIG_SND_HDA_POWER_SAVE
4877 .loopbacks = alc880_lg_loopbacks,
4878#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004879 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004880 [ALC880_LG_LW] = {
4881 .mixers = { alc880_lg_lw_mixer },
4882 .init_verbs = { alc880_volume_init_verbs,
4883 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004884 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004885 .dac_nids = alc880_dac_nids,
4886 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004887 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4888 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004889 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004890 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004891 .setup = alc880_lg_lw_setup,
4892 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004893 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004894 [ALC880_MEDION_RIM] = {
4895 .mixers = { alc880_medion_rim_mixer },
4896 .init_verbs = { alc880_volume_init_verbs,
4897 alc880_medion_rim_init_verbs,
4898 alc_gpio2_init_verbs },
4899 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4900 .dac_nids = alc880_dac_nids,
4901 .dig_out_nid = ALC880_DIGOUT_NID,
4902 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4903 .channel_mode = alc880_2_jack_modes,
4904 .input_mux = &alc880_medion_rim_capture_source,
4905 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004906 .setup = alc880_medion_rim_setup,
4907 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004908 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004909#ifdef CONFIG_SND_DEBUG
4910 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004911 .mixers = { alc880_test_mixer },
4912 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004913 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4914 .dac_nids = alc880_test_dac_nids,
4915 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004916 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4917 .channel_mode = alc880_test_modes,
4918 .input_mux = &alc880_test_capture_source,
4919 },
4920#endif
4921};
4922
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004923/*
4924 * Automatic parse of I/O pins from the BIOS configuration
4925 */
4926
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004927enum {
4928 ALC_CTL_WIDGET_VOL,
4929 ALC_CTL_WIDGET_MUTE,
4930 ALC_CTL_BIND_MUTE,
4931};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004932static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004933 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4934 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004935 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004936};
4937
4938/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004939static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004940 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004941{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004942 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004943
Takashi Iwai603c4012008-07-30 15:01:44 +02004944 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4945 knew = snd_array_new(&spec->kctls);
4946 if (!knew)
4947 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004948 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004949 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004950 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004951 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004952 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004953 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004954 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004955 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004956 return 0;
4957}
4958
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004959static int add_control_with_pfx(struct alc_spec *spec, int type,
4960 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004961 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004962{
4963 char name[32];
4964 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004965 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004966}
4967
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004968#define add_pb_vol_ctrl(spec, type, pfx, val) \
4969 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
4970#define add_pb_sw_ctrl(spec, type, pfx, val) \
4971 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
4972#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
4973 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
4974#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
4975 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004976
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004977#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4978#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4979#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4980#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004981#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4982#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4983#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4984#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4985#define ALC880_PIN_CD_NID 0x1c
4986
4987/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004988static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4989 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004990{
4991 hda_nid_t nid;
4992 int assigned[4];
4993 int i, j;
4994
4995 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004996 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004997
4998 /* check the pins hardwired to audio widget */
4999 for (i = 0; i < cfg->line_outs; i++) {
5000 nid = cfg->line_out_pins[i];
5001 if (alc880_is_fixed_pin(nid)) {
5002 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01005003 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005004 assigned[idx] = 1;
5005 }
5006 }
5007 /* left pins can be connect to any audio widget */
5008 for (i = 0; i < cfg->line_outs; i++) {
5009 nid = cfg->line_out_pins[i];
5010 if (alc880_is_fixed_pin(nid))
5011 continue;
5012 /* search for an empty channel */
5013 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005014 if (!assigned[j]) {
5015 spec->multiout.dac_nids[i] =
5016 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005017 assigned[j] = 1;
5018 break;
5019 }
5020 }
5021 }
5022 spec->multiout.num_dacs = cfg->line_outs;
5023 return 0;
5024}
5025
5026/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01005027static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
5028 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005029{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005030 static const char *chname[4] = {
5031 "Front", "Surround", NULL /*CLFE*/, "Side"
5032 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005033 hda_nid_t nid;
5034 int i, err;
5035
5036 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005037 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005038 continue;
5039 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
5040 if (i == 2) {
5041 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005042 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5043 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005044 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
5045 HDA_OUTPUT));
5046 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005047 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005048 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5049 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005050 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
5051 HDA_OUTPUT));
5052 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005053 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005054 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5055 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005056 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
5057 HDA_INPUT));
5058 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005059 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005060 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5061 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005062 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
5063 HDA_INPUT));
5064 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005065 return err;
5066 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02005067 const char *pfx;
5068 if (cfg->line_outs == 1 &&
5069 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
5070 pfx = "Speaker";
5071 else
5072 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005073 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005074 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
5075 HDA_OUTPUT));
5076 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005077 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005078 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005079 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
5080 HDA_INPUT));
5081 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005082 return err;
5083 }
5084 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005085 return 0;
5086}
5087
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005088/* add playback controls for speaker and HP outputs */
5089static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5090 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005091{
5092 hda_nid_t nid;
5093 int err;
5094
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005095 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005096 return 0;
5097
5098 if (alc880_is_fixed_pin(pin)) {
5099 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005100 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005101 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005102 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005103 else
5104 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005105 /* control HP volume/switch on the output mixer amp */
5106 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005107 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005108 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5109 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005110 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005111 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005112 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5113 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005114 return err;
5115 } else if (alc880_is_multi_pin(pin)) {
5116 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005117 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005118 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005119 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5120 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005121 return err;
5122 }
5123 return 0;
5124}
5125
5126/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005127static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005128 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005129 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005130{
Kailang Yangdf694da2005-12-05 19:42:22 +01005131 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005132
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005133 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005134 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5135 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005136 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005137 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005138 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5139 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005140 return err;
5141 return 0;
5142}
5143
Takashi Iwai05f5f472009-08-25 13:10:18 +02005144static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005145{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005146 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5147 return (pincap & AC_PINCAP_IN) != 0;
5148}
5149
5150/* create playback/capture controls for input pins */
5151static int alc_auto_create_input_ctls(struct hda_codec *codec,
5152 const struct auto_pin_cfg *cfg,
5153 hda_nid_t mixer,
5154 hda_nid_t cap1, hda_nid_t cap2)
5155{
5156 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005157 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005158 int i, err, idx, type, type_idx = 0;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005159
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005160 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005161 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005162 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005163
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005164 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005165 if (!alc_is_input_pin(codec, pin))
5166 continue;
5167
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005168 type = cfg->inputs[i].type;
5169 if (i > 0 && type == cfg->inputs[i - 1].type)
5170 type_idx++;
5171 else
5172 type_idx = 0;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005173 label = hda_get_autocfg_input_label(codec, cfg, i);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005174 if (mixer) {
5175 idx = get_connection_index(codec, mixer, pin);
5176 if (idx >= 0) {
5177 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005178 label, type_idx,
5179 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005180 if (err < 0)
5181 return err;
5182 }
5183 }
5184
5185 if (!cap1)
5186 continue;
5187 idx = get_connection_index(codec, cap1, pin);
5188 if (idx < 0 && cap2)
5189 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005190 if (idx >= 0)
5191 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005192 }
5193 return 0;
5194}
5195
Takashi Iwai05f5f472009-08-25 13:10:18 +02005196static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5197 const struct auto_pin_cfg *cfg)
5198{
5199 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5200}
5201
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005202static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5203 unsigned int pin_type)
5204{
5205 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5206 pin_type);
5207 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005208 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5209 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005210}
5211
Kailang Yangdf694da2005-12-05 19:42:22 +01005212static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5213 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005214 int dac_idx)
5215{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005216 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005217 /* need the manual connection? */
5218 if (alc880_is_multi_pin(nid)) {
5219 struct alc_spec *spec = codec->spec;
5220 int idx = alc880_multi_pin_idx(nid);
5221 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5222 AC_VERB_SET_CONNECT_SEL,
5223 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5224 }
5225}
5226
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005227static int get_pin_type(int line_out_type)
5228{
5229 if (line_out_type == AUTO_PIN_HP_OUT)
5230 return PIN_HP;
5231 else
5232 return PIN_OUT;
5233}
5234
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005235static void alc880_auto_init_multi_out(struct hda_codec *codec)
5236{
5237 struct alc_spec *spec = codec->spec;
5238 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005239
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005240 for (i = 0; i < spec->autocfg.line_outs; i++) {
5241 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005242 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5243 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005244 }
5245}
5246
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005247static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005248{
5249 struct alc_spec *spec = codec->spec;
5250 hda_nid_t pin;
5251
Takashi Iwai82bc9552006-03-21 11:24:42 +01005252 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005253 if (pin) /* connect to front */
5254 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005255 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005256 if (pin) /* connect to front */
5257 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5258}
5259
5260static void alc880_auto_init_analog_input(struct hda_codec *codec)
5261{
5262 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005263 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005264 int i;
5265
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005266 for (i = 0; i < cfg->num_inputs; i++) {
5267 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005268 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005269 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005270 if (nid != ALC880_PIN_CD_NID &&
5271 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005272 snd_hda_codec_write(codec, nid, 0,
5273 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005274 AMP_OUT_MUTE);
5275 }
5276 }
5277}
5278
Takashi Iwai7f311a42010-04-09 17:32:23 +02005279static void alc880_auto_init_input_src(struct hda_codec *codec)
5280{
5281 struct alc_spec *spec = codec->spec;
5282 int c;
5283
5284 for (c = 0; c < spec->num_adc_nids; c++) {
5285 unsigned int mux_idx;
5286 const struct hda_input_mux *imux;
5287 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5288 imux = &spec->input_mux[mux_idx];
5289 if (!imux->num_items && mux_idx > 0)
5290 imux = &spec->input_mux[0];
5291 if (imux)
5292 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5293 AC_VERB_SET_CONNECT_SEL,
5294 imux->items[0].index);
5295 }
5296}
5297
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005298/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005299/* return 1 if successful, 0 if the proper config is not found,
5300 * or a negative error code
5301 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005302static int alc880_parse_auto_config(struct hda_codec *codec)
5303{
5304 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005305 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005306 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005307
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005308 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5309 alc880_ignore);
5310 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005311 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005312 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005313 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005314
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005315 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5316 if (err < 0)
5317 return err;
5318 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5319 if (err < 0)
5320 return err;
5321 err = alc880_auto_create_extra_out(spec,
5322 spec->autocfg.speaker_pins[0],
5323 "Speaker");
5324 if (err < 0)
5325 return err;
5326 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5327 "Headphone");
5328 if (err < 0)
5329 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005330 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005331 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005332 return err;
5333
5334 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5335
Takashi Iwai757899a2010-07-30 10:48:14 +02005336 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005337
Takashi Iwai603c4012008-07-30 15:01:44 +02005338 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005339 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005340
Takashi Iwaid88897e2008-10-31 15:01:37 +01005341 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005342
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005343 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005344 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005345
Kailang Yang6227cdc2010-02-25 08:36:52 +01005346 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005347
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005348 return 1;
5349}
5350
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005351/* additional initialization for auto-configuration model */
5352static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005353{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005354 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005355 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005356 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005357 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005358 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005359 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005360 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005361 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005362}
5363
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005364/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5365 * one of two digital mic pins, e.g. on ALC272
5366 */
5367static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005368{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005369 struct alc_spec *spec = codec->spec;
5370 int i;
5371
5372 for (i = 0; i < spec->num_adc_nids; i++) {
5373 hda_nid_t cap = spec->capsrc_nids ?
5374 spec->capsrc_nids[i] : spec->adc_nids[i];
5375 int iidx, eidx;
5376
5377 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5378 if (iidx < 0)
5379 continue;
5380 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5381 if (eidx < 0)
5382 continue;
5383 spec->int_mic.mux_idx = iidx;
5384 spec->ext_mic.mux_idx = eidx;
5385 if (spec->capsrc_nids)
5386 spec->capsrc_nids += i;
5387 spec->adc_nids += i;
5388 spec->num_adc_nids = 1;
5389 return;
5390 }
5391 snd_printd(KERN_INFO "hda_codec: %s: "
5392 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5393 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5394 spec->auto_mic = 0; /* disable auto-mic to be sure */
5395}
5396
Takashi Iwai748cce42010-08-04 07:37:39 +02005397/* select or unmute the given capsrc route */
5398static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5399 int idx)
5400{
5401 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5402 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5403 HDA_AMP_MUTE, 0);
5404 } else {
5405 snd_hda_codec_write_cache(codec, cap, 0,
5406 AC_VERB_SET_CONNECT_SEL, idx);
5407 }
5408}
5409
Takashi Iwai840b64c2010-07-13 22:49:01 +02005410/* set the default connection to that pin */
5411static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5412{
5413 struct alc_spec *spec = codec->spec;
5414 int i;
5415
5416 for (i = 0; i < spec->num_adc_nids; i++) {
5417 hda_nid_t cap = spec->capsrc_nids ?
5418 spec->capsrc_nids[i] : spec->adc_nids[i];
5419 int idx;
5420
5421 idx = get_connection_index(codec, cap, pin);
5422 if (idx < 0)
5423 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005424 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005425 return i; /* return the found index */
5426 }
5427 return -1; /* not found */
5428}
5429
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005430/* choose the ADC/MUX containing the input pin and initialize the setup */
5431static void fixup_single_adc(struct hda_codec *codec)
5432{
5433 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005434 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005435 int i;
5436
5437 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005438 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005439 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005440 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005441 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005442 /* use only this ADC */
5443 if (spec->capsrc_nids)
5444 spec->capsrc_nids += i;
5445 spec->adc_nids += i;
5446 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005447 }
5448}
5449
Takashi Iwai840b64c2010-07-13 22:49:01 +02005450/* initialize dual adcs */
5451static void fixup_dual_adc_switch(struct hda_codec *codec)
5452{
5453 struct alc_spec *spec = codec->spec;
5454 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5455 init_capsrc_for_pin(codec, spec->int_mic.pin);
5456}
5457
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005458static void set_capture_mixer(struct hda_codec *codec)
5459{
5460 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005461 static struct snd_kcontrol_new *caps[2][3] = {
5462 { alc_capture_mixer_nosrc1,
5463 alc_capture_mixer_nosrc2,
5464 alc_capture_mixer_nosrc3 },
5465 { alc_capture_mixer1,
5466 alc_capture_mixer2,
5467 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005468 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005469 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005470 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005471 int num_adcs = spec->num_adc_nids;
5472 if (spec->dual_adc_switch)
5473 fixup_dual_adc_switch(codec);
5474 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005475 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005476 else if (spec->input_mux) {
5477 if (spec->input_mux->num_items > 1)
5478 mux = 1;
5479 else if (spec->input_mux->num_items == 1)
5480 fixup_single_adc(codec);
5481 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005482 if (spec->dual_adc_switch)
5483 num_adcs = 1;
5484 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005485 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005486}
5487
Takashi Iwai66946352010-03-29 17:21:45 +02005488/* fill adc_nids (and capsrc_nids) containing all active input pins */
5489static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5490 int num_nids)
5491{
5492 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005493 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005494 int n;
5495 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5496
5497 for (n = 0; n < num_nids; n++) {
5498 hda_nid_t adc, cap;
5499 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5500 int nconns, i, j;
5501
5502 adc = nids[n];
5503 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5504 continue;
5505 cap = adc;
5506 nconns = snd_hda_get_connections(codec, cap, conn,
5507 ARRAY_SIZE(conn));
5508 if (nconns == 1) {
5509 cap = conn[0];
5510 nconns = snd_hda_get_connections(codec, cap, conn,
5511 ARRAY_SIZE(conn));
5512 }
5513 if (nconns <= 0)
5514 continue;
5515 if (!fallback_adc) {
5516 fallback_adc = adc;
5517 fallback_cap = cap;
5518 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005519 for (i = 0; i < cfg->num_inputs; i++) {
5520 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005521 for (j = 0; j < nconns; j++) {
5522 if (conn[j] == nid)
5523 break;
5524 }
5525 if (j >= nconns)
5526 break;
5527 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005528 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005529 int num_adcs = spec->num_adc_nids;
5530 spec->private_adc_nids[num_adcs] = adc;
5531 spec->private_capsrc_nids[num_adcs] = cap;
5532 spec->num_adc_nids++;
5533 spec->adc_nids = spec->private_adc_nids;
5534 if (adc != cap)
5535 spec->capsrc_nids = spec->private_capsrc_nids;
5536 }
5537 }
5538 if (!spec->num_adc_nids) {
5539 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005540 " using fallback 0x%x\n",
5541 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005542 spec->private_adc_nids[0] = fallback_adc;
5543 spec->adc_nids = spec->private_adc_nids;
5544 if (fallback_adc != fallback_cap) {
5545 spec->private_capsrc_nids[0] = fallback_cap;
5546 spec->capsrc_nids = spec->private_adc_nids;
5547 }
5548 }
5549}
5550
Takashi Iwai67d634c2009-11-16 15:35:59 +01005551#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005552#define set_beep_amp(spec, nid, idx, dir) \
5553 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005554
5555static struct snd_pci_quirk beep_white_list[] = {
5556 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005557 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005558 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005559 {}
5560};
5561
5562static inline int has_cdefine_beep(struct hda_codec *codec)
5563{
5564 struct alc_spec *spec = codec->spec;
5565 const struct snd_pci_quirk *q;
5566 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5567 if (q)
5568 return q->value;
5569 return spec->cdefine.enable_pcbeep;
5570}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005571#else
5572#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005573#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005574#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005575
5576/*
5577 * OK, here we have finally the patch for ALC880
5578 */
5579
Linus Torvalds1da177e2005-04-16 15:20:36 -07005580static int patch_alc880(struct hda_codec *codec)
5581{
5582 struct alc_spec *spec;
5583 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005584 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005585
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005586 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005587 if (spec == NULL)
5588 return -ENOMEM;
5589
5590 codec->spec = spec;
5591
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005592 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5593 alc880_models,
5594 alc880_cfg_tbl);
5595 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005596 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5597 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005598 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005599 }
5600
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005601 if (board_config == ALC880_AUTO) {
5602 /* automatic parse from the BIOS config */
5603 err = alc880_parse_auto_config(codec);
5604 if (err < 0) {
5605 alc_free(codec);
5606 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005607 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005608 printk(KERN_INFO
5609 "hda_codec: Cannot set up configuration "
5610 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005611 board_config = ALC880_3ST;
5612 }
5613 }
5614
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005615 err = snd_hda_attach_beep_device(codec, 0x1);
5616 if (err < 0) {
5617 alc_free(codec);
5618 return err;
5619 }
5620
Kailang Yangdf694da2005-12-05 19:42:22 +01005621 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005622 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005623
Linus Torvalds1da177e2005-04-16 15:20:36 -07005624 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5625 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005626 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005627
Linus Torvalds1da177e2005-04-16 15:20:36 -07005628 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5629 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5630
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005631 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005632 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005633 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005634 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005635 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005636 if (wcap != AC_WID_AUD_IN) {
5637 spec->adc_nids = alc880_adc_nids_alt;
5638 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005639 } else {
5640 spec->adc_nids = alc880_adc_nids;
5641 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005642 }
5643 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005644 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005645 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005646
Takashi Iwai2134ea42008-01-10 16:53:55 +01005647 spec->vmaster_nid = 0x0c;
5648
Linus Torvalds1da177e2005-04-16 15:20:36 -07005649 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005650 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005651 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005652#ifdef CONFIG_SND_HDA_POWER_SAVE
5653 if (!spec->loopback.amplist)
5654 spec->loopback.amplist = alc880_loopbacks;
5655#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005656
5657 return 0;
5658}
5659
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005660
Linus Torvalds1da177e2005-04-16 15:20:36 -07005661/*
5662 * ALC260 support
5663 */
5664
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005665static hda_nid_t alc260_dac_nids[1] = {
5666 /* front */
5667 0x02,
5668};
5669
5670static hda_nid_t alc260_adc_nids[1] = {
5671 /* ADC0 */
5672 0x04,
5673};
5674
Kailang Yangdf694da2005-12-05 19:42:22 +01005675static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005676 /* ADC1 */
5677 0x05,
5678};
5679
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005680/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5681 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5682 */
5683static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005684 /* ADC0, ADC1 */
5685 0x04, 0x05
5686};
5687
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005688#define ALC260_DIGOUT_NID 0x03
5689#define ALC260_DIGIN_NID 0x06
5690
5691static struct hda_input_mux alc260_capture_source = {
5692 .num_items = 4,
5693 .items = {
5694 { "Mic", 0x0 },
5695 { "Front Mic", 0x1 },
5696 { "Line", 0x2 },
5697 { "CD", 0x4 },
5698 },
5699};
5700
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005701/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005702 * headphone jack and the internal CD lines since these are the only pins at
5703 * which audio can appear. For flexibility, also allow the option of
5704 * recording the mixer output on the second ADC (ADC0 doesn't have a
5705 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005706 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005707static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5708 {
5709 .num_items = 3,
5710 .items = {
5711 { "Mic/Line", 0x0 },
5712 { "CD", 0x4 },
5713 { "Headphone", 0x2 },
5714 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005715 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005716 {
5717 .num_items = 4,
5718 .items = {
5719 { "Mic/Line", 0x0 },
5720 { "CD", 0x4 },
5721 { "Headphone", 0x2 },
5722 { "Mixer", 0x5 },
5723 },
5724 },
5725
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005726};
5727
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005728/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5729 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005730 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005731static struct hda_input_mux alc260_acer_capture_sources[2] = {
5732 {
5733 .num_items = 4,
5734 .items = {
5735 { "Mic", 0x0 },
5736 { "Line", 0x2 },
5737 { "CD", 0x4 },
5738 { "Headphone", 0x5 },
5739 },
5740 },
5741 {
5742 .num_items = 5,
5743 .items = {
5744 { "Mic", 0x0 },
5745 { "Line", 0x2 },
5746 { "CD", 0x4 },
5747 { "Headphone", 0x6 },
5748 { "Mixer", 0x5 },
5749 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005750 },
5751};
Michael Schwingencc959482009-02-22 18:58:45 +01005752
5753/* Maxdata Favorit 100XS */
5754static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5755 {
5756 .num_items = 2,
5757 .items = {
5758 { "Line/Mic", 0x0 },
5759 { "CD", 0x4 },
5760 },
5761 },
5762 {
5763 .num_items = 3,
5764 .items = {
5765 { "Line/Mic", 0x0 },
5766 { "CD", 0x4 },
5767 { "Mixer", 0x5 },
5768 },
5769 },
5770};
5771
Linus Torvalds1da177e2005-04-16 15:20:36 -07005772/*
5773 * This is just place-holder, so there's something for alc_build_pcms to look
5774 * at when it calculates the maximum number of channels. ALC260 has no mixer
5775 * element which allows changing the channel mode, so the verb list is
5776 * never used.
5777 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005778static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005779 { 2, NULL },
5780};
5781
Kailang Yangdf694da2005-12-05 19:42:22 +01005782
5783/* Mixer combinations
5784 *
5785 * basic: base_output + input + pc_beep + capture
5786 * HP: base_output + input + capture_alt
5787 * HP_3013: hp_3013 + input + capture
5788 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005789 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005790 */
5791
5792static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005793 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005794 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005795 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5796 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5797 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5798 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5799 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005800};
Kailang Yangdf694da2005-12-05 19:42:22 +01005801
5802static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005803 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5804 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5805 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5806 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5807 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5808 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5809 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5810 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005811 { } /* end */
5812};
5813
Takashi Iwaibec15c32008-01-28 18:16:30 +01005814/* update HP, line and mono out pins according to the master switch */
5815static void alc260_hp_master_update(struct hda_codec *codec,
5816 hda_nid_t hp, hda_nid_t line,
5817 hda_nid_t mono)
5818{
5819 struct alc_spec *spec = codec->spec;
5820 unsigned int val = spec->master_sw ? PIN_HP : 0;
5821 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005822 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005823 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005824 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005825 val);
5826 /* mono (speaker) depending on the HP jack sense */
5827 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005828 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005829 val);
5830}
5831
5832static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5833 struct snd_ctl_elem_value *ucontrol)
5834{
5835 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5836 struct alc_spec *spec = codec->spec;
5837 *ucontrol->value.integer.value = spec->master_sw;
5838 return 0;
5839}
5840
5841static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5842 struct snd_ctl_elem_value *ucontrol)
5843{
5844 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5845 struct alc_spec *spec = codec->spec;
5846 int val = !!*ucontrol->value.integer.value;
5847 hda_nid_t hp, line, mono;
5848
5849 if (val == spec->master_sw)
5850 return 0;
5851 spec->master_sw = val;
5852 hp = (kcontrol->private_value >> 16) & 0xff;
5853 line = (kcontrol->private_value >> 8) & 0xff;
5854 mono = kcontrol->private_value & 0xff;
5855 alc260_hp_master_update(codec, hp, line, mono);
5856 return 1;
5857}
5858
5859static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5860 {
5861 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5862 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005863 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005864 .info = snd_ctl_boolean_mono_info,
5865 .get = alc260_hp_master_sw_get,
5866 .put = alc260_hp_master_sw_put,
5867 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5868 },
5869 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5870 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5871 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5872 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5873 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5874 HDA_OUTPUT),
5875 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5876 { } /* end */
5877};
5878
5879static struct hda_verb alc260_hp_unsol_verbs[] = {
5880 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5881 {},
5882};
5883
5884static void alc260_hp_automute(struct hda_codec *codec)
5885{
5886 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005887
Wu Fengguang864f92b2009-11-18 12:38:02 +08005888 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005889 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5890}
5891
5892static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5893{
5894 if ((res >> 26) == ALC880_HP_EVENT)
5895 alc260_hp_automute(codec);
5896}
5897
Kailang Yangdf694da2005-12-05 19:42:22 +01005898static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005899 {
5900 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5901 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005902 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005903 .info = snd_ctl_boolean_mono_info,
5904 .get = alc260_hp_master_sw_get,
5905 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005906 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005907 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005908 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5909 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5910 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5911 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5912 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5913 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005914 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5915 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005916 { } /* end */
5917};
5918
Kailang Yang3f878302008-08-26 13:02:23 +02005919static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5920 .ops = &snd_hda_bind_vol,
5921 .values = {
5922 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5923 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5924 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5925 0
5926 },
5927};
5928
5929static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5930 .ops = &snd_hda_bind_sw,
5931 .values = {
5932 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5933 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5934 0
5935 },
5936};
5937
5938static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5939 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5940 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5941 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5942 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5943 { } /* end */
5944};
5945
Takashi Iwaibec15c32008-01-28 18:16:30 +01005946static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5947 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5948 {},
5949};
5950
5951static void alc260_hp_3013_automute(struct hda_codec *codec)
5952{
5953 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005954
Wu Fengguang864f92b2009-11-18 12:38:02 +08005955 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005956 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005957}
5958
5959static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5960 unsigned int res)
5961{
5962 if ((res >> 26) == ALC880_HP_EVENT)
5963 alc260_hp_3013_automute(codec);
5964}
5965
Kailang Yang3f878302008-08-26 13:02:23 +02005966static void alc260_hp_3012_automute(struct hda_codec *codec)
5967{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005968 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005969
Kailang Yang3f878302008-08-26 13:02:23 +02005970 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5971 bits);
5972 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5973 bits);
5974 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5975 bits);
5976}
5977
5978static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5979 unsigned int res)
5980{
5981 if ((res >> 26) == ALC880_HP_EVENT)
5982 alc260_hp_3012_automute(codec);
5983}
5984
5985/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005986 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5987 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005988static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005989 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005990 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005991 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005992 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5993 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5994 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5995 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005996 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005997 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5998 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005999 { } /* end */
6000};
6001
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006002/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
6003 * versions of the ALC260 don't act on requests to enable mic bias from NID
6004 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
6005 * datasheet doesn't mention this restriction. At this stage it's not clear
6006 * whether this behaviour is intentional or is a hardware bug in chip
6007 * revisions available in early 2006. Therefore for now allow the
6008 * "Headphone Jack Mode" control to span all choices, but if it turns out
6009 * that the lack of mic bias for this NID is intentional we could change the
6010 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6011 *
6012 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
6013 * don't appear to make the mic bias available from the "line" jack, even
6014 * though the NID used for this jack (0x14) can supply it. The theory is
6015 * that perhaps Acer have included blocking capacitors between the ALC260
6016 * and the output jack. If this turns out to be the case for all such
6017 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
6018 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01006019 *
6020 * The C20x Tablet series have a mono internal speaker which is controlled
6021 * via the chip's Mono sum widget and pin complex, so include the necessary
6022 * controls for such models. On models without a "mono speaker" the control
6023 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006024 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006025static struct snd_kcontrol_new alc260_acer_mixer[] = {
6026 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6027 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006028 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006029 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01006030 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006031 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01006032 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006033 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6034 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6035 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6036 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6037 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6038 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6039 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6040 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006041 { } /* end */
6042};
6043
Michael Schwingencc959482009-02-22 18:58:45 +01006044/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6045 */
6046static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
6047 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6048 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6049 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6050 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6051 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6052 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6053 { } /* end */
6054};
6055
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006056/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6057 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6058 */
6059static struct snd_kcontrol_new alc260_will_mixer[] = {
6060 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6061 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6062 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6063 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6064 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6065 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6066 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6067 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6068 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6069 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006070 { } /* end */
6071};
6072
6073/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6074 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6075 */
6076static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
6077 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6078 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6079 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6080 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6081 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6082 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6083 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6084 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6085 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6086 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6087 { } /* end */
6088};
6089
Kailang Yangdf694da2005-12-05 19:42:22 +01006090/*
6091 * initialization verbs
6092 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006093static struct hda_verb alc260_init_verbs[] = {
6094 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006095 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006096 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006097 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006098 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006099 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006100 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006101 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006102 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006103 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006104 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006105 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006106 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006107 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006108 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006109 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006110 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006111 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6112 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006113 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006114 /* set connection select to line in (default select for this ADC) */
6115 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006116 /* mute capture amp left and right */
6117 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6118 /* set connection select to line in (default select for this ADC) */
6119 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006120 /* set vol=0 Line-Out mixer amp left and right */
6121 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6122 /* unmute pin widget amp left and right (no gain on this amp) */
6123 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6124 /* set vol=0 HP mixer amp left and right */
6125 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6126 /* unmute pin widget amp left and right (no gain on this amp) */
6127 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6128 /* set vol=0 Mono mixer amp left and right */
6129 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6130 /* unmute pin widget amp left and right (no gain on this amp) */
6131 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6132 /* unmute LINE-2 out pin */
6133 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006134 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6135 * Line In 2 = 0x03
6136 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006137 /* mute analog inputs */
6138 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6139 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6140 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6141 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6142 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006143 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006144 /* mute Front out path */
6145 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6146 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6147 /* mute Headphone out path */
6148 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6149 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6150 /* mute Mono out path */
6151 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6152 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006153 { }
6154};
6155
Takashi Iwai474167d2006-05-17 17:17:43 +02006156#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006157static struct hda_verb alc260_hp_init_verbs[] = {
6158 /* Headphone and output */
6159 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6160 /* mono output */
6161 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6162 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6163 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6164 /* Mic2 (front panel) pin widget for input and vref at 80% */
6165 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6166 /* Line In pin widget for input */
6167 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6168 /* Line-2 pin widget for output */
6169 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6170 /* CD pin widget for input */
6171 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6172 /* unmute amp left and right */
6173 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6174 /* set connection select to line in (default select for this ADC) */
6175 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6176 /* unmute Line-Out mixer amp left and right (volume = 0) */
6177 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6178 /* mute pin widget amp left and right (no gain on this amp) */
6179 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6180 /* unmute HP mixer amp left and right (volume = 0) */
6181 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6182 /* mute pin widget amp left and right (no gain on this amp) */
6183 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006184 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6185 * Line In 2 = 0x03
6186 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006187 /* mute analog inputs */
6188 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6189 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6190 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6191 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6192 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006193 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6194 /* Unmute Front out path */
6195 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6196 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6197 /* Unmute Headphone out path */
6198 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6199 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6200 /* Unmute Mono out path */
6201 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6202 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6203 { }
6204};
Takashi Iwai474167d2006-05-17 17:17:43 +02006205#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006206
6207static struct hda_verb alc260_hp_3013_init_verbs[] = {
6208 /* Line out and output */
6209 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6210 /* mono output */
6211 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6212 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6213 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6214 /* Mic2 (front panel) pin widget for input and vref at 80% */
6215 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6216 /* Line In pin widget for input */
6217 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6218 /* Headphone pin widget for output */
6219 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6220 /* CD pin widget for input */
6221 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6222 /* unmute amp left and right */
6223 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6224 /* set connection select to line in (default select for this ADC) */
6225 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6226 /* unmute Line-Out mixer amp left and right (volume = 0) */
6227 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6228 /* mute pin widget amp left and right (no gain on this amp) */
6229 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6230 /* unmute HP mixer amp left and right (volume = 0) */
6231 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6232 /* mute pin widget amp left and right (no gain on this amp) */
6233 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006234 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6235 * Line In 2 = 0x03
6236 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006237 /* mute analog inputs */
6238 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6239 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6240 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6241 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6242 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006243 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6244 /* Unmute Front out path */
6245 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6246 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6247 /* Unmute Headphone out path */
6248 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6249 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6250 /* Unmute Mono out path */
6251 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6252 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6253 { }
6254};
6255
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006256/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006257 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6258 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006259 */
6260static struct hda_verb alc260_fujitsu_init_verbs[] = {
6261 /* Disable all GPIOs */
6262 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6263 /* Internal speaker is connected to headphone pin */
6264 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6265 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6266 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006267 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6268 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6269 /* Ensure all other unused pins are disabled and muted. */
6270 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6271 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006272 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006273 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006274 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006275 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6276 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6277 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006278
Jonathan Woithef7ace402006-02-28 11:46:14 +01006279 /* Disable digital (SPDIF) pins */
6280 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6281 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006282
Kailang Yangea1fb292008-08-26 12:58:38 +02006283 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006284 * when acting as an output.
6285 */
6286 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6287
6288 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006289 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6290 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6291 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6292 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6293 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6294 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6295 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6296 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6297 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006298
Jonathan Woithef7ace402006-02-28 11:46:14 +01006299 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6300 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6301 /* Unmute Line1 pin widget output buffer since it starts as an output.
6302 * If the pin mode is changed by the user the pin mode control will
6303 * take care of enabling the pin's input/output buffers as needed.
6304 * Therefore there's no need to enable the input buffer at this
6305 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006306 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006307 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006308 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006309 * mixer ctrl)
6310 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006311 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006312
Jonathan Woithef7ace402006-02-28 11:46:14 +01006313 /* Mute capture amp left and right */
6314 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006315 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006316 * in (on mic1 pin)
6317 */
6318 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006319
Jonathan Woithef7ace402006-02-28 11:46:14 +01006320 /* Do the same for the second ADC: mute capture input amp and
6321 * set ADC connection to line in (on mic1 pin)
6322 */
6323 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6324 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006325
Jonathan Woithef7ace402006-02-28 11:46:14 +01006326 /* Mute all inputs to mixer widget (even unconnected ones) */
6327 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6328 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6329 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6330 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6331 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006335
6336 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006337};
6338
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006339/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6340 * similar laptops (adapted from Fujitsu init verbs).
6341 */
6342static struct hda_verb alc260_acer_init_verbs[] = {
6343 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6344 * the headphone jack. Turn this on and rely on the standard mute
6345 * methods whenever the user wants to turn these outputs off.
6346 */
6347 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6348 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6349 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6350 /* Internal speaker/Headphone jack is connected to Line-out pin */
6351 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6352 /* Internal microphone/Mic jack is connected to Mic1 pin */
6353 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6354 /* Line In jack is connected to Line1 pin */
6355 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006356 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6357 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006358 /* Ensure all other unused pins are disabled and muted. */
6359 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6360 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006361 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6362 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6363 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6364 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6365 /* Disable digital (SPDIF) pins */
6366 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6367 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6368
Kailang Yangea1fb292008-08-26 12:58:38 +02006369 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006370 * bus when acting as outputs.
6371 */
6372 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6373 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6374
6375 /* Start with output sum widgets muted and their output gains at min */
6376 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6377 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6378 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6379 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6380 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6381 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6382 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6383 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6384 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6385
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006386 /* Unmute Line-out pin widget amp left and right
6387 * (no equiv mixer ctrl)
6388 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006389 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006390 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6391 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006392 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6393 * inputs. If the pin mode is changed by the user the pin mode control
6394 * will take care of enabling the pin's input/output buffers as needed.
6395 * Therefore there's no need to enable the input buffer at this
6396 * stage.
6397 */
6398 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6399 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6400
6401 /* Mute capture amp left and right */
6402 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6403 /* Set ADC connection select to match default mixer setting - mic
6404 * (on mic1 pin)
6405 */
6406 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6407
6408 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006409 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006410 */
6411 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006412 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006413
6414 /* Mute all inputs to mixer widget (even unconnected ones) */
6415 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6416 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6417 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6418 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6419 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6420 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6421 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6422 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6423
6424 { }
6425};
6426
Michael Schwingencc959482009-02-22 18:58:45 +01006427/* Initialisation sequence for Maxdata Favorit 100XS
6428 * (adapted from Acer init verbs).
6429 */
6430static struct hda_verb alc260_favorit100_init_verbs[] = {
6431 /* GPIO 0 enables the output jack.
6432 * Turn this on and rely on the standard mute
6433 * methods whenever the user wants to turn these outputs off.
6434 */
6435 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6436 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6437 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6438 /* Line/Mic input jack is connected to Mic1 pin */
6439 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6440 /* Ensure all other unused pins are disabled and muted. */
6441 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6442 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6443 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6444 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6445 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6446 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6447 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6448 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6449 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6450 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6451 /* Disable digital (SPDIF) pins */
6452 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6453 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6454
6455 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6456 * bus when acting as outputs.
6457 */
6458 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6459 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6460
6461 /* Start with output sum widgets muted and their output gains at min */
6462 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6463 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6464 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6465 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6466 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6467 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6468 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6469 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6470 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6471
6472 /* Unmute Line-out pin widget amp left and right
6473 * (no equiv mixer ctrl)
6474 */
6475 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6476 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6477 * inputs. If the pin mode is changed by the user the pin mode control
6478 * will take care of enabling the pin's input/output buffers as needed.
6479 * Therefore there's no need to enable the input buffer at this
6480 * stage.
6481 */
6482 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6483
6484 /* Mute capture amp left and right */
6485 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6486 /* Set ADC connection select to match default mixer setting - mic
6487 * (on mic1 pin)
6488 */
6489 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6490
6491 /* Do similar with the second ADC: mute capture input amp and
6492 * set ADC connection to mic to match ALSA's default state.
6493 */
6494 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6495 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6496
6497 /* Mute all inputs to mixer widget (even unconnected ones) */
6498 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6499 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6500 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6501 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6502 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6503 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6504 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6505 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6506
6507 { }
6508};
6509
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006510static struct hda_verb alc260_will_verbs[] = {
6511 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6512 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6513 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6514 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6515 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6516 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6517 {}
6518};
6519
6520static struct hda_verb alc260_replacer_672v_verbs[] = {
6521 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6522 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6523 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6524
6525 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6526 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6527 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6528
6529 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6530 {}
6531};
6532
6533/* toggle speaker-output according to the hp-jack state */
6534static void alc260_replacer_672v_automute(struct hda_codec *codec)
6535{
6536 unsigned int present;
6537
6538 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006539 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006540 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006541 snd_hda_codec_write_cache(codec, 0x01, 0,
6542 AC_VERB_SET_GPIO_DATA, 1);
6543 snd_hda_codec_write_cache(codec, 0x0f, 0,
6544 AC_VERB_SET_PIN_WIDGET_CONTROL,
6545 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006546 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006547 snd_hda_codec_write_cache(codec, 0x01, 0,
6548 AC_VERB_SET_GPIO_DATA, 0);
6549 snd_hda_codec_write_cache(codec, 0x0f, 0,
6550 AC_VERB_SET_PIN_WIDGET_CONTROL,
6551 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006552 }
6553}
6554
6555static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6556 unsigned int res)
6557{
6558 if ((res >> 26) == ALC880_HP_EVENT)
6559 alc260_replacer_672v_automute(codec);
6560}
6561
Kailang Yang3f878302008-08-26 13:02:23 +02006562static struct hda_verb alc260_hp_dc7600_verbs[] = {
6563 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6564 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6565 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6566 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6567 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6568 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6569 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6570 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6571 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6572 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6573 {}
6574};
6575
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006576/* Test configuration for debugging, modelled after the ALC880 test
6577 * configuration.
6578 */
6579#ifdef CONFIG_SND_DEBUG
6580static hda_nid_t alc260_test_dac_nids[1] = {
6581 0x02,
6582};
6583static hda_nid_t alc260_test_adc_nids[2] = {
6584 0x04, 0x05,
6585};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006586/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006587 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006588 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006589 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006590static struct hda_input_mux alc260_test_capture_sources[2] = {
6591 {
6592 .num_items = 7,
6593 .items = {
6594 { "MIC1 pin", 0x0 },
6595 { "MIC2 pin", 0x1 },
6596 { "LINE1 pin", 0x2 },
6597 { "LINE2 pin", 0x3 },
6598 { "CD pin", 0x4 },
6599 { "LINE-OUT pin", 0x5 },
6600 { "HP-OUT pin", 0x6 },
6601 },
6602 },
6603 {
6604 .num_items = 8,
6605 .items = {
6606 { "MIC1 pin", 0x0 },
6607 { "MIC2 pin", 0x1 },
6608 { "LINE1 pin", 0x2 },
6609 { "LINE2 pin", 0x3 },
6610 { "CD pin", 0x4 },
6611 { "Mixer", 0x5 },
6612 { "LINE-OUT pin", 0x6 },
6613 { "HP-OUT pin", 0x7 },
6614 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006615 },
6616};
6617static struct snd_kcontrol_new alc260_test_mixer[] = {
6618 /* Output driver widgets */
6619 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6620 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6621 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6622 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6623 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6624 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6625
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006626 /* Modes for retasking pin widgets
6627 * Note: the ALC260 doesn't seem to act on requests to enable mic
6628 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6629 * mention this restriction. At this stage it's not clear whether
6630 * this behaviour is intentional or is a hardware bug in chip
6631 * revisions available at least up until early 2006. Therefore for
6632 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6633 * choices, but if it turns out that the lack of mic bias for these
6634 * NIDs is intentional we could change their modes from
6635 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6636 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006637 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6638 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6639 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6640 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6641 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6642 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6643
6644 /* Loopback mixer controls */
6645 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6646 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6647 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6648 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6649 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6650 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6651 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6652 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6653 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6654 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006655 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6656 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6657 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6658 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006659
6660 /* Controls for GPIO pins, assuming they are configured as outputs */
6661 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6662 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6663 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6664 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6665
Jonathan Woithe92621f12006-02-28 11:47:47 +01006666 /* Switches to allow the digital IO pins to be enabled. The datasheet
6667 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006668 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006669 */
6670 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6671 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6672
Jonathan Woithef8225f62008-01-08 12:16:54 +01006673 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6674 * this output to turn on an external amplifier.
6675 */
6676 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6677 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6678
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006679 { } /* end */
6680};
6681static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006682 /* Enable all GPIOs as outputs with an initial value of 0 */
6683 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6684 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6685 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6686
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006687 /* Enable retasking pins as output, initially without power amp */
6688 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6689 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6690 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6691 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6692 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6693 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6694
Jonathan Woithe92621f12006-02-28 11:47:47 +01006695 /* Disable digital (SPDIF) pins initially, but users can enable
6696 * them via a mixer switch. In the case of SPDIF-out, this initverb
6697 * payload also sets the generation to 0, output to be in "consumer"
6698 * PCM format, copyright asserted, no pre-emphasis and no validity
6699 * control.
6700 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006701 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6702 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6703
Kailang Yangea1fb292008-08-26 12:58:38 +02006704 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006705 * OUT1 sum bus when acting as an output.
6706 */
6707 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6708 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6709 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6710 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6711
6712 /* Start with output sum widgets muted and their output gains at min */
6713 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6714 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6715 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6716 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6717 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6718 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6719 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6720 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6721 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6722
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006723 /* Unmute retasking pin widget output buffers since the default
6724 * state appears to be output. As the pin mode is changed by the
6725 * user the pin mode control will take care of enabling the pin's
6726 * input/output buffers as needed.
6727 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006728 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6729 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6730 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6731 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6732 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6733 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6734 /* Also unmute the mono-out pin widget */
6735 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6736
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006737 /* Mute capture amp left and right */
6738 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006739 /* Set ADC connection select to match default mixer setting (mic1
6740 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006741 */
6742 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6743
6744 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006745 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006746 */
6747 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6748 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6749
6750 /* Mute all inputs to mixer widget (even unconnected ones) */
6751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6752 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6753 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6754 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6755 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6756 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6757 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6758 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6759
6760 { }
6761};
6762#endif
6763
Takashi Iwai63300792008-01-24 15:31:36 +01006764#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6765#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006766
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006767#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6768#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6769
Kailang Yangdf694da2005-12-05 19:42:22 +01006770/*
6771 * for BIOS auto-configuration
6772 */
6773
6774static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006775 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006776{
6777 hda_nid_t nid_vol;
6778 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006779 int err;
6780
6781 if (nid >= 0x0f && nid < 0x11) {
6782 nid_vol = nid - 0x7;
6783 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6784 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6785 } else if (nid == 0x11) {
6786 nid_vol = nid - 0x7;
6787 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6788 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6789 } else if (nid >= 0x12 && nid <= 0x15) {
6790 nid_vol = 0x08;
6791 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6792 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6793 } else
6794 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006795
Takashi Iwai863b4512008-10-21 17:01:47 +02006796 if (!(*vol_bits & (1 << nid_vol))) {
6797 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006798 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006799 if (err < 0)
6800 return err;
6801 *vol_bits |= (1 << nid_vol);
6802 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006803 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006804 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006805 return err;
6806 return 1;
6807}
6808
6809/* add playback controls from the parsed DAC table */
6810static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6811 const struct auto_pin_cfg *cfg)
6812{
6813 hda_nid_t nid;
6814 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006815 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006816
6817 spec->multiout.num_dacs = 1;
6818 spec->multiout.dac_nids = spec->private_dac_nids;
6819 spec->multiout.dac_nids[0] = 0x02;
6820
6821 nid = cfg->line_out_pins[0];
6822 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006823 const char *pfx;
6824 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6825 pfx = "Master";
6826 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6827 pfx = "Speaker";
6828 else
6829 pfx = "Front";
6830 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006831 if (err < 0)
6832 return err;
6833 }
6834
Takashi Iwai82bc9552006-03-21 11:24:42 +01006835 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006836 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006837 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006838 if (err < 0)
6839 return err;
6840 }
6841
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006842 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006843 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006844 err = alc260_add_playback_controls(spec, nid, "Headphone",
6845 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006846 if (err < 0)
6847 return err;
6848 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006849 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006850}
6851
6852/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006853static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006854 const struct auto_pin_cfg *cfg)
6855{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006856 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006857}
6858
6859static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6860 hda_nid_t nid, int pin_type,
6861 int sel_idx)
6862{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006863 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006864 /* need the manual connection? */
6865 if (nid >= 0x12) {
6866 int idx = nid - 0x12;
6867 snd_hda_codec_write(codec, idx + 0x0b, 0,
6868 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006869 }
6870}
6871
6872static void alc260_auto_init_multi_out(struct hda_codec *codec)
6873{
6874 struct alc_spec *spec = codec->spec;
6875 hda_nid_t nid;
6876
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006877 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006878 if (nid) {
6879 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6880 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6881 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006882
Takashi Iwai82bc9552006-03-21 11:24:42 +01006883 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006884 if (nid)
6885 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6886
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006887 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006888 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006889 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006890}
Kailang Yangdf694da2005-12-05 19:42:22 +01006891
6892#define ALC260_PIN_CD_NID 0x16
6893static void alc260_auto_init_analog_input(struct hda_codec *codec)
6894{
6895 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006896 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01006897 int i;
6898
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006899 for (i = 0; i < cfg->num_inputs; i++) {
6900 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01006901 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02006902 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006903 if (nid != ALC260_PIN_CD_NID &&
6904 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006905 snd_hda_codec_write(codec, nid, 0,
6906 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006907 AMP_OUT_MUTE);
6908 }
6909 }
6910}
6911
Takashi Iwai7f311a42010-04-09 17:32:23 +02006912#define alc260_auto_init_input_src alc880_auto_init_input_src
6913
Kailang Yangdf694da2005-12-05 19:42:22 +01006914/*
6915 * generic initialization of ADC, input mixers and output mixers
6916 */
6917static struct hda_verb alc260_volume_init_verbs[] = {
6918 /*
6919 * Unmute ADC0-1 and set the default input to mic-in
6920 */
6921 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6922 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6923 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6924 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006925
Kailang Yangdf694da2005-12-05 19:42:22 +01006926 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6927 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006928 * Note: PASD motherboards uses the Line In 2 as the input for
6929 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006930 */
6931 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006932 /* mute analog inputs */
6933 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6934 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6935 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6937 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006938
6939 /*
6940 * Set up output mixers (0x08 - 0x0a)
6941 */
6942 /* set vol=0 to output mixers */
6943 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6944 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6945 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6946 /* set up input amps for analog loopback */
6947 /* Amp Indices: DAC = 0, mixer = 1 */
6948 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6949 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6950 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6951 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6952 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6953 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006954
Kailang Yangdf694da2005-12-05 19:42:22 +01006955 { }
6956};
6957
6958static int alc260_parse_auto_config(struct hda_codec *codec)
6959{
6960 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006961 int err;
6962 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6963
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006964 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6965 alc260_ignore);
6966 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006967 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006968 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6969 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006970 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006971 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006972 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006973 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006974 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006975 return err;
6976
6977 spec->multiout.max_channels = 2;
6978
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006979 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006980 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006981 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006982 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006983
Takashi Iwaid88897e2008-10-31 15:01:37 +01006984 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006985
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006986 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006987 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006988
Kailang Yang6227cdc2010-02-25 08:36:52 +01006989 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006990
Kailang Yangdf694da2005-12-05 19:42:22 +01006991 return 1;
6992}
6993
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006994/* additional initialization for auto-configuration model */
6995static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006996{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006997 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006998 alc260_auto_init_multi_out(codec);
6999 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02007000 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02007001 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007002 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007003 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007004}
7005
Takashi Iwaicb53c622007-08-10 17:21:45 +02007006#ifdef CONFIG_SND_HDA_POWER_SAVE
7007static struct hda_amp_list alc260_loopbacks[] = {
7008 { 0x07, HDA_INPUT, 0 },
7009 { 0x07, HDA_INPUT, 1 },
7010 { 0x07, HDA_INPUT, 2 },
7011 { 0x07, HDA_INPUT, 3 },
7012 { 0x07, HDA_INPUT, 4 },
7013 { } /* end */
7014};
7015#endif
7016
Kailang Yangdf694da2005-12-05 19:42:22 +01007017/*
Takashi Iwaifc091762010-08-04 23:53:36 +02007018 * Pin config fixes
7019 */
7020enum {
7021 PINFIX_HP_DC5750,
7022};
7023
Takashi Iwaifc091762010-08-04 23:53:36 +02007024static const struct alc_fixup alc260_fixups[] = {
7025 [PINFIX_HP_DC5750] = {
Takashi Iwai73413b12010-08-30 09:39:57 +02007026 .pins = (const struct alc_pincfg[]) {
7027 { 0x11, 0x90130110 }, /* speaker */
7028 { }
7029 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007030 },
7031};
7032
7033static struct snd_pci_quirk alc260_fixup_tbl[] = {
7034 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
7035 {}
7036};
7037
7038/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007039 * ALC260 configurations
7040 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007041static const char *alc260_models[ALC260_MODEL_LAST] = {
7042 [ALC260_BASIC] = "basic",
7043 [ALC260_HP] = "hp",
7044 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007045 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007046 [ALC260_FUJITSU_S702X] = "fujitsu",
7047 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007048 [ALC260_WILL] = "will",
7049 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007050 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007051#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007052 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007053#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007054 [ALC260_AUTO] = "auto",
7055};
7056
7057static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007058 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007059 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007060 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007061 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007062 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007063 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007064 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007065 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007066 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007067 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7068 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7069 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7070 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7071 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7072 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7073 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7074 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7075 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007076 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007077 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007078 {}
7079};
7080
Kailang Yangdf694da2005-12-05 19:42:22 +01007081static struct alc_config_preset alc260_presets[] = {
7082 [ALC260_BASIC] = {
7083 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007084 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007085 .init_verbs = { alc260_init_verbs },
7086 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7087 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007088 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007089 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007090 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7091 .channel_mode = alc260_modes,
7092 .input_mux = &alc260_capture_source,
7093 },
7094 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007095 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007096 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007097 .init_verbs = { alc260_init_verbs,
7098 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007099 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7100 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007101 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7102 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007103 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7104 .channel_mode = alc260_modes,
7105 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007106 .unsol_event = alc260_hp_unsol_event,
7107 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007108 },
Kailang Yang3f878302008-08-26 13:02:23 +02007109 [ALC260_HP_DC7600] = {
7110 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007111 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007112 .init_verbs = { alc260_init_verbs,
7113 alc260_hp_dc7600_verbs },
7114 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7115 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007116 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7117 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007118 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7119 .channel_mode = alc260_modes,
7120 .input_mux = &alc260_capture_source,
7121 .unsol_event = alc260_hp_3012_unsol_event,
7122 .init_hook = alc260_hp_3012_automute,
7123 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007124 [ALC260_HP_3013] = {
7125 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007126 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007127 .init_verbs = { alc260_hp_3013_init_verbs,
7128 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007129 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7130 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007131 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7132 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007133 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7134 .channel_mode = alc260_modes,
7135 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007136 .unsol_event = alc260_hp_3013_unsol_event,
7137 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007138 },
7139 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007140 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007141 .init_verbs = { alc260_fujitsu_init_verbs },
7142 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7143 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007144 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7145 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007146 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7147 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007148 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7149 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007150 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007151 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007152 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007153 .init_verbs = { alc260_acer_init_verbs },
7154 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7155 .dac_nids = alc260_dac_nids,
7156 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7157 .adc_nids = alc260_dual_adc_nids,
7158 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7159 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007160 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7161 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007162 },
Michael Schwingencc959482009-02-22 18:58:45 +01007163 [ALC260_FAVORIT100] = {
7164 .mixers = { alc260_favorit100_mixer },
7165 .init_verbs = { alc260_favorit100_init_verbs },
7166 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7167 .dac_nids = alc260_dac_nids,
7168 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7169 .adc_nids = alc260_dual_adc_nids,
7170 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7171 .channel_mode = alc260_modes,
7172 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7173 .input_mux = alc260_favorit100_capture_sources,
7174 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007175 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007176 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007177 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7178 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7179 .dac_nids = alc260_dac_nids,
7180 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7181 .adc_nids = alc260_adc_nids,
7182 .dig_out_nid = ALC260_DIGOUT_NID,
7183 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7184 .channel_mode = alc260_modes,
7185 .input_mux = &alc260_capture_source,
7186 },
7187 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007188 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007189 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7190 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7191 .dac_nids = alc260_dac_nids,
7192 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7193 .adc_nids = alc260_adc_nids,
7194 .dig_out_nid = ALC260_DIGOUT_NID,
7195 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7196 .channel_mode = alc260_modes,
7197 .input_mux = &alc260_capture_source,
7198 .unsol_event = alc260_replacer_672v_unsol_event,
7199 .init_hook = alc260_replacer_672v_automute,
7200 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007201#ifdef CONFIG_SND_DEBUG
7202 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007203 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007204 .init_verbs = { alc260_test_init_verbs },
7205 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7206 .dac_nids = alc260_test_dac_nids,
7207 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7208 .adc_nids = alc260_test_adc_nids,
7209 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7210 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007211 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7212 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007213 },
7214#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007215};
7216
Linus Torvalds1da177e2005-04-16 15:20:36 -07007217static int patch_alc260(struct hda_codec *codec)
7218{
7219 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007220 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007221
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007222 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007223 if (spec == NULL)
7224 return -ENOMEM;
7225
7226 codec->spec = spec;
7227
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007228 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7229 alc260_models,
7230 alc260_cfg_tbl);
7231 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007232 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007233 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007234 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007235 }
7236
Takashi Iwaifc091762010-08-04 23:53:36 +02007237 if (board_config == ALC260_AUTO)
7238 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 1);
7239
Kailang Yangdf694da2005-12-05 19:42:22 +01007240 if (board_config == ALC260_AUTO) {
7241 /* automatic parse from the BIOS config */
7242 err = alc260_parse_auto_config(codec);
7243 if (err < 0) {
7244 alc_free(codec);
7245 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007246 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007247 printk(KERN_INFO
7248 "hda_codec: Cannot set up configuration "
7249 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007250 board_config = ALC260_BASIC;
7251 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007252 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007253
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007254 err = snd_hda_attach_beep_device(codec, 0x1);
7255 if (err < 0) {
7256 alc_free(codec);
7257 return err;
7258 }
7259
Kailang Yangdf694da2005-12-05 19:42:22 +01007260 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007261 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007262
Linus Torvalds1da177e2005-04-16 15:20:36 -07007263 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7264 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307265 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007266
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007267 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7268 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7269
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007270 if (!spec->adc_nids && spec->input_mux) {
7271 /* check whether NID 0x04 is valid */
7272 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007273 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007274 /* get type */
7275 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7276 spec->adc_nids = alc260_adc_nids_alt;
7277 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7278 } else {
7279 spec->adc_nids = alc260_adc_nids;
7280 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7281 }
7282 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007283 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007284 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007285
Takashi Iwaifc091762010-08-04 23:53:36 +02007286 if (board_config == ALC260_AUTO)
7287 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 0);
7288
Takashi Iwai2134ea42008-01-10 16:53:55 +01007289 spec->vmaster_nid = 0x08;
7290
Linus Torvalds1da177e2005-04-16 15:20:36 -07007291 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007292 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007293 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007294#ifdef CONFIG_SND_HDA_POWER_SAVE
7295 if (!spec->loopback.amplist)
7296 spec->loopback.amplist = alc260_loopbacks;
7297#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007298
7299 return 0;
7300}
7301
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007302
Linus Torvalds1da177e2005-04-16 15:20:36 -07007303/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007304 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007305 *
7306 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7307 * configuration. Each pin widget can choose any input DACs and a mixer.
7308 * Each ADC is connected from a mixer of all inputs. This makes possible
7309 * 6-channel independent captures.
7310 *
7311 * In addition, an independent DAC for the multi-playback (not used in this
7312 * driver yet).
7313 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007314#define ALC882_DIGOUT_NID 0x06
7315#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007316#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7317#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7318#define ALC1200_DIGOUT_NID 0x10
7319
Linus Torvalds1da177e2005-04-16 15:20:36 -07007320
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007321static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007322 { 8, NULL }
7323};
7324
Takashi Iwai4953550a2009-06-30 15:28:30 +02007325/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007326static hda_nid_t alc882_dac_nids[4] = {
7327 /* front, rear, clfe, rear_surr */
7328 0x02, 0x03, 0x04, 0x05
7329};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007330#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007331
Takashi Iwai4953550a2009-06-30 15:28:30 +02007332/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007333#define alc882_adc_nids alc880_adc_nids
7334#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007335#define alc883_adc_nids alc882_adc_nids_alt
7336static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7337static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7338#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007339
Takashi Iwaie1406342008-02-11 18:32:32 +01007340static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7341static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007342#define alc883_capsrc_nids alc882_capsrc_nids_alt
7343static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7344#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007345
Linus Torvalds1da177e2005-04-16 15:20:36 -07007346/* input MUX */
7347/* FIXME: should be a matrix-type input source selection */
7348
7349static struct hda_input_mux alc882_capture_source = {
7350 .num_items = 4,
7351 .items = {
7352 { "Mic", 0x0 },
7353 { "Front Mic", 0x1 },
7354 { "Line", 0x2 },
7355 { "CD", 0x4 },
7356 },
7357};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007358
Takashi Iwai4953550a2009-06-30 15:28:30 +02007359#define alc883_capture_source alc882_capture_source
7360
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007361static struct hda_input_mux alc889_capture_source = {
7362 .num_items = 3,
7363 .items = {
7364 { "Front Mic", 0x0 },
7365 { "Mic", 0x3 },
7366 { "Line", 0x2 },
7367 },
7368};
7369
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007370static struct hda_input_mux mb5_capture_source = {
7371 .num_items = 3,
7372 .items = {
7373 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307374 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007375 { "CD", 0x4 },
7376 },
7377};
7378
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007379static struct hda_input_mux macmini3_capture_source = {
7380 .num_items = 2,
7381 .items = {
7382 { "Line", 0x2 },
7383 { "CD", 0x4 },
7384 },
7385};
7386
Takashi Iwai4953550a2009-06-30 15:28:30 +02007387static struct hda_input_mux alc883_3stack_6ch_intel = {
7388 .num_items = 4,
7389 .items = {
7390 { "Mic", 0x1 },
7391 { "Front Mic", 0x0 },
7392 { "Line", 0x2 },
7393 { "CD", 0x4 },
7394 },
7395};
7396
7397static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7398 .num_items = 2,
7399 .items = {
7400 { "Mic", 0x1 },
7401 { "Line", 0x2 },
7402 },
7403};
7404
7405static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7406 .num_items = 4,
7407 .items = {
7408 { "Mic", 0x0 },
David Henningsson150b4322010-07-29 14:46:42 +02007409 { "Int Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007410 { "Line", 0x2 },
7411 { "CD", 0x4 },
7412 },
7413};
7414
7415static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7416 .num_items = 2,
7417 .items = {
7418 { "Mic", 0x0 },
7419 { "Int Mic", 0x1 },
7420 },
7421};
7422
7423static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7424 .num_items = 3,
7425 .items = {
7426 { "Mic", 0x0 },
7427 { "Front Mic", 0x1 },
7428 { "Line", 0x4 },
7429 },
7430};
7431
7432static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7433 .num_items = 2,
7434 .items = {
7435 { "Mic", 0x0 },
7436 { "Line", 0x2 },
7437 },
7438};
7439
7440static struct hda_input_mux alc889A_mb31_capture_source = {
7441 .num_items = 2,
7442 .items = {
7443 { "Mic", 0x0 },
7444 /* Front Mic (0x01) unused */
7445 { "Line", 0x2 },
7446 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007447 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007448 },
7449};
7450
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007451static struct hda_input_mux alc889A_imac91_capture_source = {
7452 .num_items = 2,
7453 .items = {
7454 { "Mic", 0x01 },
7455 { "Line", 0x2 }, /* Not sure! */
7456 },
7457};
7458
Takashi Iwai4953550a2009-06-30 15:28:30 +02007459/*
7460 * 2ch mode
7461 */
7462static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7463 { 2, NULL }
7464};
7465
Kailang Yangdf694da2005-12-05 19:42:22 +01007466/*
Kailang Yang272a5272007-05-14 11:00:38 +02007467 * 2ch mode
7468 */
7469static struct hda_verb alc882_3ST_ch2_init[] = {
7470 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7471 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7472 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7473 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7474 { } /* end */
7475};
7476
7477/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007478 * 4ch mode
7479 */
7480static struct hda_verb alc882_3ST_ch4_init[] = {
7481 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7482 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7483 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7484 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7485 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7486 { } /* end */
7487};
7488
7489/*
Kailang Yang272a5272007-05-14 11:00:38 +02007490 * 6ch mode
7491 */
7492static struct hda_verb alc882_3ST_ch6_init[] = {
7493 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7494 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7495 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7496 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7497 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7498 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7499 { } /* end */
7500};
7501
Takashi Iwai4953550a2009-06-30 15:28:30 +02007502static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007503 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007504 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007505 { 6, alc882_3ST_ch6_init },
7506};
7507
Takashi Iwai4953550a2009-06-30 15:28:30 +02007508#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7509
Kailang Yang272a5272007-05-14 11:00:38 +02007510/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307511 * 2ch mode
7512 */
7513static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7514 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7515 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7516 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7517 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7518 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7519 { } /* end */
7520};
7521
7522/*
7523 * 4ch mode
7524 */
7525static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7526 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7527 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7528 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7529 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7530 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7531 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7532 { } /* end */
7533};
7534
7535/*
7536 * 6ch mode
7537 */
7538static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7539 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7540 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7541 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7542 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7543 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7544 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7545 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7546 { } /* end */
7547};
7548
7549static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7550 { 2, alc883_3ST_ch2_clevo_init },
7551 { 4, alc883_3ST_ch4_clevo_init },
7552 { 6, alc883_3ST_ch6_clevo_init },
7553};
7554
7555
7556/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007557 * 6ch mode
7558 */
7559static struct hda_verb alc882_sixstack_ch6_init[] = {
7560 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7561 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7562 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7563 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7564 { } /* end */
7565};
7566
7567/*
7568 * 8ch mode
7569 */
7570static struct hda_verb alc882_sixstack_ch8_init[] = {
7571 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7572 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7573 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7574 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7575 { } /* end */
7576};
7577
7578static struct hda_channel_mode alc882_sixstack_modes[2] = {
7579 { 6, alc882_sixstack_ch6_init },
7580 { 8, alc882_sixstack_ch8_init },
7581};
7582
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007583
7584/* Macbook Air 2,1 */
7585
7586static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7587 { 2, NULL },
7588};
7589
Takashi Iwai87350ad2007-08-16 18:19:38 +02007590/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007591 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007592 */
7593
7594/*
7595 * 2ch mode
7596 */
7597static struct hda_verb alc885_mbp_ch2_init[] = {
7598 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7599 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7600 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7601 { } /* end */
7602};
7603
7604/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007605 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007606 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007607static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007608 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7609 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7610 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7611 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7612 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7613 { } /* end */
7614};
7615
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007616static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007617 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007618 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007619};
7620
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007621/*
7622 * 2ch
7623 * Speakers/Woofer/HP = Front
7624 * LineIn = Input
7625 */
7626static struct hda_verb alc885_mb5_ch2_init[] = {
7627 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7628 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7629 { } /* end */
7630};
7631
7632/*
7633 * 6ch mode
7634 * Speakers/HP = Front
7635 * Woofer = LFE
7636 * LineIn = Surround
7637 */
7638static struct hda_verb alc885_mb5_ch6_init[] = {
7639 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7640 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7641 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7642 { } /* end */
7643};
7644
7645static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7646 { 2, alc885_mb5_ch2_init },
7647 { 6, alc885_mb5_ch6_init },
7648};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007649
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007650#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007651
7652/*
7653 * 2ch mode
7654 */
7655static struct hda_verb alc883_4ST_ch2_init[] = {
7656 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7657 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7658 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7659 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7660 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7661 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7662 { } /* end */
7663};
7664
7665/*
7666 * 4ch mode
7667 */
7668static struct hda_verb alc883_4ST_ch4_init[] = {
7669 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7670 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7671 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7672 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7673 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7674 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7675 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7676 { } /* end */
7677};
7678
7679/*
7680 * 6ch mode
7681 */
7682static struct hda_verb alc883_4ST_ch6_init[] = {
7683 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7684 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7685 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7686 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7687 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7688 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7689 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7690 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7691 { } /* end */
7692};
7693
7694/*
7695 * 8ch mode
7696 */
7697static struct hda_verb alc883_4ST_ch8_init[] = {
7698 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7699 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7700 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7701 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7702 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7703 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7704 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7705 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7706 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7707 { } /* end */
7708};
7709
7710static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7711 { 2, alc883_4ST_ch2_init },
7712 { 4, alc883_4ST_ch4_init },
7713 { 6, alc883_4ST_ch6_init },
7714 { 8, alc883_4ST_ch8_init },
7715};
7716
7717
7718/*
7719 * 2ch mode
7720 */
7721static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7722 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7723 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7724 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7725 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7726 { } /* end */
7727};
7728
7729/*
7730 * 4ch mode
7731 */
7732static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7733 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7734 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7735 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7736 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7737 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7738 { } /* end */
7739};
7740
7741/*
7742 * 6ch mode
7743 */
7744static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7745 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7746 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7747 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7748 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7749 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7750 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7751 { } /* end */
7752};
7753
7754static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7755 { 2, alc883_3ST_ch2_intel_init },
7756 { 4, alc883_3ST_ch4_intel_init },
7757 { 6, alc883_3ST_ch6_intel_init },
7758};
7759
7760/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007761 * 2ch mode
7762 */
7763static struct hda_verb alc889_ch2_intel_init[] = {
7764 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7765 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7766 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7767 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7768 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7769 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7770 { } /* end */
7771};
7772
7773/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007774 * 6ch mode
7775 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007776static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007777 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7778 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7779 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7780 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7781 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007782 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7783 { } /* end */
7784};
7785
7786/*
7787 * 8ch mode
7788 */
7789static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007790 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7791 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7792 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7793 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7794 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007795 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7796 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007797 { } /* end */
7798};
7799
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007800static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7801 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007802 { 6, alc889_ch6_intel_init },
7803 { 8, alc889_ch8_intel_init },
7804};
7805
7806/*
7807 * 6ch mode
7808 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007809static struct hda_verb alc883_sixstack_ch6_init[] = {
7810 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7811 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7812 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7813 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7814 { } /* end */
7815};
7816
7817/*
7818 * 8ch mode
7819 */
7820static struct hda_verb alc883_sixstack_ch8_init[] = {
7821 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7822 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7823 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7824 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7825 { } /* end */
7826};
7827
7828static struct hda_channel_mode alc883_sixstack_modes[2] = {
7829 { 6, alc883_sixstack_ch6_init },
7830 { 8, alc883_sixstack_ch8_init },
7831};
7832
7833
Linus Torvalds1da177e2005-04-16 15:20:36 -07007834/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7835 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7836 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007837static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007838 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007839 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007840 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007841 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007842 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7843 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007844 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7845 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007846 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007847 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007848 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7849 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7850 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7851 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7852 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7853 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007854 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007855 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7856 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007857 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007858 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007859 { } /* end */
7860};
7861
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007862/* Macbook Air 2,1 same control for HP and internal Speaker */
7863
7864static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7865 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7866 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7867 { }
7868};
7869
7870
Takashi Iwai87350ad2007-08-16 18:19:38 +02007871static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007872 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7873 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7874 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7875 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7876 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007877 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7878 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007879 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7880 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007881 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007882 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7883 { } /* end */
7884};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007885
7886static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007887 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7888 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7889 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7890 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7891 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7892 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307893 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7894 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307895 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7896 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7898 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7899 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7900 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7901 { } /* end */
7902};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007903
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007904static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7905 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7906 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7907 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7908 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7909 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7910 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7911 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7912 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7913 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7914 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7915 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7916 { } /* end */
7917};
7918
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007919static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007920 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7921 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007922 { } /* end */
7923};
7924
7925
Kailang Yangbdd148a2007-05-08 15:19:08 +02007926static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7927 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7928 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7929 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7930 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7931 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7932 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7934 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7935 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007936 { } /* end */
7937};
7938
Kailang Yang272a5272007-05-14 11:00:38 +02007939static struct snd_kcontrol_new alc882_targa_mixer[] = {
7940 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7941 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7942 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7943 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7944 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7945 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7946 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7947 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7948 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007949 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007950 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7951 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007952 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007953 { } /* end */
7954};
7955
7956/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7957 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7958 */
7959static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7960 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7961 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7962 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7963 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7964 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7965 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7966 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7967 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7968 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7969 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7970 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7971 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007972 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007973 { } /* end */
7974};
7975
Takashi Iwai914759b2007-09-06 14:52:04 +02007976static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7977 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7978 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7979 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7980 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7981 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7982 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7983 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7984 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7985 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7986 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007987 { } /* end */
7988};
7989
Kailang Yangdf694da2005-12-05 19:42:22 +01007990static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7991 {
7992 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7993 .name = "Channel Mode",
7994 .info = alc_ch_mode_info,
7995 .get = alc_ch_mode_get,
7996 .put = alc_ch_mode_put,
7997 },
7998 { } /* end */
7999};
8000
Takashi Iwai4953550a2009-06-30 15:28:30 +02008001static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07008002 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008003 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8004 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008005 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008006 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8007 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008008 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008009 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8010 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008011 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008012 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8013 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008014
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008015 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008016 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008017 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008018 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008019 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008020 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008021 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008022 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008023 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008024 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008025 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008026 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008027 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008028 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008029 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008030 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008031 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008032 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008033 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8034 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008035 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008036 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8037 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008038 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008039 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8040 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8041 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8042 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8043 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008044 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008045 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008046
8047 /* FIXME: use matrix-type input source selection */
8048 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008049 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008050 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008051 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008052 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008053 /* ADC2: mute amp left and right */
8054 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008055 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008056 /* ADC3: mute amp left and right */
8057 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008058 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008059
8060 { }
8061};
8062
Takashi Iwai4953550a2009-06-30 15:28:30 +02008063static struct hda_verb alc882_adc1_init_verbs[] = {
8064 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8065 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8066 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8067 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8068 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8069 /* ADC1: mute amp left and right */
8070 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8071 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8072 { }
8073};
8074
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008075static struct hda_verb alc882_eapd_verbs[] = {
8076 /* change to EAPD mode */
8077 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008078 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008079 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008080};
8081
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008082static struct hda_verb alc889_eapd_verbs[] = {
8083 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8084 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8085 { }
8086};
8087
Wu Fengguang6732bd02009-07-30 09:19:14 +02008088static struct hda_verb alc_hp15_unsol_verbs[] = {
8089 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8090 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8091 {}
8092};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008093
8094static struct hda_verb alc885_init_verbs[] = {
8095 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008096 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8097 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008098 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008099 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8100 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008101 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008102 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8103 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008104 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008105 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8106 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008107
8108 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008109 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008110 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8111 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8112 /* Front Pin: output 0 (0x0c) */
8113 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8114 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8115 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8116 /* Rear Pin: output 1 (0x0d) */
8117 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8118 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8119 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8120 /* CLFE Pin: output 2 (0x0e) */
8121 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8122 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8123 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8124 /* Side Pin: output 3 (0x0f) */
8125 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8126 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8127 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8128 /* Mic (rear) pin: input vref at 80% */
8129 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8130 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8131 /* Front Mic pin: input vref at 80% */
8132 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8133 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8134 /* Line In pin: input */
8135 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8136 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8137
8138 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8139 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008140 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008141 /* Input mixer2 */
8142 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008143 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008144 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008145 /* ADC2: mute amp left and right */
8146 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8147 /* ADC3: mute amp left and right */
8148 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8149
8150 { }
8151};
8152
8153static struct hda_verb alc885_init_input_verbs[] = {
8154 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8155 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8156 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8157 { }
8158};
8159
8160
8161/* Unmute Selector 24h and set the default input to front mic */
8162static struct hda_verb alc889_init_input_verbs[] = {
8163 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8164 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8165 { }
8166};
8167
8168
Takashi Iwai4953550a2009-06-30 15:28:30 +02008169#define alc883_init_verbs alc882_base_init_verbs
8170
Tobin Davis9102cd12006-12-15 10:02:12 +01008171/* Mac Pro test */
8172static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8173 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8174 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8175 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8176 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8177 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008178 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008179 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8180 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008181 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008182 { } /* end */
8183};
8184
8185static struct hda_verb alc882_macpro_init_verbs[] = {
8186 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8187 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8188 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8189 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8190 /* Front Pin: output 0 (0x0c) */
8191 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8193 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8194 /* Front Mic pin: input vref at 80% */
8195 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8196 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8197 /* Speaker: output */
8198 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8199 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8200 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8201 /* Headphone output (output 0 - 0x0c) */
8202 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8203 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8204 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8205
8206 /* FIXME: use matrix-type input source selection */
8207 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8208 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8210 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8211 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8212 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8213 /* Input mixer2 */
8214 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8215 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8216 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8217 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8218 /* Input mixer3 */
8219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8220 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8221 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8222 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8223 /* ADC1: mute amp left and right */
8224 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8225 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8226 /* ADC2: mute amp left and right */
8227 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8228 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8229 /* ADC3: mute amp left and right */
8230 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8231 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8232
8233 { }
8234};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008235
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008236/* Macbook 5,1 */
8237static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008238 /* DACs */
8239 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8240 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8241 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8242 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008243 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008244 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8245 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8246 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008247 /* Surround mixer */
8248 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8249 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8250 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8251 /* LFE mixer */
8252 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8253 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8254 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8255 /* HP mixer */
8256 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8257 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8258 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8259 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008260 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8261 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008262 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8263 /* LFE Pin (0x0e) */
8264 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8265 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8266 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8267 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008268 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8269 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008270 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308271 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008272 /* Front Mic pin: input vref at 80% */
8273 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8274 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8275 /* Line In pin */
8276 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8277 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8278
Alex Murrayb8f171e2010-06-14 12:08:43 +09308279 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8280 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8281 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008282 { }
8283};
8284
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008285/* Macmini 3,1 */
8286static struct hda_verb alc885_macmini3_init_verbs[] = {
8287 /* DACs */
8288 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8289 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8290 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8291 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8292 /* Front mixer */
8293 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8294 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8295 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8296 /* Surround mixer */
8297 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8298 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8299 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8300 /* LFE mixer */
8301 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8302 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8303 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8304 /* HP mixer */
8305 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8306 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8307 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8308 /* Front Pin (0x0c) */
8309 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8310 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8311 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8312 /* LFE Pin (0x0e) */
8313 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8315 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8316 /* HP Pin (0x0f) */
8317 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8318 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8319 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8320 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8321 /* Line In pin */
8322 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8323 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8324
8325 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8326 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8327 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8328 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8329 { }
8330};
8331
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008332
8333static struct hda_verb alc885_mba21_init_verbs[] = {
8334 /*Internal and HP Speaker Mixer*/
8335 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8336 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8337 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8338 /*Internal Speaker Pin (0x0c)*/
8339 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8340 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8341 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8342 /* HP Pin: output 0 (0x0e) */
8343 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8344 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8345 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8346 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8347 /* Line in (is hp when jack connected)*/
8348 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8349 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8350
8351 { }
8352 };
8353
8354
Takashi Iwai87350ad2007-08-16 18:19:38 +02008355/* Macbook Pro rev3 */
8356static struct hda_verb alc885_mbp3_init_verbs[] = {
8357 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8358 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8359 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8360 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8361 /* Rear mixer */
8362 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8363 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8364 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008365 /* HP mixer */
8366 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8367 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8368 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008369 /* Front Pin: output 0 (0x0c) */
8370 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8371 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8372 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008373 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008374 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008375 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8376 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008377 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8378 /* Mic (rear) pin: input vref at 80% */
8379 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8380 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8381 /* Front Mic pin: input vref at 80% */
8382 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8383 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8384 /* Line In pin: use output 1 when in LineOut mode */
8385 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8386 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8387 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8388
8389 /* FIXME: use matrix-type input source selection */
8390 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8391 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8392 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8393 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8394 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8395 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8396 /* Input mixer2 */
8397 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8398 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8399 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8400 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8401 /* Input mixer3 */
8402 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8403 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8404 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8405 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8406 /* ADC1: mute amp left and right */
8407 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8408 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8409 /* ADC2: mute amp left and right */
8410 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8411 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8412 /* ADC3: mute amp left and right */
8413 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8414 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8415
8416 { }
8417};
8418
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008419/* iMac 9,1 */
8420static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008421 /* Internal Speaker Pin (0x0c) */
8422 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8423 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8424 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8425 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8426 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8427 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8428 /* HP Pin: Rear */
8429 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8430 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8431 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8432 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8433 /* Line in Rear */
8434 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8435 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8436 /* Front Mic pin: input vref at 80% */
8437 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8438 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008439 /* Rear mixer */
8440 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8441 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8442 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008443 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8444 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8445 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8446 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8447 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008448 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8449 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8450 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8451 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008452 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008453 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8454 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8455 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8456 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008457 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8460 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8461 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008462 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008463 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8464 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008465 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008466 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8467 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008468 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008469 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8470 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008471 { }
8472};
8473
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008474/* iMac 24 mixer. */
8475static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8476 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8477 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8478 { } /* end */
8479};
8480
8481/* iMac 24 init verbs. */
8482static struct hda_verb alc885_imac24_init_verbs[] = {
8483 /* Internal speakers: output 0 (0x0c) */
8484 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8485 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8486 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8487 /* Internal speakers: output 0 (0x0c) */
8488 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8489 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8490 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8491 /* Headphone: output 0 (0x0c) */
8492 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8493 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8494 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8495 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8496 /* Front Mic: input vref at 80% */
8497 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8498 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8499 { }
8500};
8501
8502/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008503static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008504{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008505 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008506
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008507 spec->autocfg.hp_pins[0] = 0x14;
8508 spec->autocfg.speaker_pins[0] = 0x18;
8509 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008510}
8511
Takashi Iwai9d54f082010-02-22 08:34:40 +01008512#define alc885_mb5_setup alc885_imac24_setup
8513#define alc885_macmini3_setup alc885_imac24_setup
8514
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008515/* Macbook Air 2,1 */
8516static void alc885_mba21_setup(struct hda_codec *codec)
8517{
8518 struct alc_spec *spec = codec->spec;
8519
8520 spec->autocfg.hp_pins[0] = 0x14;
8521 spec->autocfg.speaker_pins[0] = 0x18;
8522}
8523
8524
8525
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008526static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008527{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008528 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008529
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008530 spec->autocfg.hp_pins[0] = 0x15;
8531 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008532}
8533
Takashi Iwai9d54f082010-02-22 08:34:40 +01008534static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308535{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008536 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308537
Takashi Iwai9d54f082010-02-22 08:34:40 +01008538 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008539 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008540 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008541}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008542
Kailang Yang272a5272007-05-14 11:00:38 +02008543static struct hda_verb alc882_targa_verbs[] = {
8544 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8545 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8546
8547 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8548 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008549
Kailang Yang272a5272007-05-14 11:00:38 +02008550 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8551 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8552 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8553
8554 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008555 { } /* end */
8556};
8557
8558/* toggle speaker-output according to the hp-jack state */
8559static void alc882_targa_automute(struct hda_codec *codec)
8560{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008561 struct alc_spec *spec = codec->spec;
8562 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008563 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008564 spec->jack_present ? 1 : 3);
8565}
8566
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008567static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008568{
8569 struct alc_spec *spec = codec->spec;
8570
8571 spec->autocfg.hp_pins[0] = 0x14;
8572 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008573}
8574
8575static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8576{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008577 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008578 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008579}
8580
8581static struct hda_verb alc882_asus_a7j_verbs[] = {
8582 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8583 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8584
8585 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8586 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8587 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008588
Kailang Yang272a5272007-05-14 11:00:38 +02008589 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8590 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8591 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8592
8593 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8594 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8595 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8596 { } /* end */
8597};
8598
Takashi Iwai914759b2007-09-06 14:52:04 +02008599static struct hda_verb alc882_asus_a7m_verbs[] = {
8600 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8601 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8602
8603 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8604 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8605 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008606
Takashi Iwai914759b2007-09-06 14:52:04 +02008607 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8608 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8609 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8610
8611 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8612 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8613 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8614 { } /* end */
8615};
8616
Tobin Davis9102cd12006-12-15 10:02:12 +01008617static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8618{
8619 unsigned int gpiostate, gpiomask, gpiodir;
8620
8621 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8622 AC_VERB_GET_GPIO_DATA, 0);
8623
8624 if (!muted)
8625 gpiostate |= (1 << pin);
8626 else
8627 gpiostate &= ~(1 << pin);
8628
8629 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8630 AC_VERB_GET_GPIO_MASK, 0);
8631 gpiomask |= (1 << pin);
8632
8633 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8634 AC_VERB_GET_GPIO_DIRECTION, 0);
8635 gpiodir |= (1 << pin);
8636
8637
8638 snd_hda_codec_write(codec, codec->afg, 0,
8639 AC_VERB_SET_GPIO_MASK, gpiomask);
8640 snd_hda_codec_write(codec, codec->afg, 0,
8641 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8642
8643 msleep(1);
8644
8645 snd_hda_codec_write(codec, codec->afg, 0,
8646 AC_VERB_SET_GPIO_DATA, gpiostate);
8647}
8648
Takashi Iwai7debbe52007-08-16 15:01:03 +02008649/* set up GPIO at initialization */
8650static void alc885_macpro_init_hook(struct hda_codec *codec)
8651{
8652 alc882_gpio_mute(codec, 0, 0);
8653 alc882_gpio_mute(codec, 1, 0);
8654}
8655
8656/* set up GPIO and update auto-muting at initialization */
8657static void alc885_imac24_init_hook(struct hda_codec *codec)
8658{
8659 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008660 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008661}
8662
Kailang Yangdf694da2005-12-05 19:42:22 +01008663/*
8664 * generic initialization of ADC, input mixers and output mixers
8665 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008666static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008667 /*
8668 * Unmute ADC0-2 and set the default input to mic-in
8669 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008670 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8671 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8672 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8673 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8674
Kailang Yangdf694da2005-12-05 19:42:22 +01008675 /*
8676 * Set up output mixers (0x0c - 0x0f)
8677 */
8678 /* set vol=0 to output mixers */
8679 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8680 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8681 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8682 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8683 /* set up input amps for analog loopback */
8684 /* Amp Indices: DAC = 0, mixer = 1 */
8685 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8686 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8687 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8688 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8689 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8690 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8691 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8692 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8693 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8694 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8695
8696 /* FIXME: use matrix-type input source selection */
8697 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008698 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008699 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008700 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008701 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008702 { }
8703};
8704
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008705/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8706static struct hda_verb alc889A_mb31_ch2_init[] = {
8707 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8708 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8709 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8710 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8711 { } /* end */
8712};
8713
8714/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8715static struct hda_verb alc889A_mb31_ch4_init[] = {
8716 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8717 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8718 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8719 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8720 { } /* end */
8721};
8722
8723/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8724static struct hda_verb alc889A_mb31_ch5_init[] = {
8725 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8726 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8727 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8728 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8729 { } /* end */
8730};
8731
8732/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8733static struct hda_verb alc889A_mb31_ch6_init[] = {
8734 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8735 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8736 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8737 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8738 { } /* end */
8739};
8740
8741static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8742 { 2, alc889A_mb31_ch2_init },
8743 { 4, alc889A_mb31_ch4_init },
8744 { 5, alc889A_mb31_ch5_init },
8745 { 6, alc889A_mb31_ch6_init },
8746};
8747
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008748static struct hda_verb alc883_medion_eapd_verbs[] = {
8749 /* eanable EAPD on medion laptop */
8750 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8751 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8752 { }
8753};
8754
Takashi Iwai4953550a2009-06-30 15:28:30 +02008755#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008756
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008757static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8758 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8759 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8760 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8761 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8762 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8763 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8764 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8765 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8766 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8767 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8768 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8769 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8770 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008771 { } /* end */
8772};
8773
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008774static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008775 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8776 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8777 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8778 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8779 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8780 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8781 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8782 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8783 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8784 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008785 { } /* end */
8786};
8787
Jiang zhefb97dc62008-03-06 11:07:11 +01008788static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8789 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8790 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8791 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8792 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8793 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8794 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8795 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8796 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8797 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8798 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008799 { } /* end */
8800};
8801
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008802static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8803 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8804 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8805 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8806 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8807 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8808 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8809 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008811 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008812 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8813 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008814 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008815 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008816 { } /* end */
8817};
8818
8819static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8820 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8821 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8822 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8823 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8824 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8825 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8826 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8827 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8828 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8829 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8830 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8831 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8832 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008834 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008835 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8836 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008837 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008838 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008839 { } /* end */
8840};
8841
Jiang zhe17bba1b2008-06-04 12:11:07 +02008842static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8843 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8844 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8845 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8846 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8847 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8848 HDA_OUTPUT),
8849 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8850 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8851 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8852 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8853 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8854 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8855 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8856 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8857 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8858 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8859 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8860 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8861 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8862 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008863 { } /* end */
8864};
8865
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008866static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8867 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8868 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8869 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8870 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8871 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8872 HDA_OUTPUT),
8873 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8874 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8875 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8876 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8877 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8878 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8879 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8880 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8881 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8882 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8883 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8884 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8885 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8886 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8887 { } /* end */
8888};
8889
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008890static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008891 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008892 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008893 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008894 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008895 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8896 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008897 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8898 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008899 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8900 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8901 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8902 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8903 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8904 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008905 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008906 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8907 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008908 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008909 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008910 { } /* end */
8911};
8912
Sasha Alexandrc2592492009-06-16 14:52:54 -04008913static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008914 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008915 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008916 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008917 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008918 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8919 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8920 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8921 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8922 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8923 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8924 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8925 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8926 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8927 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8928 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008929 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008930 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008931 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008932};
Kailang Yangccc656c2006-10-17 12:32:26 +02008933
Sasha Alexandrc2592492009-06-16 14:52:54 -04008934static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008935 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008936 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008937 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008938 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008939 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8940 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8941 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008942 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008943 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008944 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8945 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8946 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008947 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008948};
Kailang Yangccc656c2006-10-17 12:32:26 +02008949
Takashi Iwaib99dba32009-09-17 18:23:00 +02008950static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8951 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8952 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8953 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8954 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8955 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8956 { } /* end */
8957};
8958
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008959static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8960 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8961 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008962 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8963 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008964 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8965 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8966 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8967 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008968 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008969};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008970
Kailang Yang272a5272007-05-14 11:00:38 +02008971static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8972 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8973 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8974 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8975 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8976 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8977 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8978 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson150b4322010-07-29 14:46:42 +02008979 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8980 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008981 { } /* end */
8982};
8983
8984static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8985 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8986 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8987 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8988 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8989 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8990 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8991 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8992 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8993 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008994 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008995};
Kailang Yang272a5272007-05-14 11:00:38 +02008996
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02008997static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
8998 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8999 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9000 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9001 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
9002 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
9003 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
9004 { } /* end */
9005};
9006
9007static struct hda_verb alc883_medion_wim2160_verbs[] = {
9008 /* Unmute front mixer */
9009 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9010 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9011
9012 /* Set speaker pin to front mixer */
9013 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9014
9015 /* Init headphone pin */
9016 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9017 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9018 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9019 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9020
9021 { } /* end */
9022};
9023
9024/* toggle speaker-output according to the hp-jack state */
9025static void alc883_medion_wim2160_setup(struct hda_codec *codec)
9026{
9027 struct alc_spec *spec = codec->spec;
9028
9029 spec->autocfg.hp_pins[0] = 0x1a;
9030 spec->autocfg.speaker_pins[0] = 0x15;
9031}
9032
Tobin Davis2880a862007-08-07 11:50:26 +02009033static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009034 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9035 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009036 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009037 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9038 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009039 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9040 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9041 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009042 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009043};
Tobin Davis2880a862007-08-07 11:50:26 +02009044
Tony Vroond2fd4b02009-06-21 00:40:10 +01009045static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
9046 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009047 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009048 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9049 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009050 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9051 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9052 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9053 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9054 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9055 { } /* end */
9056};
9057
Kailang Yange2757d52008-08-26 13:17:46 +02009058static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
9059 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9060 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9061 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9062 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9063 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9064 0x0d, 1, 0x0, HDA_OUTPUT),
9065 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9066 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9067 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9068 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9069 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009070 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9071 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9072 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9073 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9074 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9075 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9076 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9077 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9078 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9079 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009080 { } /* end */
9081};
9082
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009083static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9084 /* Output mixers */
9085 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9086 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9087 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9088 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9089 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9090 HDA_OUTPUT),
9091 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9092 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9093 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9094 /* Output switches */
9095 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9096 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9097 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9098 /* Boost mixers */
9099 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
9100 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
9101 /* Input mixers */
9102 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9103 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9104 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9105 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9106 { } /* end */
9107};
9108
Guido Günther3e1647c2009-06-05 00:47:26 +02009109static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9110 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9111 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9112 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9113 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9114 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
9115 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9116 { } /* end */
9117};
9118
Kailang Yange2757d52008-08-26 13:17:46 +02009119static struct hda_bind_ctls alc883_bind_cap_vol = {
9120 .ops = &snd_hda_bind_vol,
9121 .values = {
9122 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9123 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9124 0
9125 },
9126};
9127
9128static struct hda_bind_ctls alc883_bind_cap_switch = {
9129 .ops = &snd_hda_bind_sw,
9130 .values = {
9131 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9132 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9133 0
9134 },
9135};
9136
9137static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9138 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9139 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9140 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9141 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9142 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9143 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9144 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9145 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009146 { } /* end */
9147};
9148
9149static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009150 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9151 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9152 {
9153 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9154 /* .name = "Capture Source", */
9155 .name = "Input Source",
9156 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009157 .info = alc_mux_enum_info,
9158 .get = alc_mux_enum_get,
9159 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009160 },
9161 { } /* end */
9162};
9163
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009164static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9165 {
9166 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9167 .name = "Channel Mode",
9168 .info = alc_ch_mode_info,
9169 .get = alc_ch_mode_get,
9170 .put = alc_ch_mode_put,
9171 },
9172 { } /* end */
9173};
9174
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009175/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009176static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009177{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009178 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009179
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009180 spec->autocfg.hp_pins[0] = 0x15;
9181 spec->autocfg.speaker_pins[0] = 0x14;
9182 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009183}
9184
9185/* auto-toggle front mic */
9186/*
9187static void alc883_mitac_mic_automute(struct hda_codec *codec)
9188{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009189 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009190
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009191 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
9192}
9193*/
9194
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009195static struct hda_verb alc883_mitac_verbs[] = {
9196 /* HP */
9197 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9198 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9199 /* Subwoofer */
9200 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9201 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9202
9203 /* enable unsolicited event */
9204 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9205 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9206
9207 { } /* end */
9208};
9209
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309210static struct hda_verb alc883_clevo_m540r_verbs[] = {
9211 /* HP */
9212 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9213 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9214 /* Int speaker */
9215 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9216
9217 /* enable unsolicited event */
9218 /*
9219 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9220 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9221 */
9222
9223 { } /* end */
9224};
9225
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009226static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009227 /* HP */
9228 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9229 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9230 /* Int speaker */
9231 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9232 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9233
9234 /* enable unsolicited event */
9235 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009236 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009237
9238 { } /* end */
9239};
9240
Jiang zhefb97dc62008-03-06 11:07:11 +01009241static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9242 /* HP */
9243 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9244 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9245 /* Subwoofer */
9246 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9247 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9248
9249 /* enable unsolicited event */
9250 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9251
9252 { } /* end */
9253};
9254
Sasha Alexandrc2592492009-06-16 14:52:54 -04009255static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009256 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9258
9259 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9260 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009261
David Heidelberger64a8be72009-06-08 16:15:18 +02009262/* Connect Line-Out side jack (SPDIF) to Side */
9263 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9264 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9265 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9266/* Connect Mic jack to CLFE */
9267 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9268 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9269 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9270/* Connect Line-in jack to Surround */
9271 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9272 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9273 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9274/* Connect HP out jack to Front */
9275 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9276 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9277 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009278
9279 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009280
9281 { } /* end */
9282};
9283
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009284static struct hda_verb alc883_lenovo_101e_verbs[] = {
9285 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9286 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9287 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9288 { } /* end */
9289};
9290
Kailang Yang272a5272007-05-14 11:00:38 +02009291static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9292 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9293 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9294 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9295 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9296 { } /* end */
9297};
9298
9299static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9300 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9301 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9302 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9303 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9304 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9305 { } /* end */
9306};
9307
Kailang Yang189609a2007-08-20 11:31:23 +02009308static struct hda_verb alc883_haier_w66_verbs[] = {
9309 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9311
9312 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9313
9314 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9315 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9316 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9317 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9318 { } /* end */
9319};
9320
Kailang Yange2757d52008-08-26 13:17:46 +02009321static struct hda_verb alc888_lenovo_sky_verbs[] = {
9322 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9324 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9326 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9327 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9328 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9329 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9330 { } /* end */
9331};
9332
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009333static struct hda_verb alc888_6st_dell_verbs[] = {
9334 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9335 { }
9336};
9337
Guido Günther3e1647c2009-06-05 00:47:26 +02009338static struct hda_verb alc883_vaiott_verbs[] = {
9339 /* HP */
9340 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9341 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9342
9343 /* enable unsolicited event */
9344 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9345
9346 { } /* end */
9347};
9348
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009349static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009350{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009351 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009352
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009353 spec->autocfg.hp_pins[0] = 0x1b;
9354 spec->autocfg.speaker_pins[0] = 0x14;
9355 spec->autocfg.speaker_pins[1] = 0x16;
9356 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009357}
9358
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009359static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009360 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009361 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9362 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009363 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009364 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009365};
9366
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009367/*
9368 * 2ch mode
9369 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009370static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009371 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9372 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9373 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9374 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009375 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009376};
9377
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009378/*
9379 * 4ch mode
9380 */
9381static struct hda_verb alc888_3st_hp_4ch_init[] = {
9382 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9383 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9384 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9385 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9386 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9387 { } /* end */
9388};
9389
9390/*
9391 * 6ch mode
9392 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009393static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009394 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9395 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009396 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009397 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9398 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009399 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9400 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009401};
9402
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009403static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009404 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009405 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009406 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009407};
9408
Kailang Yang272a5272007-05-14 11:00:38 +02009409/* toggle front-jack and RCA according to the hp-jack state */
9410static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9411{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009412 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009413
Takashi Iwai47fd8302007-08-10 17:11:07 +02009414 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9415 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9416 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9417 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009418}
9419
9420/* toggle RCA according to the front-jack state */
9421static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9422{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009423 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009424
Takashi Iwai47fd8302007-08-10 17:11:07 +02009425 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9426 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009427}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009428
Kailang Yang272a5272007-05-14 11:00:38 +02009429static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9430 unsigned int res)
9431{
9432 if ((res >> 26) == ALC880_HP_EVENT)
9433 alc888_lenovo_ms7195_front_automute(codec);
9434 if ((res >> 26) == ALC880_FRONT_EVENT)
9435 alc888_lenovo_ms7195_rca_automute(codec);
9436}
9437
9438static struct hda_verb alc883_medion_md2_verbs[] = {
9439 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9440 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9441
9442 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9443
9444 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9445 { } /* end */
9446};
9447
9448/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009449static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009450{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009451 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009452
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009453 spec->autocfg.hp_pins[0] = 0x14;
9454 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009455}
9456
Kailang Yangccc656c2006-10-17 12:32:26 +02009457/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009458#define alc883_targa_init_hook alc882_targa_init_hook
9459#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009460
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009461static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
9462{
9463 unsigned int present;
9464
Takashi Iwaid56757a2009-11-18 08:00:14 +01009465 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009466 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
9467 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9468}
9469
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009470static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009471{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009472 struct alc_spec *spec = codec->spec;
9473
9474 spec->autocfg.hp_pins[0] = 0x15;
9475 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009476}
9477
9478static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9479{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009480 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009481 alc883_clevo_m720_mic_automute(codec);
9482}
9483
9484static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009485 unsigned int res)
9486{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009487 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009488 case ALC880_MIC_EVENT:
9489 alc883_clevo_m720_mic_automute(codec);
9490 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009491 default:
9492 alc_automute_amp_unsol_event(codec, res);
9493 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009494 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009495}
9496
Jiang zhefb97dc62008-03-06 11:07:11 +01009497/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009498static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009499{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009500 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009501
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009502 spec->autocfg.hp_pins[0] = 0x14;
9503 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009504}
9505
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009506static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009507{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009508 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009509
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009510 spec->autocfg.hp_pins[0] = 0x1b;
9511 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009512}
9513
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009514static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9515{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009516 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009517
Takashi Iwai47fd8302007-08-10 17:11:07 +02009518 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9519 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009520}
9521
9522static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9523{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009524 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009525
Takashi Iwai47fd8302007-08-10 17:11:07 +02009526 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9527 HDA_AMP_MUTE, bits);
9528 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9529 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009530}
9531
9532static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9533 unsigned int res)
9534{
9535 if ((res >> 26) == ALC880_HP_EVENT)
9536 alc883_lenovo_101e_all_automute(codec);
9537 if ((res >> 26) == ALC880_FRONT_EVENT)
9538 alc883_lenovo_101e_ispeaker_automute(codec);
9539}
9540
Takashi Iwai676a9b52007-08-16 15:23:35 +02009541/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009542static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009543{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009544 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009545
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009546 spec->autocfg.hp_pins[0] = 0x14;
9547 spec->autocfg.speaker_pins[0] = 0x15;
9548 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009549}
9550
Kailang Yangd1a991a2007-08-15 16:21:59 +02009551static struct hda_verb alc883_acer_eapd_verbs[] = {
9552 /* HP Pin: output 0 (0x0c) */
9553 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9554 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9555 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9556 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009557 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9558 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009559 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009560 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9561 /* eanable EAPD on medion laptop */
9562 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9563 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009564 /* enable unsolicited event */
9565 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009566 { }
9567};
9568
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009569static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009570{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009571 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009572
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009573 spec->autocfg.hp_pins[0] = 0x1b;
9574 spec->autocfg.speaker_pins[0] = 0x14;
9575 spec->autocfg.speaker_pins[1] = 0x15;
9576 spec->autocfg.speaker_pins[2] = 0x16;
9577 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009578}
9579
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009580static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009581{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009582 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009583
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009584 spec->autocfg.hp_pins[0] = 0x1b;
9585 spec->autocfg.speaker_pins[0] = 0x14;
9586 spec->autocfg.speaker_pins[1] = 0x15;
9587 spec->autocfg.speaker_pins[2] = 0x16;
9588 spec->autocfg.speaker_pins[3] = 0x17;
9589 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009590}
9591
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009592static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009593{
9594 struct alc_spec *spec = codec->spec;
9595
9596 spec->autocfg.hp_pins[0] = 0x15;
9597 spec->autocfg.speaker_pins[0] = 0x14;
9598 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009599}
9600
Kailang Yange2757d52008-08-26 13:17:46 +02009601static struct hda_verb alc888_asus_m90v_verbs[] = {
9602 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9603 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9604 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9605 /* enable unsolicited event */
9606 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9607 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9608 { } /* end */
9609};
9610
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009611static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009612{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009613 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009614
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009615 spec->autocfg.hp_pins[0] = 0x1b;
9616 spec->autocfg.speaker_pins[0] = 0x14;
9617 spec->autocfg.speaker_pins[1] = 0x15;
9618 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009619 spec->ext_mic.pin = 0x18;
9620 spec->int_mic.pin = 0x19;
9621 spec->ext_mic.mux_idx = 0;
9622 spec->int_mic.mux_idx = 1;
9623 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009624}
9625
9626static struct hda_verb alc888_asus_eee1601_verbs[] = {
9627 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9628 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9629 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9630 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9631 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9632 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9633 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9634 /* enable unsolicited event */
9635 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9636 { } /* end */
9637};
9638
Kailang Yange2757d52008-08-26 13:17:46 +02009639static void alc883_eee1601_inithook(struct hda_codec *codec)
9640{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009641 struct alc_spec *spec = codec->spec;
9642
9643 spec->autocfg.hp_pins[0] = 0x14;
9644 spec->autocfg.speaker_pins[0] = 0x1b;
9645 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009646}
9647
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009648static struct hda_verb alc889A_mb31_verbs[] = {
9649 /* Init rear pin (used as headphone output) */
9650 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9651 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9652 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9653 /* Init line pin (used as output in 4ch and 6ch mode) */
9654 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9655 /* Init line 2 pin (used as headphone out by default) */
9656 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9657 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9658 { } /* end */
9659};
9660
9661/* Mute speakers according to the headphone jack state */
9662static void alc889A_mb31_automute(struct hda_codec *codec)
9663{
9664 unsigned int present;
9665
9666 /* Mute only in 2ch or 4ch mode */
9667 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9668 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009669 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009670 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9671 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9672 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9673 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9674 }
9675}
9676
9677static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9678{
9679 if ((res >> 26) == ALC880_HP_EVENT)
9680 alc889A_mb31_automute(codec);
9681}
9682
Takashi Iwai4953550a2009-06-30 15:28:30 +02009683
Takashi Iwaicb53c622007-08-10 17:21:45 +02009684#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009685#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009686#endif
9687
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009688/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009689#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9690#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9691#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9692#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9693
9694static hda_nid_t alc883_slave_dig_outs[] = {
9695 ALC1200_DIGOUT_NID, 0,
9696};
9697
9698static hda_nid_t alc1200_slave_dig_outs[] = {
9699 ALC883_DIGOUT_NID, 0,
9700};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009701
9702/*
9703 * configuration and preset
9704 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009705static const char *alc882_models[ALC882_MODEL_LAST] = {
9706 [ALC882_3ST_DIG] = "3stack-dig",
9707 [ALC882_6ST_DIG] = "6stack-dig",
9708 [ALC882_ARIMA] = "arima",
9709 [ALC882_W2JC] = "w2jc",
9710 [ALC882_TARGA] = "targa",
9711 [ALC882_ASUS_A7J] = "asus-a7j",
9712 [ALC882_ASUS_A7M] = "asus-a7m",
9713 [ALC885_MACPRO] = "macpro",
9714 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009715 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009716 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009717 [ALC885_MBP3] = "mbp3",
9718 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009719 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009720 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009721 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9722 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009723 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009724 [ALC883_TARGA_DIG] = "targa-dig",
9725 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009726 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009727 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009728 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009729 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009730 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009731 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009732 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009733 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009734 [ALC883_MEDION_MD2] = "medion-md2",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009735 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009736 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009737 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009738 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9739 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009740 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009741 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009742 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009743 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009744 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309745 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009746 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009747 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009748 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009749 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009750 [ALC889A_INTEL] = "intel-alc889a",
9751 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009752 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009753 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009754 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009755 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009756};
9757
Takashi Iwai4953550a2009-06-30 15:28:30 +02009758static struct snd_pci_quirk alc882_cfg_tbl[] = {
9759 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9760
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009761 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009762 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009763 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009764 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9765 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009766 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009767 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9768 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009769 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009770 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009771 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9772 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009773 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9774 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009775 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9776 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009777 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009778 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009779 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009780 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009781 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9782 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009783 /* default Acer -- disabled as it causes more problems.
9784 * model=auto should work fine now
9785 */
9786 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009787
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009788 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009789
Tobin Davisfebe3372007-06-12 11:27:46 +02009790 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009791 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9792 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009793 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009794 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009795 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009796
9797 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9798 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9799 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009800 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009801 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9802 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9803 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009804 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009805 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009806 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009807 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009808
9809 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009810 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009811 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009812 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009813 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9814 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009815 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009816 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009817 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9818
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009819 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9820 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9821 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009822 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009823 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009824 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009825 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009826 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009827 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9828 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9829 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9830 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9831 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9832 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009833 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009834 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9835 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9836 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009837 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009838 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009839 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9840 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009841 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009842 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009843 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009844 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009845 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009846 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009847 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009848 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009849 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009850
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009851 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009852 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009853 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9854 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309855 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009856 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009857 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009858 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009859 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009860 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009861 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009862 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009863 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009864 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009865 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009866 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9867 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009868 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Takashi Iwai959973b2008-11-05 11:30:56 +01009869 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009870 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009871 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009872
Jiang zhe17bba1b2008-06-04 12:11:07 +02009873 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9874 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009875 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009876 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9877 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9878 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009879 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009880
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009881 {}
9882};
9883
Takashi Iwai4953550a2009-06-30 15:28:30 +02009884/* codec SSID table for Intel Mac */
9885static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9886 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9887 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9888 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9889 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9890 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9891 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9892 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009893 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009894 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009895 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009896 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009897 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9898 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9899 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009900 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009901 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009902 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009903 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9904 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009905 */
9906 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009907 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009908 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009909 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009910};
9911
Takashi Iwai4953550a2009-06-30 15:28:30 +02009912static struct alc_config_preset alc882_presets[] = {
9913 [ALC882_3ST_DIG] = {
9914 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009915 .init_verbs = { alc882_base_init_verbs,
9916 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009917 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9918 .dac_nids = alc882_dac_nids,
9919 .dig_out_nid = ALC882_DIGOUT_NID,
9920 .dig_in_nid = ALC882_DIGIN_NID,
9921 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9922 .channel_mode = alc882_ch_modes,
9923 .need_dac_fix = 1,
9924 .input_mux = &alc882_capture_source,
9925 },
9926 [ALC882_6ST_DIG] = {
9927 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009928 .init_verbs = { alc882_base_init_verbs,
9929 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009930 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9931 .dac_nids = alc882_dac_nids,
9932 .dig_out_nid = ALC882_DIGOUT_NID,
9933 .dig_in_nid = ALC882_DIGIN_NID,
9934 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9935 .channel_mode = alc882_sixstack_modes,
9936 .input_mux = &alc882_capture_source,
9937 },
9938 [ALC882_ARIMA] = {
9939 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009940 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9941 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009942 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9943 .dac_nids = alc882_dac_nids,
9944 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9945 .channel_mode = alc882_sixstack_modes,
9946 .input_mux = &alc882_capture_source,
9947 },
9948 [ALC882_W2JC] = {
9949 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009950 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9951 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009952 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9953 .dac_nids = alc882_dac_nids,
9954 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9955 .channel_mode = alc880_threestack_modes,
9956 .need_dac_fix = 1,
9957 .input_mux = &alc882_capture_source,
9958 .dig_out_nid = ALC882_DIGOUT_NID,
9959 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009960 [ALC885_MBA21] = {
9961 .mixers = { alc885_mba21_mixer },
9962 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9963 .num_dacs = 2,
9964 .dac_nids = alc882_dac_nids,
9965 .channel_mode = alc885_mba21_ch_modes,
9966 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9967 .input_mux = &alc882_capture_source,
9968 .unsol_event = alc_automute_amp_unsol_event,
9969 .setup = alc885_mba21_setup,
9970 .init_hook = alc_automute_amp,
9971 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009972 [ALC885_MBP3] = {
9973 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9974 .init_verbs = { alc885_mbp3_init_verbs,
9975 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009976 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009977 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009978 .hp_nid = 0x04,
9979 .channel_mode = alc885_mbp_4ch_modes,
9980 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009981 .input_mux = &alc882_capture_source,
9982 .dig_out_nid = ALC882_DIGOUT_NID,
9983 .dig_in_nid = ALC882_DIGIN_NID,
9984 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009985 .setup = alc885_mbp3_setup,
9986 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009987 },
9988 [ALC885_MB5] = {
9989 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9990 .init_verbs = { alc885_mb5_init_verbs,
9991 alc880_gpio1_init_verbs },
9992 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9993 .dac_nids = alc882_dac_nids,
9994 .channel_mode = alc885_mb5_6ch_modes,
9995 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9996 .input_mux = &mb5_capture_source,
9997 .dig_out_nid = ALC882_DIGOUT_NID,
9998 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009999 .unsol_event = alc_automute_amp_unsol_event,
10000 .setup = alc885_mb5_setup,
10001 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010002 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010003 [ALC885_MACMINI3] = {
10004 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
10005 .init_verbs = { alc885_macmini3_init_verbs,
10006 alc880_gpio1_init_verbs },
10007 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10008 .dac_nids = alc882_dac_nids,
10009 .channel_mode = alc885_macmini3_6ch_modes,
10010 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
10011 .input_mux = &macmini3_capture_source,
10012 .dig_out_nid = ALC882_DIGOUT_NID,
10013 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010014 .unsol_event = alc_automute_amp_unsol_event,
10015 .setup = alc885_macmini3_setup,
10016 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010017 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010018 [ALC885_MACPRO] = {
10019 .mixers = { alc882_macpro_mixer },
10020 .init_verbs = { alc882_macpro_init_verbs },
10021 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10022 .dac_nids = alc882_dac_nids,
10023 .dig_out_nid = ALC882_DIGOUT_NID,
10024 .dig_in_nid = ALC882_DIGIN_NID,
10025 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10026 .channel_mode = alc882_ch_modes,
10027 .input_mux = &alc882_capture_source,
10028 .init_hook = alc885_macpro_init_hook,
10029 },
10030 [ALC885_IMAC24] = {
10031 .mixers = { alc885_imac24_mixer },
10032 .init_verbs = { alc885_imac24_init_verbs },
10033 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10034 .dac_nids = alc882_dac_nids,
10035 .dig_out_nid = ALC882_DIGOUT_NID,
10036 .dig_in_nid = ALC882_DIGIN_NID,
10037 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10038 .channel_mode = alc882_ch_modes,
10039 .input_mux = &alc882_capture_source,
10040 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010041 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010042 .init_hook = alc885_imac24_init_hook,
10043 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010044 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010045 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010046 .init_verbs = { alc885_imac91_init_verbs,
10047 alc880_gpio1_init_verbs },
10048 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10049 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010050 .channel_mode = alc885_mba21_ch_modes,
10051 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10052 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010053 .dig_out_nid = ALC882_DIGOUT_NID,
10054 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010055 .unsol_event = alc_automute_amp_unsol_event,
10056 .setup = alc885_imac91_setup,
10057 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010058 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010059 [ALC882_TARGA] = {
10060 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010061 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010062 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010063 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10064 .dac_nids = alc882_dac_nids,
10065 .dig_out_nid = ALC882_DIGOUT_NID,
10066 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10067 .adc_nids = alc882_adc_nids,
10068 .capsrc_nids = alc882_capsrc_nids,
10069 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10070 .channel_mode = alc882_3ST_6ch_modes,
10071 .need_dac_fix = 1,
10072 .input_mux = &alc882_capture_source,
10073 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010074 .setup = alc882_targa_setup,
10075 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010076 },
10077 [ALC882_ASUS_A7J] = {
10078 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010079 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10080 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010081 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10082 .dac_nids = alc882_dac_nids,
10083 .dig_out_nid = ALC882_DIGOUT_NID,
10084 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10085 .adc_nids = alc882_adc_nids,
10086 .capsrc_nids = alc882_capsrc_nids,
10087 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10088 .channel_mode = alc882_3ST_6ch_modes,
10089 .need_dac_fix = 1,
10090 .input_mux = &alc882_capture_source,
10091 },
10092 [ALC882_ASUS_A7M] = {
10093 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010094 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10095 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010096 alc882_asus_a7m_verbs },
10097 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10098 .dac_nids = alc882_dac_nids,
10099 .dig_out_nid = ALC882_DIGOUT_NID,
10100 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10101 .channel_mode = alc880_threestack_modes,
10102 .need_dac_fix = 1,
10103 .input_mux = &alc882_capture_source,
10104 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010105 [ALC883_3ST_2ch_DIG] = {
10106 .mixers = { alc883_3ST_2ch_mixer },
10107 .init_verbs = { alc883_init_verbs },
10108 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10109 .dac_nids = alc883_dac_nids,
10110 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010111 .dig_in_nid = ALC883_DIGIN_NID,
10112 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10113 .channel_mode = alc883_3ST_2ch_modes,
10114 .input_mux = &alc883_capture_source,
10115 },
10116 [ALC883_3ST_6ch_DIG] = {
10117 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10118 .init_verbs = { alc883_init_verbs },
10119 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10120 .dac_nids = alc883_dac_nids,
10121 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010122 .dig_in_nid = ALC883_DIGIN_NID,
10123 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10124 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010125 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010126 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010127 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010128 [ALC883_3ST_6ch] = {
10129 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10130 .init_verbs = { alc883_init_verbs },
10131 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10132 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010133 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10134 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010135 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010136 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010137 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010138 [ALC883_3ST_6ch_INTEL] = {
10139 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10140 .init_verbs = { alc883_init_verbs },
10141 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10142 .dac_nids = alc883_dac_nids,
10143 .dig_out_nid = ALC883_DIGOUT_NID,
10144 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010145 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010146 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10147 .channel_mode = alc883_3ST_6ch_intel_modes,
10148 .need_dac_fix = 1,
10149 .input_mux = &alc883_3stack_6ch_intel,
10150 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010151 [ALC889A_INTEL] = {
10152 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010153 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10154 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010155 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10156 .dac_nids = alc883_dac_nids,
10157 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10158 .adc_nids = alc889_adc_nids,
10159 .dig_out_nid = ALC883_DIGOUT_NID,
10160 .dig_in_nid = ALC883_DIGIN_NID,
10161 .slave_dig_outs = alc883_slave_dig_outs,
10162 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10163 .channel_mode = alc889_8ch_intel_modes,
10164 .capsrc_nids = alc889_capsrc_nids,
10165 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010166 .setup = alc889_automute_setup,
10167 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010168 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010169 .need_dac_fix = 1,
10170 },
10171 [ALC889_INTEL] = {
10172 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10173 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010174 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010175 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10176 .dac_nids = alc883_dac_nids,
10177 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10178 .adc_nids = alc889_adc_nids,
10179 .dig_out_nid = ALC883_DIGOUT_NID,
10180 .dig_in_nid = ALC883_DIGIN_NID,
10181 .slave_dig_outs = alc883_slave_dig_outs,
10182 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10183 .channel_mode = alc889_8ch_intel_modes,
10184 .capsrc_nids = alc889_capsrc_nids,
10185 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010186 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010187 .init_hook = alc889_intel_init_hook,
10188 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010189 .need_dac_fix = 1,
10190 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010191 [ALC883_6ST_DIG] = {
10192 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10193 .init_verbs = { alc883_init_verbs },
10194 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10195 .dac_nids = alc883_dac_nids,
10196 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010197 .dig_in_nid = ALC883_DIGIN_NID,
10198 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10199 .channel_mode = alc883_sixstack_modes,
10200 .input_mux = &alc883_capture_source,
10201 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010202 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010203 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010204 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10205 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010206 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10207 .dac_nids = alc883_dac_nids,
10208 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010209 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10210 .channel_mode = alc883_3ST_6ch_modes,
10211 .need_dac_fix = 1,
10212 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010213 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010214 .setup = alc882_targa_setup,
10215 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010216 },
10217 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010218 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010219 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10220 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010221 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10222 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010223 .adc_nids = alc883_adc_nids_alt,
10224 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010225 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010226 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010227 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10228 .channel_mode = alc883_3ST_2ch_modes,
10229 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010230 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010231 .setup = alc882_targa_setup,
10232 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010233 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010234 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010235 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10236 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010237 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010238 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010239 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10240 .dac_nids = alc883_dac_nids,
10241 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10242 .adc_nids = alc883_adc_nids_rev,
10243 .capsrc_nids = alc883_capsrc_nids_rev,
10244 .dig_out_nid = ALC883_DIGOUT_NID,
10245 .dig_in_nid = ALC883_DIGIN_NID,
10246 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10247 .channel_mode = alc883_4ST_8ch_modes,
10248 .need_dac_fix = 1,
10249 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010250 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010251 .setup = alc882_targa_setup,
10252 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010253 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010254 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010255 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010256 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10257 * and the headphone jack. Turn this on and rely on the
10258 * standard mute methods whenever the user wants to turn
10259 * these outputs off.
10260 */
10261 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10262 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10263 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010264 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10265 .channel_mode = alc883_3ST_2ch_modes,
10266 .input_mux = &alc883_capture_source,
10267 },
Tobin Davis2880a862007-08-07 11:50:26 +020010268 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010269 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010270 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010271 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10272 .dac_nids = alc883_dac_nids,
10273 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010274 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10275 .channel_mode = alc883_3ST_2ch_modes,
10276 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010277 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010278 .setup = alc883_acer_aspire_setup,
10279 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010280 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010281 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010282 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010283 alc883_chmode_mixer },
10284 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10285 alc888_acer_aspire_4930g_verbs },
10286 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10287 .dac_nids = alc883_dac_nids,
10288 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10289 .adc_nids = alc883_adc_nids_rev,
10290 .capsrc_nids = alc883_capsrc_nids_rev,
10291 .dig_out_nid = ALC883_DIGOUT_NID,
10292 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10293 .channel_mode = alc883_3ST_6ch_modes,
10294 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010295 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010296 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010297 ARRAY_SIZE(alc888_2_capture_sources),
10298 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010299 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010300 .setup = alc888_acer_aspire_4930g_setup,
10301 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010302 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010303 [ALC888_ACER_ASPIRE_6530G] = {
10304 .mixers = { alc888_acer_aspire_6530_mixer },
10305 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10306 alc888_acer_aspire_6530g_verbs },
10307 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10308 .dac_nids = alc883_dac_nids,
10309 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10310 .adc_nids = alc883_adc_nids_rev,
10311 .capsrc_nids = alc883_capsrc_nids_rev,
10312 .dig_out_nid = ALC883_DIGOUT_NID,
10313 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10314 .channel_mode = alc883_3ST_2ch_modes,
10315 .num_mux_defs =
10316 ARRAY_SIZE(alc888_2_capture_sources),
10317 .input_mux = alc888_acer_aspire_6530_sources,
10318 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010319 .setup = alc888_acer_aspire_6530g_setup,
10320 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010321 },
Hector Martin3b315d72009-06-02 10:54:19 +020010322 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010323 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010324 alc883_chmode_mixer },
10325 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010326 alc889_acer_aspire_8930g_verbs,
10327 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010328 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10329 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010330 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10331 .adc_nids = alc889_adc_nids,
10332 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010333 .dig_out_nid = ALC883_DIGOUT_NID,
10334 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10335 .channel_mode = alc883_3ST_6ch_modes,
10336 .need_dac_fix = 1,
10337 .const_channel_count = 6,
10338 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010339 ARRAY_SIZE(alc889_capture_sources),
10340 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010341 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010342 .setup = alc889_acer_aspire_8930g_setup,
10343 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010344#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010345 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010346#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010347 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010348 [ALC888_ACER_ASPIRE_7730G] = {
10349 .mixers = { alc883_3ST_6ch_mixer,
10350 alc883_chmode_mixer },
10351 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10352 alc888_acer_aspire_7730G_verbs },
10353 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10354 .dac_nids = alc883_dac_nids,
10355 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10356 .adc_nids = alc883_adc_nids_rev,
10357 .capsrc_nids = alc883_capsrc_nids_rev,
10358 .dig_out_nid = ALC883_DIGOUT_NID,
10359 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10360 .channel_mode = alc883_3ST_6ch_modes,
10361 .need_dac_fix = 1,
10362 .const_channel_count = 6,
10363 .input_mux = &alc883_capture_source,
10364 .unsol_event = alc_automute_amp_unsol_event,
Denis Kuplyakovd9477202010-11-24 06:01:09 +010010365 .setup = alc888_acer_aspire_7730g_setup,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010366 .init_hook = alc_automute_amp,
10367 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010368 [ALC883_MEDION] = {
10369 .mixers = { alc883_fivestack_mixer,
10370 alc883_chmode_mixer },
10371 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010372 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010373 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10374 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010375 .adc_nids = alc883_adc_nids_alt,
10376 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010377 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010378 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10379 .channel_mode = alc883_sixstack_modes,
10380 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010381 },
Kailang Yang272a5272007-05-14 11:00:38 +020010382 [ALC883_MEDION_MD2] = {
10383 .mixers = { alc883_medion_md2_mixer},
10384 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
10385 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10386 .dac_nids = alc883_dac_nids,
10387 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010388 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10389 .channel_mode = alc883_3ST_2ch_modes,
10390 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010391 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010392 .setup = alc883_medion_md2_setup,
10393 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020010394 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010395 [ALC883_MEDION_WIM2160] = {
10396 .mixers = { alc883_medion_wim2160_mixer },
10397 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10398 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10399 .dac_nids = alc883_dac_nids,
10400 .dig_out_nid = ALC883_DIGOUT_NID,
10401 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10402 .adc_nids = alc883_adc_nids,
10403 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10404 .channel_mode = alc883_3ST_2ch_modes,
10405 .input_mux = &alc883_capture_source,
10406 .unsol_event = alc_automute_amp_unsol_event,
10407 .setup = alc883_medion_wim2160_setup,
10408 .init_hook = alc_automute_amp,
10409 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010410 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010411 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010412 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10413 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10414 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010415 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10416 .channel_mode = alc883_3ST_2ch_modes,
10417 .input_mux = &alc883_capture_source,
10418 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010419 [ALC883_CLEVO_M540R] = {
10420 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10421 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10422 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10423 .dac_nids = alc883_dac_nids,
10424 .dig_out_nid = ALC883_DIGOUT_NID,
10425 .dig_in_nid = ALC883_DIGIN_NID,
10426 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10427 .channel_mode = alc883_3ST_6ch_clevo_modes,
10428 .need_dac_fix = 1,
10429 .input_mux = &alc883_capture_source,
10430 /* This machine has the hardware HP auto-muting, thus
10431 * we need no software mute via unsol event
10432 */
10433 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010434 [ALC883_CLEVO_M720] = {
10435 .mixers = { alc883_clevo_m720_mixer },
10436 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010437 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10438 .dac_nids = alc883_dac_nids,
10439 .dig_out_nid = ALC883_DIGOUT_NID,
10440 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10441 .channel_mode = alc883_3ST_2ch_modes,
10442 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010443 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010444 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010445 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010446 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010447 [ALC883_LENOVO_101E_2ch] = {
10448 .mixers = { alc883_lenovo_101e_2ch_mixer},
10449 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10450 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10451 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010452 .adc_nids = alc883_adc_nids_alt,
10453 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010454 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010455 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10456 .channel_mode = alc883_3ST_2ch_modes,
10457 .input_mux = &alc883_lenovo_101e_capture_source,
10458 .unsol_event = alc883_lenovo_101e_unsol_event,
10459 .init_hook = alc883_lenovo_101e_all_automute,
10460 },
Kailang Yang272a5272007-05-14 11:00:38 +020010461 [ALC883_LENOVO_NB0763] = {
10462 .mixers = { alc883_lenovo_nb0763_mixer },
10463 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10464 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10465 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010466 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10467 .channel_mode = alc883_3ST_2ch_modes,
10468 .need_dac_fix = 1,
10469 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010470 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010471 .setup = alc883_medion_md2_setup,
10472 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010473 },
10474 [ALC888_LENOVO_MS7195_DIG] = {
10475 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10476 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10477 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10478 .dac_nids = alc883_dac_nids,
10479 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010480 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10481 .channel_mode = alc883_3ST_6ch_modes,
10482 .need_dac_fix = 1,
10483 .input_mux = &alc883_capture_source,
10484 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10485 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010486 },
10487 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010488 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010489 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10490 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10491 .dac_nids = alc883_dac_nids,
10492 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010493 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10494 .channel_mode = alc883_3ST_2ch_modes,
10495 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010496 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010497 .setup = alc883_haier_w66_setup,
10498 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010499 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010500 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010501 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010502 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010503 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10504 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010505 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10506 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010507 .need_dac_fix = 1,
10508 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010509 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010510 .setup = alc888_3st_hp_setup,
10511 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010512 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010513 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010514 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010515 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10516 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10517 .dac_nids = alc883_dac_nids,
10518 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010519 .dig_in_nid = ALC883_DIGIN_NID,
10520 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10521 .channel_mode = alc883_sixstack_modes,
10522 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010523 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010524 .setup = alc888_6st_dell_setup,
10525 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010526 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010527 [ALC883_MITAC] = {
10528 .mixers = { alc883_mitac_mixer },
10529 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10530 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10531 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010532 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10533 .channel_mode = alc883_3ST_2ch_modes,
10534 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010535 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010536 .setup = alc883_mitac_setup,
10537 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010538 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010539 [ALC883_FUJITSU_PI2515] = {
10540 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10541 .init_verbs = { alc883_init_verbs,
10542 alc883_2ch_fujitsu_pi2515_verbs},
10543 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10544 .dac_nids = alc883_dac_nids,
10545 .dig_out_nid = ALC883_DIGOUT_NID,
10546 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10547 .channel_mode = alc883_3ST_2ch_modes,
10548 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010549 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010550 .setup = alc883_2ch_fujitsu_pi2515_setup,
10551 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010552 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010553 [ALC888_FUJITSU_XA3530] = {
10554 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10555 .init_verbs = { alc883_init_verbs,
10556 alc888_fujitsu_xa3530_verbs },
10557 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10558 .dac_nids = alc883_dac_nids,
10559 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10560 .adc_nids = alc883_adc_nids_rev,
10561 .capsrc_nids = alc883_capsrc_nids_rev,
10562 .dig_out_nid = ALC883_DIGOUT_NID,
10563 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10564 .channel_mode = alc888_4ST_8ch_intel_modes,
10565 .num_mux_defs =
10566 ARRAY_SIZE(alc888_2_capture_sources),
10567 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010568 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010569 .setup = alc888_fujitsu_xa3530_setup,
10570 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010571 },
Kailang Yange2757d52008-08-26 13:17:46 +020010572 [ALC888_LENOVO_SKY] = {
10573 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10574 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10575 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10576 .dac_nids = alc883_dac_nids,
10577 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010578 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10579 .channel_mode = alc883_sixstack_modes,
10580 .need_dac_fix = 1,
10581 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010582 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010583 .setup = alc888_lenovo_sky_setup,
10584 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010585 },
10586 [ALC888_ASUS_M90V] = {
10587 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10588 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10589 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10590 .dac_nids = alc883_dac_nids,
10591 .dig_out_nid = ALC883_DIGOUT_NID,
10592 .dig_in_nid = ALC883_DIGIN_NID,
10593 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10594 .channel_mode = alc883_3ST_6ch_modes,
10595 .need_dac_fix = 1,
10596 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010597 .unsol_event = alc_sku_unsol_event,
10598 .setup = alc883_mode2_setup,
10599 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010600 },
10601 [ALC888_ASUS_EEE1601] = {
10602 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010603 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010604 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10605 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10606 .dac_nids = alc883_dac_nids,
10607 .dig_out_nid = ALC883_DIGOUT_NID,
10608 .dig_in_nid = ALC883_DIGIN_NID,
10609 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10610 .channel_mode = alc883_3ST_2ch_modes,
10611 .need_dac_fix = 1,
10612 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010613 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010614 .init_hook = alc883_eee1601_inithook,
10615 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010616 [ALC1200_ASUS_P5Q] = {
10617 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10618 .init_verbs = { alc883_init_verbs },
10619 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10620 .dac_nids = alc883_dac_nids,
10621 .dig_out_nid = ALC1200_DIGOUT_NID,
10622 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010623 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010624 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10625 .channel_mode = alc883_sixstack_modes,
10626 .input_mux = &alc883_capture_source,
10627 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010628 [ALC889A_MB31] = {
10629 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10630 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10631 alc880_gpio1_init_verbs },
10632 .adc_nids = alc883_adc_nids,
10633 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010634 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010635 .dac_nids = alc883_dac_nids,
10636 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10637 .channel_mode = alc889A_mb31_6ch_modes,
10638 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10639 .input_mux = &alc889A_mb31_capture_source,
10640 .dig_out_nid = ALC883_DIGOUT_NID,
10641 .unsol_event = alc889A_mb31_unsol_event,
10642 .init_hook = alc889A_mb31_automute,
10643 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010644 [ALC883_SONY_VAIO_TT] = {
10645 .mixers = { alc883_vaiott_mixer },
10646 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10647 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10648 .dac_nids = alc883_dac_nids,
10649 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10650 .channel_mode = alc883_3ST_2ch_modes,
10651 .input_mux = &alc883_capture_source,
10652 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010653 .setup = alc883_vaiott_setup,
10654 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010655 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010656};
10657
10658
10659/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010660 * Pin config fixes
10661 */
10662enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010663 PINFIX_ABIT_AW9D_MAX,
10664 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010665 PINFIX_ACER_ASPIRE_7736,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010666};
10667
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010668static const struct alc_fixup alc882_fixups[] = {
10669 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010670 .pins = (const struct alc_pincfg[]) {
10671 { 0x15, 0x01080104 }, /* side */
10672 { 0x16, 0x01011012 }, /* rear */
10673 { 0x17, 0x01016011 }, /* clfe */
10674 { }
10675 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010676 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010677 [PINFIX_PB_M5210] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010678 .verbs = (const struct hda_verb[]) {
10679 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10680 {}
10681 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010682 },
David Henningssonc3d226a2010-10-14 15:42:08 +020010683 [PINFIX_ACER_ASPIRE_7736] = {
10684 .sku = ALC_FIXUP_SKU_IGNORE,
10685 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010686};
10687
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010688static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010689 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010690 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020010691 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010692 {}
10693};
10694
10695/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010696 * BIOS auto configuration
10697 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010698static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10699 const struct auto_pin_cfg *cfg)
10700{
10701 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10702}
10703
Takashi Iwai4953550a2009-06-30 15:28:30 +020010704static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010705 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010706 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010707{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010708 int idx;
10709
Takashi Iwai489008c2010-04-07 09:06:00 +020010710 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010711 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010712
Takashi Iwai489008c2010-04-07 09:06:00 +020010713 if (dac == 0x25)
10714 idx = 4;
10715 else if (dac >= 0x02 && dac <= 0x05)
10716 idx = dac - 2;
10717 else
10718 return;
10719 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010720}
10721
Takashi Iwai4953550a2009-06-30 15:28:30 +020010722static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010723{
10724 struct alc_spec *spec = codec->spec;
10725 int i;
10726
10727 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010728 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010729 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010730 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010731 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010732 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010733 }
10734}
10735
Takashi Iwai4953550a2009-06-30 15:28:30 +020010736static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010737{
10738 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010739 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010740 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010741
Takashi Iwai5855fb82010-09-16 18:24:02 +020010742 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10743 pin = spec->autocfg.hp_pins[i];
10744 if (!pin)
10745 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010746 dac = spec->multiout.hp_nid;
10747 if (!dac)
10748 dac = spec->multiout.dac_nids[0]; /* to front */
10749 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10750 }
Takashi Iwai5855fb82010-09-16 18:24:02 +020010751 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10752 pin = spec->autocfg.speaker_pins[i];
10753 if (!pin)
10754 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010755 dac = spec->multiout.extra_out_nid[0];
10756 if (!dac)
10757 dac = spec->multiout.dac_nids[0]; /* to front */
10758 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10759 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010760}
10761
Takashi Iwai4953550a2009-06-30 15:28:30 +020010762static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010763{
10764 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010765 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010766 int i;
10767
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010768 for (i = 0; i < cfg->num_inputs; i++) {
10769 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010770 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010771 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10772 snd_hda_codec_write(codec, nid, 0,
10773 AC_VERB_SET_AMP_GAIN_MUTE,
10774 AMP_OUT_MUTE);
10775 }
10776}
10777
10778static void alc882_auto_init_input_src(struct hda_codec *codec)
10779{
10780 struct alc_spec *spec = codec->spec;
10781 int c;
10782
10783 for (c = 0; c < spec->num_adc_nids; c++) {
10784 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10785 hda_nid_t nid = spec->capsrc_nids[c];
10786 unsigned int mux_idx;
10787 const struct hda_input_mux *imux;
10788 int conns, mute, idx, item;
10789
10790 conns = snd_hda_get_connections(codec, nid, conn_list,
10791 ARRAY_SIZE(conn_list));
10792 if (conns < 0)
10793 continue;
10794 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10795 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010796 if (!imux->num_items && mux_idx > 0)
10797 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010798 for (idx = 0; idx < conns; idx++) {
10799 /* if the current connection is the selected one,
10800 * unmute it as default - otherwise mute it
10801 */
10802 mute = AMP_IN_MUTE(idx);
10803 for (item = 0; item < imux->num_items; item++) {
10804 if (imux->items[item].index == idx) {
10805 if (spec->cur_mux[c] == item)
10806 mute = AMP_IN_UNMUTE(idx);
10807 break;
10808 }
10809 }
10810 /* check if we have a selector or mixer
10811 * we could check for the widget type instead, but
10812 * just check for Amp-In presence (in case of mixer
10813 * without amp-in there is something wrong, this
10814 * function shouldn't be used or capsrc nid is wrong)
10815 */
10816 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010817 snd_hda_codec_write(codec, nid, 0,
10818 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010819 mute);
10820 else if (mute != AMP_IN_MUTE(idx))
10821 snd_hda_codec_write(codec, nid, 0,
10822 AC_VERB_SET_CONNECT_SEL,
10823 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010824 }
10825 }
10826}
10827
Takashi Iwai4953550a2009-06-30 15:28:30 +020010828/* add mic boosts if needed */
10829static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010830{
10831 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010832 struct auto_pin_cfg *cfg = &spec->autocfg;
10833 int i, err;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010834 hda_nid_t nid;
10835
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010836 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010837 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010838 break;
10839 nid = cfg->inputs[i].pin;
10840 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +020010841 char label[32];
10842 snprintf(label, sizeof(label), "%s Boost",
10843 hda_get_autocfg_input_label(codec, cfg, i));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010844 err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010845 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010846 if (err < 0)
10847 return err;
10848 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010849 }
10850 return 0;
10851}
10852
10853/* almost identical with ALC880 parser... */
10854static int alc882_parse_auto_config(struct hda_codec *codec)
10855{
10856 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010857 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010858 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010859
Takashi Iwai05f5f472009-08-25 13:10:18 +020010860 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10861 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010862 if (err < 0)
10863 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010864 if (!spec->autocfg.line_outs)
10865 return 0; /* can't find valid BIOS pin config */
10866
10867 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10868 if (err < 0)
10869 return err;
10870 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10871 if (err < 0)
10872 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010873 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10874 "Headphone");
10875 if (err < 0)
10876 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010877 err = alc880_auto_create_extra_out(spec,
10878 spec->autocfg.speaker_pins[0],
10879 "Speaker");
10880 if (err < 0)
10881 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010882 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10883 if (err < 0)
10884 return err;
10885
10886 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10887
Takashi Iwai757899a2010-07-30 10:48:14 +020010888 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010889
10890 if (spec->kctls.list)
10891 add_mixer(spec, spec->kctls.list);
10892
10893 add_verb(spec, alc883_auto_init_verbs);
10894 /* if ADC 0x07 is available, initialize it, too */
10895 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10896 add_verb(spec, alc882_adc1_init_verbs);
10897
10898 spec->num_mux_defs = 1;
10899 spec->input_mux = &spec->private_imux[0];
10900
Kailang Yang6227cdc2010-02-25 08:36:52 +010010901 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010902
10903 err = alc_auto_add_mic_boost(codec);
10904 if (err < 0)
10905 return err;
10906
Takashi Iwai776e1842007-08-29 15:07:11 +020010907 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010908}
10909
10910/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010911static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010912{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010913 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010914 alc882_auto_init_multi_out(codec);
10915 alc882_auto_init_hp_out(codec);
10916 alc882_auto_init_analog_input(codec);
10917 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010918 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010919 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010920 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010921}
10922
Takashi Iwai4953550a2009-06-30 15:28:30 +020010923static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010924{
10925 struct alc_spec *spec;
10926 int err, board_config;
10927
10928 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10929 if (spec == NULL)
10930 return -ENOMEM;
10931
10932 codec->spec = spec;
10933
Takashi Iwai4953550a2009-06-30 15:28:30 +020010934 switch (codec->vendor_id) {
10935 case 0x10ec0882:
10936 case 0x10ec0885:
10937 break;
10938 default:
10939 /* ALC883 and variants */
10940 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10941 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010942 }
10943
Takashi Iwai4953550a2009-06-30 15:28:30 +020010944 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10945 alc882_models,
10946 alc882_cfg_tbl);
10947
10948 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10949 board_config = snd_hda_check_board_codec_sid_config(codec,
10950 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10951
10952 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010953 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010954 codec->chip_name);
10955 board_config = ALC882_AUTO;
10956 }
10957
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010958 if (board_config == ALC882_AUTO)
10959 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010960
David Henningsson90622912010-10-14 14:50:18 +020010961 alc_auto_parse_customize_define(codec);
10962
Takashi Iwai4953550a2009-06-30 15:28:30 +020010963 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010964 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010965 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010966 if (err < 0) {
10967 alc_free(codec);
10968 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010969 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010970 printk(KERN_INFO
10971 "hda_codec: Cannot set up configuration "
10972 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010973 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010974 }
10975 }
10976
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010977 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020010978 err = snd_hda_attach_beep_device(codec, 0x1);
10979 if (err < 0) {
10980 alc_free(codec);
10981 return err;
10982 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010983 }
10984
Takashi Iwai4953550a2009-06-30 15:28:30 +020010985 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010986 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010987
Takashi Iwai4953550a2009-06-30 15:28:30 +020010988 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10989 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10990 /* FIXME: setup DAC5 */
10991 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10992 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10993
10994 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10995 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10996
Takashi Iwai4953550a2009-06-30 15:28:30 +020010997 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010998 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010999 spec->num_adc_nids = 0;
11000 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011001 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011002 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011003 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020011004 hda_nid_t nid = alc882_adc_nids[i];
11005 unsigned int wcap = get_wcaps(codec, nid);
11006 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011007 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020011008 if (wcap != AC_WID_AUD_IN)
11009 continue;
11010 spec->private_adc_nids[spec->num_adc_nids] = nid;
11011 err = snd_hda_get_connections(codec, nid, &cap, 1);
11012 if (err < 0)
11013 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011014 err = snd_hda_get_connections(codec, cap, items,
11015 ARRAY_SIZE(items));
11016 if (err < 0)
11017 continue;
11018 for (j = 0; j < imux->num_items; j++)
11019 if (imux->items[j].index >= err)
11020 break;
11021 if (j < imux->num_items)
11022 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011023 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
11024 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011025 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011026 spec->adc_nids = spec->private_adc_nids;
11027 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020011028 }
11029
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011030 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010011031
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011032 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010011033 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011034
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011035 if (board_config == ALC882_AUTO)
11036 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
11037
Takashi Iwai2134ea42008-01-10 16:53:55 +010011038 spec->vmaster_nid = 0x0c;
11039
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011040 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011041 if (board_config == ALC882_AUTO)
11042 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011043
11044 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011045#ifdef CONFIG_SND_HDA_POWER_SAVE
11046 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011047 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011048#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011049
11050 return 0;
11051}
11052
Takashi Iwai4953550a2009-06-30 15:28:30 +020011053
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011054/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011055 * ALC262 support
11056 */
11057
11058#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11059#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11060
11061#define alc262_dac_nids alc260_dac_nids
11062#define alc262_adc_nids alc882_adc_nids
11063#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011064#define alc262_capsrc_nids alc882_capsrc_nids
11065#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011066
11067#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011068#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011069
Kailang Yang4e555fe2008-08-26 13:05:55 +020011070static hda_nid_t alc262_dmic_adc_nids[1] = {
11071 /* ADC0 */
11072 0x09
11073};
11074
11075static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
11076
Kailang Yangdf694da2005-12-05 19:42:22 +010011077static struct snd_kcontrol_new alc262_base_mixer[] = {
11078 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11079 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11080 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11081 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11082 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11083 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11084 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11085 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011086 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011087 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11088 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011089 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011090 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11091 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11092 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11093 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011094 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011095};
11096
Takashi Iwaice875f02008-01-28 18:17:43 +010011097/* update HP, line and mono-out pins according to the master switch */
11098static void alc262_hp_master_update(struct hda_codec *codec)
11099{
11100 struct alc_spec *spec = codec->spec;
11101 int val = spec->master_sw;
11102
11103 /* HP & line-out */
11104 snd_hda_codec_write_cache(codec, 0x1b, 0,
11105 AC_VERB_SET_PIN_WIDGET_CONTROL,
11106 val ? PIN_HP : 0);
11107 snd_hda_codec_write_cache(codec, 0x15, 0,
11108 AC_VERB_SET_PIN_WIDGET_CONTROL,
11109 val ? PIN_HP : 0);
11110 /* mono (speaker) depending on the HP jack sense */
11111 val = val && !spec->jack_present;
11112 snd_hda_codec_write_cache(codec, 0x16, 0,
11113 AC_VERB_SET_PIN_WIDGET_CONTROL,
11114 val ? PIN_OUT : 0);
11115}
11116
11117static void alc262_hp_bpc_automute(struct hda_codec *codec)
11118{
11119 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011120
11121 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011122 alc262_hp_master_update(codec);
11123}
11124
11125static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11126{
11127 if ((res >> 26) != ALC880_HP_EVENT)
11128 return;
11129 alc262_hp_bpc_automute(codec);
11130}
11131
11132static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11133{
11134 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011135
11136 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011137 alc262_hp_master_update(codec);
11138}
11139
11140static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11141 unsigned int res)
11142{
11143 if ((res >> 26) != ALC880_HP_EVENT)
11144 return;
11145 alc262_hp_wildwest_automute(codec);
11146}
11147
Takashi Iwaib72519b2009-05-08 14:31:55 +020011148#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011149
11150static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11151 struct snd_ctl_elem_value *ucontrol)
11152{
11153 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11154 struct alc_spec *spec = codec->spec;
11155 int val = !!*ucontrol->value.integer.value;
11156
11157 if (val == spec->master_sw)
11158 return 0;
11159 spec->master_sw = val;
11160 alc262_hp_master_update(codec);
11161 return 1;
11162}
11163
Takashi Iwaib72519b2009-05-08 14:31:55 +020011164#define ALC262_HP_MASTER_SWITCH \
11165 { \
11166 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11167 .name = "Master Playback Switch", \
11168 .info = snd_ctl_boolean_mono_info, \
11169 .get = alc262_hp_master_sw_get, \
11170 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011171 }, \
11172 { \
11173 .iface = NID_MAPPING, \
11174 .name = "Master Playback Switch", \
11175 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011176 }
11177
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011178
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011179static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011180 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011181 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11182 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11183 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011184 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11185 HDA_OUTPUT),
11186 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11187 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011188 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11189 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011190 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011191 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11192 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011193 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011194 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11195 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11196 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11197 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011198 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11199 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11200 { } /* end */
11201};
11202
Kailang Yangcd7509a2007-01-26 18:33:17 +010011203static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011204 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011205 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11206 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11207 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11208 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011209 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11210 HDA_OUTPUT),
11211 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11212 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011213 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11214 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011215 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011216 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11217 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11218 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11219 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011220 { } /* end */
11221};
11222
11223static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11224 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11225 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011226 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011227 { } /* end */
11228};
11229
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011230/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011231static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011232{
11233 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011234
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011235 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011236 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011237}
11238
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011239static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011240 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11241 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011242 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11243 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11244 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11245 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11246 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11247 { } /* end */
11248};
11249
11250static struct hda_verb alc262_hp_t5735_verbs[] = {
11251 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11252 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11253
11254 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11255 { }
11256};
11257
Kailang Yang8c427222008-01-10 13:03:59 +010011258static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011259 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11260 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011261 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11262 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011263 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11264 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11265 { } /* end */
11266};
11267
11268static struct hda_verb alc262_hp_rp5700_verbs[] = {
11269 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11270 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11271 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11272 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11273 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11274 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11275 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11277 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11278 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11279 {}
11280};
11281
11282static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11283 .num_items = 1,
11284 .items = {
11285 { "Line", 0x1 },
11286 },
11287};
11288
Takashi Iwai42171c12009-05-08 14:11:43 +020011289/* bind hp and internal speaker mute (with plug check) as master switch */
11290static void alc262_hippo_master_update(struct hda_codec *codec)
11291{
11292 struct alc_spec *spec = codec->spec;
11293 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11294 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11295 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11296 unsigned int mute;
11297
11298 /* HP */
11299 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11300 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11301 HDA_AMP_MUTE, mute);
11302 /* mute internal speaker per jack sense */
11303 if (spec->jack_present)
11304 mute = HDA_AMP_MUTE;
11305 if (line_nid)
11306 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11307 HDA_AMP_MUTE, mute);
11308 if (speaker_nid && speaker_nid != line_nid)
11309 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11310 HDA_AMP_MUTE, mute);
11311}
11312
11313#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11314
11315static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11316 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011317{
11318 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011319 struct alc_spec *spec = codec->spec;
11320 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011321
Takashi Iwai42171c12009-05-08 14:11:43 +020011322 if (val == spec->master_sw)
11323 return 0;
11324 spec->master_sw = val;
11325 alc262_hippo_master_update(codec);
11326 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011327}
Takashi Iwai5b319542007-07-26 11:49:22 +020011328
Takashi Iwai42171c12009-05-08 14:11:43 +020011329#define ALC262_HIPPO_MASTER_SWITCH \
11330 { \
11331 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11332 .name = "Master Playback Switch", \
11333 .info = snd_ctl_boolean_mono_info, \
11334 .get = alc262_hippo_master_sw_get, \
11335 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011336 }, \
11337 { \
11338 .iface = NID_MAPPING, \
11339 .name = "Master Playback Switch", \
11340 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11341 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011342 }
11343
11344static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11345 ALC262_HIPPO_MASTER_SWITCH,
11346 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11347 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11348 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11349 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11350 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11351 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11352 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11353 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11354 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11355 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11356 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11357 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11358 { } /* end */
11359};
11360
11361static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11362 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11363 ALC262_HIPPO_MASTER_SWITCH,
11364 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11365 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11366 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11367 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11370 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11371 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11372 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11373 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11374 { } /* end */
11375};
11376
11377/* mute/unmute internal speaker according to the hp jack and mute state */
11378static void alc262_hippo_automute(struct hda_codec *codec)
11379{
11380 struct alc_spec *spec = codec->spec;
11381 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011382
Wu Fengguang864f92b2009-11-18 12:38:02 +080011383 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011384 alc262_hippo_master_update(codec);
11385}
11386
11387static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11388{
11389 if ((res >> 26) != ALC880_HP_EVENT)
11390 return;
11391 alc262_hippo_automute(codec);
11392}
11393
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011394static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011395{
11396 struct alc_spec *spec = codec->spec;
11397
11398 spec->autocfg.hp_pins[0] = 0x15;
11399 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011400}
11401
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011402static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011403{
11404 struct alc_spec *spec = codec->spec;
11405
11406 spec->autocfg.hp_pins[0] = 0x1b;
11407 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011408}
11409
11410
Kailang Yang272a5272007-05-14 11:00:38 +020011411static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011412 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011413 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011414 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11415 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11416 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11417 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11418 { } /* end */
11419};
11420
Kailang Yang83c34212007-07-05 11:43:05 +020011421static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011422 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11423 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011424 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11425 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11426 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11427 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11428 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11429 { } /* end */
11430};
Kailang Yang272a5272007-05-14 11:00:38 +020011431
Tony Vroonba340e82009-02-02 19:01:30 +000011432static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11433 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11434 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11435 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11436 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11437 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11438 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11439 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11440 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11441 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11442 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11443 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11444 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11445 { } /* end */
11446};
11447
11448static struct hda_verb alc262_tyan_verbs[] = {
11449 /* Headphone automute */
11450 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11451 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11452 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11453
11454 /* P11 AUX_IN, white 4-pin connector */
11455 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11456 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11457 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11458 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11459
11460 {}
11461};
11462
11463/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011464static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011465{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011466 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011467
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011468 spec->autocfg.hp_pins[0] = 0x1b;
11469 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011470}
11471
Tony Vroonba340e82009-02-02 19:01:30 +000011472
Kailang Yangdf694da2005-12-05 19:42:22 +010011473#define alc262_capture_mixer alc882_capture_mixer
11474#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11475
11476/*
11477 * generic initialization of ADC, input mixers and output mixers
11478 */
11479static struct hda_verb alc262_init_verbs[] = {
11480 /*
11481 * Unmute ADC0-2 and set the default input to mic-in
11482 */
11483 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11484 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11485 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11486 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11487 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11488 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11489
Takashi Iwaicb53c622007-08-10 17:21:45 +020011490 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011491 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011492 * Note: PASD motherboards uses the Line In 2 as the input for
11493 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011494 */
11495 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011496 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11497 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11498 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11499 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011501
11502 /*
11503 * Set up output mixers (0x0c - 0x0e)
11504 */
11505 /* set vol=0 to output mixers */
11506 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11507 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11508 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11509 /* set up input amps for analog loopback */
11510 /* Amp Indices: DAC = 0, mixer = 1 */
11511 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11512 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11513 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11514 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11515 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11516 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11517
11518 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11519 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11520 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11521 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11522 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11523 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11524
11525 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11526 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11527 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11528 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11529 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011530
Kailang Yangdf694da2005-12-05 19:42:22 +010011531 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11532 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011533
Kailang Yangdf694da2005-12-05 19:42:22 +010011534 /* FIXME: use matrix-type input source selection */
11535 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11536 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11537 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11538 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11539 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11540 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11541 /* Input mixer2 */
11542 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11543 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11544 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11545 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11546 /* Input mixer3 */
11547 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11548 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11549 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011550 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011551
11552 { }
11553};
11554
Kailang Yang4e555fe2008-08-26 13:05:55 +020011555static struct hda_verb alc262_eapd_verbs[] = {
11556 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11557 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11558 { }
11559};
11560
Kailang Yangccc656c2006-10-17 12:32:26 +020011561static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11562 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11563 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11564 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11565
11566 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11567 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11568 {}
11569};
11570
Kailang Yang272a5272007-05-14 11:00:38 +020011571static struct hda_verb alc262_sony_unsol_verbs[] = {
11572 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11573 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11574 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11575
11576 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11577 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011578 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011579};
11580
Kailang Yang4e555fe2008-08-26 13:05:55 +020011581static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11582 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11583 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11584 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11585 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11586 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011587 { } /* end */
11588};
11589
11590static struct hda_verb alc262_toshiba_s06_verbs[] = {
11591 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11592 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11593 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11594 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11595 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11596 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11597 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11598 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11599 {}
11600};
11601
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011602static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011603{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011604 struct alc_spec *spec = codec->spec;
11605
11606 spec->autocfg.hp_pins[0] = 0x15;
11607 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011608 spec->ext_mic.pin = 0x18;
11609 spec->ext_mic.mux_idx = 0;
11610 spec->int_mic.pin = 0x12;
11611 spec->int_mic.mux_idx = 9;
11612 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011613}
11614
Takashi Iwai834be882006-03-01 14:16:17 +010011615/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011616 * nec model
11617 * 0x15 = headphone
11618 * 0x16 = internal speaker
11619 * 0x18 = external mic
11620 */
11621
11622static struct snd_kcontrol_new alc262_nec_mixer[] = {
11623 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11624 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11625
11626 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11627 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11628 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11629
11630 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11631 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11632 { } /* end */
11633};
11634
11635static struct hda_verb alc262_nec_verbs[] = {
11636 /* Unmute Speaker */
11637 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11638
11639 /* Headphone */
11640 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11641 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11642
11643 /* External mic to headphone */
11644 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11645 /* External mic to speaker */
11646 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11647 {}
11648};
11649
11650/*
Takashi Iwai834be882006-03-01 14:16:17 +010011651 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011652 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11653 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011654 */
11655
11656#define ALC_HP_EVENT 0x37
11657
11658static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11659 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11660 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011661 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11662 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011663 {}
11664};
11665
Jiang zhe0e31daf2008-03-20 12:12:39 +010011666static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11667 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11668 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11669 {}
11670};
11671
Daniel T Chene2595322009-12-19 18:19:02 -050011672static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11673 /* Front Mic pin: input vref at 50% */
11674 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11675 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11676 {}
11677};
11678
Takashi Iwai834be882006-03-01 14:16:17 +010011679static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011680 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011681 .items = {
11682 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011683 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011684 { "CD", 0x4 },
11685 },
11686};
11687
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011688static struct hda_input_mux alc262_HP_capture_source = {
11689 .num_items = 5,
11690 .items = {
11691 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011692 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011693 { "Line", 0x2 },
11694 { "CD", 0x4 },
11695 { "AUX IN", 0x6 },
11696 },
11697};
11698
zhejiangaccbe492007-08-31 12:36:05 +020011699static struct hda_input_mux alc262_HP_D7000_capture_source = {
11700 .num_items = 4,
11701 .items = {
11702 { "Mic", 0x0 },
11703 { "Front Mic", 0x2 },
11704 { "Line", 0x1 },
11705 { "CD", 0x4 },
11706 },
11707};
11708
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011709/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011710static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11711{
11712 struct alc_spec *spec = codec->spec;
11713 unsigned int mute;
11714
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011715 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011716 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11717 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011718 spec->sense_updated = 1;
11719 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011720 /* unmute internal speaker only if both HPs are unplugged and
11721 * master switch is on
11722 */
11723 if (spec->jack_present)
11724 mute = HDA_AMP_MUTE;
11725 else
Takashi Iwai834be882006-03-01 14:16:17 +010011726 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011727 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11728 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011729}
11730
11731/* unsolicited event for HP jack sensing */
11732static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11733 unsigned int res)
11734{
11735 if ((res >> 26) != ALC_HP_EVENT)
11736 return;
11737 alc262_fujitsu_automute(codec, 1);
11738}
11739
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011740static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11741{
11742 alc262_fujitsu_automute(codec, 1);
11743}
11744
Takashi Iwai834be882006-03-01 14:16:17 +010011745/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011746static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11747 .ops = &snd_hda_bind_vol,
11748 .values = {
11749 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11750 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11751 0
11752 },
11753};
Takashi Iwai834be882006-03-01 14:16:17 +010011754
Jiang zhe0e31daf2008-03-20 12:12:39 +010011755/* mute/unmute internal speaker according to the hp jack and mute state */
11756static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11757{
11758 struct alc_spec *spec = codec->spec;
11759 unsigned int mute;
11760
11761 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011762 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011763 spec->sense_updated = 1;
11764 }
11765 if (spec->jack_present) {
11766 /* mute internal speaker */
11767 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11768 HDA_AMP_MUTE, HDA_AMP_MUTE);
11769 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11770 HDA_AMP_MUTE, HDA_AMP_MUTE);
11771 } else {
11772 /* unmute internal speaker if necessary */
11773 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11774 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11775 HDA_AMP_MUTE, mute);
11776 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11777 HDA_AMP_MUTE, mute);
11778 }
11779}
11780
11781/* unsolicited event for HP jack sensing */
11782static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11783 unsigned int res)
11784{
11785 if ((res >> 26) != ALC_HP_EVENT)
11786 return;
11787 alc262_lenovo_3000_automute(codec, 1);
11788}
11789
Takashi Iwai8de56b72009-07-24 16:51:47 +020011790static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11791 int dir, int idx, long *valp)
11792{
11793 int i, change = 0;
11794
11795 for (i = 0; i < 2; i++, valp++)
11796 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11797 HDA_AMP_MUTE,
11798 *valp ? 0 : HDA_AMP_MUTE);
11799 return change;
11800}
11801
Takashi Iwai834be882006-03-01 14:16:17 +010011802/* bind hp and internal speaker mute (with plug check) */
11803static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11804 struct snd_ctl_elem_value *ucontrol)
11805{
11806 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11807 long *valp = ucontrol->value.integer.value;
11808 int change;
11809
Takashi Iwai8de56b72009-07-24 16:51:47 +020011810 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11811 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011812 if (change)
11813 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011814 return change;
11815}
11816
11817static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011818 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011819 {
11820 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11821 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011822 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011823 .info = snd_hda_mixer_amp_switch_info,
11824 .get = snd_hda_mixer_amp_switch_get,
11825 .put = alc262_fujitsu_master_sw_put,
11826 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11827 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011828 {
11829 .iface = NID_MAPPING,
11830 .name = "Master Playback Switch",
11831 .private_value = 0x1b,
11832 },
Takashi Iwai834be882006-03-01 14:16:17 +010011833 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11834 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11835 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11836 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11837 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011838 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11839 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11840 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011841 { } /* end */
11842};
11843
Jiang zhe0e31daf2008-03-20 12:12:39 +010011844/* bind hp and internal speaker mute (with plug check) */
11845static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11846 struct snd_ctl_elem_value *ucontrol)
11847{
11848 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11849 long *valp = ucontrol->value.integer.value;
11850 int change;
11851
Takashi Iwai8de56b72009-07-24 16:51:47 +020011852 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011853 if (change)
11854 alc262_lenovo_3000_automute(codec, 0);
11855 return change;
11856}
11857
11858static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11859 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11860 {
11861 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11862 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011863 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011864 .info = snd_hda_mixer_amp_switch_info,
11865 .get = snd_hda_mixer_amp_switch_get,
11866 .put = alc262_lenovo_3000_master_sw_put,
11867 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11868 },
11869 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11870 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11871 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11872 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11873 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11874 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11875 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11876 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11877 { } /* end */
11878};
11879
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011880static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11881 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011882 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011883 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11884 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11885 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11886 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11887 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11888 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11889 { } /* end */
11890};
11891
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011892/* additional init verbs for Benq laptops */
11893static struct hda_verb alc262_EAPD_verbs[] = {
11894 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11895 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11896 {}
11897};
11898
Kailang Yang83c34212007-07-05 11:43:05 +020011899static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11900 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11901 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11902
11903 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11904 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11905 {}
11906};
11907
Tobin Davisf651b502007-10-26 12:40:47 +020011908/* Samsung Q1 Ultra Vista model setup */
11909static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011910 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11911 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11913 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11914 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011915 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011916 { } /* end */
11917};
11918
11919static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011920 /* output mixer */
11921 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11922 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11923 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11924 /* speaker */
11925 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11926 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11927 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11928 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11929 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011930 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011931 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11932 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11933 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11934 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11935 /* internal mic */
11936 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11937 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11938 /* ADC, choose mic */
11939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11940 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11941 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11942 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11943 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11944 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11945 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11946 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11947 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11948 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011949 {}
11950};
11951
Tobin Davisf651b502007-10-26 12:40:47 +020011952/* mute/unmute internal speaker according to the hp jack and mute state */
11953static void alc262_ultra_automute(struct hda_codec *codec)
11954{
11955 struct alc_spec *spec = codec->spec;
11956 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011957
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011958 mute = 0;
11959 /* auto-mute only when HP is used as HP */
11960 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011961 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011962 if (spec->jack_present)
11963 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011964 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011965 /* mute/unmute internal speaker */
11966 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11967 HDA_AMP_MUTE, mute);
11968 /* mute/unmute HP */
11969 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11970 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011971}
11972
11973/* unsolicited event for HP jack sensing */
11974static void alc262_ultra_unsol_event(struct hda_codec *codec,
11975 unsigned int res)
11976{
11977 if ((res >> 26) != ALC880_HP_EVENT)
11978 return;
11979 alc262_ultra_automute(codec);
11980}
11981
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011982static struct hda_input_mux alc262_ultra_capture_source = {
11983 .num_items = 2,
11984 .items = {
11985 { "Mic", 0x1 },
11986 { "Headphone", 0x7 },
11987 },
11988};
11989
11990static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11991 struct snd_ctl_elem_value *ucontrol)
11992{
11993 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11994 struct alc_spec *spec = codec->spec;
11995 int ret;
11996
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011997 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011998 if (!ret)
11999 return 0;
12000 /* reprogram the HP pin as mic or HP according to the input source */
12001 snd_hda_codec_write_cache(codec, 0x15, 0,
12002 AC_VERB_SET_PIN_WIDGET_CONTROL,
12003 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
12004 alc262_ultra_automute(codec); /* mute/unmute HP */
12005 return ret;
12006}
12007
12008static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
12009 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
12010 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
12011 {
12012 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12013 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012014 .info = alc_mux_enum_info,
12015 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012016 .put = alc262_ultra_mux_enum_put,
12017 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010012018 {
12019 .iface = NID_MAPPING,
12020 .name = "Capture Source",
12021 .private_value = 0x15,
12022 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012023 { } /* end */
12024};
12025
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012026/* We use two mixers depending on the output pin; 0x16 is a mono output
12027 * and thus it's bound with a different mixer.
12028 * This function returns which mixer amp should be used.
12029 */
12030static int alc262_check_volbit(hda_nid_t nid)
12031{
12032 if (!nid)
12033 return 0;
12034 else if (nid == 0x16)
12035 return 2;
12036 else
12037 return 1;
12038}
12039
12040static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012041 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012042{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012043 unsigned long val;
12044 int vbit;
12045
12046 vbit = alc262_check_volbit(nid);
12047 if (!vbit)
12048 return 0;
12049 if (*vbits & vbit) /* a volume control for this mixer already there */
12050 return 0;
12051 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012052 if (vbit == 2)
12053 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
12054 else
12055 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012056 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012057}
12058
12059static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012060 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012061{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012062 unsigned long val;
12063
12064 if (!nid)
12065 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012066 if (nid == 0x16)
12067 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
12068 else
12069 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012070 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012071}
12072
Kailang Yangdf694da2005-12-05 19:42:22 +010012073/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012074static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
12075 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012076{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012077 const char *pfx;
12078 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020012079 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012080
12081 spec->multiout.num_dacs = 1; /* only use one dac */
12082 spec->multiout.dac_nids = spec->private_dac_nids;
12083 spec->multiout.dac_nids[0] = 2;
12084
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012085 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
12086 pfx = "Master";
12087 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12088 pfx = "Speaker";
Takashi Iwai033688a2010-09-08 15:47:09 +020012089 else if (cfg->line_out_type == AUTO_PIN_HP_OUT)
12090 pfx = "Headphone";
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012091 else
12092 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012093 for (i = 0; i < 2; i++) {
12094 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12095 if (err < 0)
12096 return err;
12097 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12098 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12099 "Speaker", i);
12100 if (err < 0)
12101 return err;
12102 }
12103 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12104 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12105 "Headphone", i);
12106 if (err < 0)
12107 return err;
12108 }
12109 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012110
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012111 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12112 alc262_check_volbit(cfg->speaker_pins[0]) |
12113 alc262_check_volbit(cfg->hp_pins[0]);
12114 if (vbits == 1 || vbits == 2)
12115 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012116 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012117 for (i = 0; i < 2; i++) {
12118 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12119 &vbits, i);
12120 if (err < 0)
12121 return err;
12122 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12123 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12124 "Speaker", &vbits, i);
12125 if (err < 0)
12126 return err;
12127 }
12128 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12129 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12130 "Headphone", &vbits, i);
12131 if (err < 0)
12132 return err;
12133 }
12134 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012135 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012136}
12137
Takashi Iwai05f5f472009-08-25 13:10:18 +020012138#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012139 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012140
12141/*
12142 * generic initialization of ADC, input mixers and output mixers
12143 */
12144static struct hda_verb alc262_volume_init_verbs[] = {
12145 /*
12146 * Unmute ADC0-2 and set the default input to mic-in
12147 */
12148 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12150 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12151 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12152 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12153 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12154
Takashi Iwaicb53c622007-08-10 17:21:45 +020012155 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012156 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012157 * Note: PASD motherboards uses the Line In 2 as the input for
12158 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012159 */
12160 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012161 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12162 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12163 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12164 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12165 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012166
12167 /*
12168 * Set up output mixers (0x0c - 0x0f)
12169 */
12170 /* set vol=0 to output mixers */
12171 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12172 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12173 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012174
Kailang Yangdf694da2005-12-05 19:42:22 +010012175 /* set up input amps for analog loopback */
12176 /* Amp Indices: DAC = 0, mixer = 1 */
12177 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12178 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12179 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12180 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12181 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12182 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12183
12184 /* FIXME: use matrix-type input source selection */
12185 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12186 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12187 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12188 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12189 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12190 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12191 /* Input mixer2 */
12192 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12193 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12194 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12195 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12196 /* Input mixer3 */
12197 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12198 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12199 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12200 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12201
12202 { }
12203};
12204
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012205static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12206 /*
12207 * Unmute ADC0-2 and set the default input to mic-in
12208 */
12209 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12210 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12211 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12212 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12213 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12214 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12215
Takashi Iwaicb53c622007-08-10 17:21:45 +020012216 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012217 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012218 * Note: PASD motherboards uses the Line In 2 as the input for
12219 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012220 */
12221 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012222 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12223 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12224 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12225 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12226 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12227 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12228 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012229
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012230 /*
12231 * Set up output mixers (0x0c - 0x0e)
12232 */
12233 /* set vol=0 to output mixers */
12234 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12235 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12236 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12237
12238 /* set up input amps for analog loopback */
12239 /* Amp Indices: DAC = 0, mixer = 1 */
12240 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12241 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12242 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12243 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12244 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12245 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12246
Takashi Iwaice875f02008-01-28 18:17:43 +010012247 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012248 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12249 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12250
12251 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12252 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12253
12254 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12255 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12256
12257 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12258 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12259 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12260 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12261 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12262
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012263 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012264 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12265 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012266 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012267 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12268 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12269
12270
12271 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012272 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12273 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012274 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12277 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12278 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12279 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12280 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12281 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12282 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012283 /* Input mixer2 */
12284 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012285 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12286 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12287 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12288 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12289 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12290 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12291 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12292 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012293 /* Input mixer3 */
12294 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012295 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12296 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12297 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12298 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12299 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12300 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12301 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12302 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012303
Takashi Iwaice875f02008-01-28 18:17:43 +010012304 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12305
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012306 { }
12307};
12308
Kailang Yangcd7509a2007-01-26 18:33:17 +010012309static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12310 /*
12311 * Unmute ADC0-2 and set the default input to mic-in
12312 */
12313 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12314 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12315 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12316 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12317 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12318 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12319
Takashi Iwaicb53c622007-08-10 17:21:45 +020012320 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012321 * mixer widget
12322 * Note: PASD motherboards uses the Line In 2 as the input for front
12323 * panel mic (mic 2)
12324 */
12325 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012326 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12327 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12328 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12329 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12330 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12331 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12332 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12333 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012334 /*
12335 * Set up output mixers (0x0c - 0x0e)
12336 */
12337 /* set vol=0 to output mixers */
12338 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12339 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12340 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12341
12342 /* set up input amps for analog loopback */
12343 /* Amp Indices: DAC = 0, mixer = 1 */
12344 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12345 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12346 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12347 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12349 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12350
12351
12352 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12353 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12354 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12355 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12356 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12357 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12358 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12359
12360 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12361 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12362
12363 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12364 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12365
12366 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12367 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12368 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12369 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12370 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12371 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12372
12373 /* FIXME: use matrix-type input source selection */
12374 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12375 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12376 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12377 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12378 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12379 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12380 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12381 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12382 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12383 /* Input mixer2 */
12384 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12385 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12386 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12387 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12388 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12389 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12390 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12391 /* Input mixer3 */
12392 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12393 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12394 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12395 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12396 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12397 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12398 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12399
Takashi Iwaice875f02008-01-28 18:17:43 +010012400 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12401
Kailang Yangcd7509a2007-01-26 18:33:17 +010012402 { }
12403};
12404
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012405static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12406
12407 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12408 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12409 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12410
12411 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12412 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12413 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12414 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12415
12416 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12417 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12418 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12419 {}
12420};
12421
Takashi Iwai18675e42010-09-08 15:55:44 +020012422/*
12423 * Pin config fixes
12424 */
12425enum {
12426 PINFIX_FSC_H270,
12427};
12428
12429static const struct alc_fixup alc262_fixups[] = {
12430 [PINFIX_FSC_H270] = {
12431 .pins = (const struct alc_pincfg[]) {
12432 { 0x14, 0x99130110 }, /* speaker */
12433 { 0x15, 0x0221142f }, /* front HP */
12434 { 0x1b, 0x0121141f }, /* rear HP */
12435 { }
12436 }
12437 },
12438 [PINFIX_PB_M5210] = {
12439 .verbs = (const struct hda_verb[]) {
12440 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
12441 {}
12442 }
12443 },
12444};
12445
12446static struct snd_pci_quirk alc262_fixup_tbl[] = {
12447 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12448 {}
12449};
12450
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012451
Takashi Iwaicb53c622007-08-10 17:21:45 +020012452#ifdef CONFIG_SND_HDA_POWER_SAVE
12453#define alc262_loopbacks alc880_loopbacks
12454#endif
12455
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012456/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012457#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12458#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12459#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12460#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12461
12462/*
12463 * BIOS auto configuration
12464 */
12465static int alc262_parse_auto_config(struct hda_codec *codec)
12466{
12467 struct alc_spec *spec = codec->spec;
12468 int err;
12469 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12470
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012471 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12472 alc262_ignore);
12473 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012474 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012475 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012476 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012477 spec->multiout.max_channels = 2;
12478 spec->no_analog = 1;
12479 goto dig_only;
12480 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012481 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012482 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012483 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12484 if (err < 0)
12485 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012486 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012487 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012488 return err;
12489
12490 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12491
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012492 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012493 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012494
Takashi Iwai603c4012008-07-30 15:01:44 +020012495 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012496 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012497
Takashi Iwaid88897e2008-10-31 15:01:37 +010012498 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012499 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012500 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012501
Takashi Iwai776e1842007-08-29 15:07:11 +020012502 err = alc_auto_add_mic_boost(codec);
12503 if (err < 0)
12504 return err;
12505
Kailang Yang6227cdc2010-02-25 08:36:52 +010012506 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012507
Kailang Yangdf694da2005-12-05 19:42:22 +010012508 return 1;
12509}
12510
12511#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12512#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12513#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012514#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012515
12516
12517/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012518static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012519{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012520 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012521 alc262_auto_init_multi_out(codec);
12522 alc262_auto_init_hp_out(codec);
12523 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012524 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012525 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012526 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012527 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012528}
12529
12530/*
12531 * configuration and preset
12532 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012533static const char *alc262_models[ALC262_MODEL_LAST] = {
12534 [ALC262_BASIC] = "basic",
12535 [ALC262_HIPPO] = "hippo",
12536 [ALC262_HIPPO_1] = "hippo_1",
12537 [ALC262_FUJITSU] = "fujitsu",
12538 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012539 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012540 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012541 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012542 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012543 [ALC262_BENQ_T31] = "benq-t31",
12544 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012545 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012546 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012547 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012548 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012549 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012550 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012551 [ALC262_AUTO] = "auto",
12552};
12553
12554static struct snd_pci_quirk alc262_cfg_tbl[] = {
12555 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012556 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012557 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12558 ALC262_HP_BPC),
12559 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12560 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012561 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12562 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012563 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012564 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012565 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012566 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012567 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012568 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012569 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012570 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012571 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12572 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12573 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012574 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12575 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012576 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012577 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012578 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012579 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012580 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012581 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012582 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012583 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012584#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012585 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12586 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012587#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012588 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012589 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012590 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012591 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012592 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012593 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012594 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12595 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012596 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012597 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012598 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012599 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012600 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012601 {}
12602};
12603
12604static struct alc_config_preset alc262_presets[] = {
12605 [ALC262_BASIC] = {
12606 .mixers = { alc262_base_mixer },
12607 .init_verbs = { alc262_init_verbs },
12608 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12609 .dac_nids = alc262_dac_nids,
12610 .hp_nid = 0x03,
12611 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12612 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012613 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012614 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012615 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012616 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012617 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012618 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12619 .dac_nids = alc262_dac_nids,
12620 .hp_nid = 0x03,
12621 .dig_out_nid = ALC262_DIGOUT_NID,
12622 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12623 .channel_mode = alc262_modes,
12624 .input_mux = &alc262_capture_source,
12625 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012626 .setup = alc262_hippo_setup,
12627 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012628 },
12629 [ALC262_HIPPO_1] = {
12630 .mixers = { alc262_hippo1_mixer },
12631 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12632 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12633 .dac_nids = alc262_dac_nids,
12634 .hp_nid = 0x02,
12635 .dig_out_nid = ALC262_DIGOUT_NID,
12636 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12637 .channel_mode = alc262_modes,
12638 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012639 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012640 .setup = alc262_hippo1_setup,
12641 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012642 },
Takashi Iwai834be882006-03-01 14:16:17 +010012643 [ALC262_FUJITSU] = {
12644 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012645 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12646 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012647 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12648 .dac_nids = alc262_dac_nids,
12649 .hp_nid = 0x03,
12650 .dig_out_nid = ALC262_DIGOUT_NID,
12651 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12652 .channel_mode = alc262_modes,
12653 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012654 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012655 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012656 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012657 [ALC262_HP_BPC] = {
12658 .mixers = { alc262_HP_BPC_mixer },
12659 .init_verbs = { alc262_HP_BPC_init_verbs },
12660 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12661 .dac_nids = alc262_dac_nids,
12662 .hp_nid = 0x03,
12663 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12664 .channel_mode = alc262_modes,
12665 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012666 .unsol_event = alc262_hp_bpc_unsol_event,
12667 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012668 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012669 [ALC262_HP_BPC_D7000_WF] = {
12670 .mixers = { alc262_HP_BPC_WildWest_mixer },
12671 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12672 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12673 .dac_nids = alc262_dac_nids,
12674 .hp_nid = 0x03,
12675 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12676 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012677 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012678 .unsol_event = alc262_hp_wildwest_unsol_event,
12679 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012680 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012681 [ALC262_HP_BPC_D7000_WL] = {
12682 .mixers = { alc262_HP_BPC_WildWest_mixer,
12683 alc262_HP_BPC_WildWest_option_mixer },
12684 .init_verbs = { alc262_HP_BPC_WildWest_init_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,
zhejiangaccbe492007-08-31 12:36:05 +020012690 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012691 .unsol_event = alc262_hp_wildwest_unsol_event,
12692 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012693 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012694 [ALC262_HP_TC_T5735] = {
12695 .mixers = { alc262_hp_t5735_mixer },
12696 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12697 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12698 .dac_nids = alc262_dac_nids,
12699 .hp_nid = 0x03,
12700 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12701 .channel_mode = alc262_modes,
12702 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012703 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012704 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012705 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012706 },
12707 [ALC262_HP_RP5700] = {
12708 .mixers = { alc262_hp_rp5700_mixer },
12709 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12710 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12711 .dac_nids = alc262_dac_nids,
12712 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12713 .channel_mode = alc262_modes,
12714 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012715 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012716 [ALC262_BENQ_ED8] = {
12717 .mixers = { alc262_base_mixer },
12718 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12719 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12720 .dac_nids = alc262_dac_nids,
12721 .hp_nid = 0x03,
12722 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12723 .channel_mode = alc262_modes,
12724 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012725 },
Kailang Yang272a5272007-05-14 11:00:38 +020012726 [ALC262_SONY_ASSAMD] = {
12727 .mixers = { alc262_sony_mixer },
12728 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12729 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12730 .dac_nids = alc262_dac_nids,
12731 .hp_nid = 0x02,
12732 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12733 .channel_mode = alc262_modes,
12734 .input_mux = &alc262_capture_source,
12735 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012736 .setup = alc262_hippo_setup,
12737 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012738 },
12739 [ALC262_BENQ_T31] = {
12740 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012741 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12742 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012743 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12744 .dac_nids = alc262_dac_nids,
12745 .hp_nid = 0x03,
12746 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12747 .channel_mode = alc262_modes,
12748 .input_mux = &alc262_capture_source,
12749 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012750 .setup = alc262_hippo_setup,
12751 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012752 },
Tobin Davisf651b502007-10-26 12:40:47 +020012753 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012754 .mixers = { alc262_ultra_mixer },
12755 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012756 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012757 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12758 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012759 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12760 .channel_mode = alc262_modes,
12761 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012762 .adc_nids = alc262_adc_nids, /* ADC0 */
12763 .capsrc_nids = alc262_capsrc_nids,
12764 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012765 .unsol_event = alc262_ultra_unsol_event,
12766 .init_hook = alc262_ultra_automute,
12767 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012768 [ALC262_LENOVO_3000] = {
12769 .mixers = { alc262_lenovo_3000_mixer },
12770 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012771 alc262_lenovo_3000_unsol_verbs,
12772 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012773 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12774 .dac_nids = alc262_dac_nids,
12775 .hp_nid = 0x03,
12776 .dig_out_nid = ALC262_DIGOUT_NID,
12777 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12778 .channel_mode = alc262_modes,
12779 .input_mux = &alc262_fujitsu_capture_source,
12780 .unsol_event = alc262_lenovo_3000_unsol_event,
12781 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012782 [ALC262_NEC] = {
12783 .mixers = { alc262_nec_mixer },
12784 .init_verbs = { alc262_nec_verbs },
12785 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12786 .dac_nids = alc262_dac_nids,
12787 .hp_nid = 0x03,
12788 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12789 .channel_mode = alc262_modes,
12790 .input_mux = &alc262_capture_source,
12791 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012792 [ALC262_TOSHIBA_S06] = {
12793 .mixers = { alc262_toshiba_s06_mixer },
12794 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12795 alc262_eapd_verbs },
12796 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12797 .capsrc_nids = alc262_dmic_capsrc_nids,
12798 .dac_nids = alc262_dac_nids,
12799 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012800 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012801 .dig_out_nid = ALC262_DIGOUT_NID,
12802 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12803 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012804 .unsol_event = alc_sku_unsol_event,
12805 .setup = alc262_toshiba_s06_setup,
12806 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012807 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012808 [ALC262_TOSHIBA_RX1] = {
12809 .mixers = { alc262_toshiba_rx1_mixer },
12810 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12811 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12812 .dac_nids = alc262_dac_nids,
12813 .hp_nid = 0x03,
12814 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12815 .channel_mode = alc262_modes,
12816 .input_mux = &alc262_capture_source,
12817 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012818 .setup = alc262_hippo_setup,
12819 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012820 },
Tony Vroonba340e82009-02-02 19:01:30 +000012821 [ALC262_TYAN] = {
12822 .mixers = { alc262_tyan_mixer },
12823 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12824 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12825 .dac_nids = alc262_dac_nids,
12826 .hp_nid = 0x02,
12827 .dig_out_nid = ALC262_DIGOUT_NID,
12828 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12829 .channel_mode = alc262_modes,
12830 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012831 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012832 .setup = alc262_tyan_setup,
12833 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012834 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012835};
12836
12837static int patch_alc262(struct hda_codec *codec)
12838{
12839 struct alc_spec *spec;
12840 int board_config;
12841 int err;
12842
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012843 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012844 if (spec == NULL)
12845 return -ENOMEM;
12846
12847 codec->spec = spec;
12848#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012849 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12850 * under-run
12851 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012852 {
12853 int tmp;
12854 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12855 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12856 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12857 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12858 }
12859#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012860 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012861
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012862 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12863
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012864 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12865 alc262_models,
12866 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012867
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012868 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012869 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12870 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012871 board_config = ALC262_AUTO;
12872 }
12873
Takashi Iwai18675e42010-09-08 15:55:44 +020012874 if (board_config == ALC262_AUTO)
12875 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 1);
12876
Kailang Yangdf694da2005-12-05 19:42:22 +010012877 if (board_config == ALC262_AUTO) {
12878 /* automatic parse from the BIOS config */
12879 err = alc262_parse_auto_config(codec);
12880 if (err < 0) {
12881 alc_free(codec);
12882 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012883 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012884 printk(KERN_INFO
12885 "hda_codec: Cannot set up configuration "
12886 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012887 board_config = ALC262_BASIC;
12888 }
12889 }
12890
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012891 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012892 err = snd_hda_attach_beep_device(codec, 0x1);
12893 if (err < 0) {
12894 alc_free(codec);
12895 return err;
12896 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012897 }
12898
Kailang Yangdf694da2005-12-05 19:42:22 +010012899 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012900 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012901
Kailang Yangdf694da2005-12-05 19:42:22 +010012902 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12903 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012904
Kailang Yangdf694da2005-12-05 19:42:22 +010012905 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12906 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12907
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012908 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012909 int i;
12910 /* check whether the digital-mic has to be supported */
12911 for (i = 0; i < spec->input_mux->num_items; i++) {
12912 if (spec->input_mux->items[i].index >= 9)
12913 break;
12914 }
12915 if (i < spec->input_mux->num_items) {
12916 /* use only ADC0 */
12917 spec->adc_nids = alc262_dmic_adc_nids;
12918 spec->num_adc_nids = 1;
12919 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012920 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012921 /* all analog inputs */
12922 /* check whether NID 0x07 is valid */
12923 unsigned int wcap = get_wcaps(codec, 0x07);
12924
12925 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012926 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012927 if (wcap != AC_WID_AUD_IN) {
12928 spec->adc_nids = alc262_adc_nids_alt;
12929 spec->num_adc_nids =
12930 ARRAY_SIZE(alc262_adc_nids_alt);
12931 spec->capsrc_nids = alc262_capsrc_nids_alt;
12932 } else {
12933 spec->adc_nids = alc262_adc_nids;
12934 spec->num_adc_nids =
12935 ARRAY_SIZE(alc262_adc_nids);
12936 spec->capsrc_nids = alc262_capsrc_nids;
12937 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012938 }
12939 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012940 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012941 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012942 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012943 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012944
Takashi Iwai18675e42010-09-08 15:55:44 +020012945 if (board_config == ALC262_AUTO)
12946 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 0);
12947
Takashi Iwai2134ea42008-01-10 16:53:55 +010012948 spec->vmaster_nid = 0x0c;
12949
Kailang Yangdf694da2005-12-05 19:42:22 +010012950 codec->patch_ops = alc_patch_ops;
12951 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012952 spec->init_hook = alc262_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020012953
12954 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020012955#ifdef CONFIG_SND_HDA_POWER_SAVE
12956 if (!spec->loopback.amplist)
12957 spec->loopback.amplist = alc262_loopbacks;
12958#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012959
Kailang Yangdf694da2005-12-05 19:42:22 +010012960 return 0;
12961}
12962
Kailang Yangdf694da2005-12-05 19:42:22 +010012963/*
Kailang Yanga361d842007-06-05 12:30:55 +020012964 * ALC268 channel source setting (2 channel)
12965 */
12966#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12967#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012968
Kailang Yanga361d842007-06-05 12:30:55 +020012969static hda_nid_t alc268_dac_nids[2] = {
12970 /* front, hp */
12971 0x02, 0x03
12972};
12973
12974static hda_nid_t alc268_adc_nids[2] = {
12975 /* ADC0-1 */
12976 0x08, 0x07
12977};
12978
12979static hda_nid_t alc268_adc_nids_alt[1] = {
12980 /* ADC0 */
12981 0x08
12982};
12983
Takashi Iwaie1406342008-02-11 18:32:32 +010012984static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12985
Kailang Yanga361d842007-06-05 12:30:55 +020012986static struct snd_kcontrol_new alc268_base_mixer[] = {
12987 /* output mixer control */
12988 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12989 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12990 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12991 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012992 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12993 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12994 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012995 { }
12996};
12997
Takashi Iwai42171c12009-05-08 14:11:43 +020012998static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12999 /* output mixer control */
13000 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13001 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13002 ALC262_HIPPO_MASTER_SWITCH,
13003 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13004 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13005 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
13006 { }
13007};
13008
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013009/* bind Beep switches of both NID 0x0f and 0x10 */
13010static struct hda_bind_ctls alc268_bind_beep_sw = {
13011 .ops = &snd_hda_bind_sw,
13012 .values = {
13013 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
13014 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
13015 0
13016 },
13017};
13018
13019static struct snd_kcontrol_new alc268_beep_mixer[] = {
13020 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
13021 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
13022 { }
13023};
13024
Kailang Yangd1a991a2007-08-15 16:21:59 +020013025static struct hda_verb alc268_eapd_verbs[] = {
13026 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13027 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13028 { }
13029};
13030
Takashi Iwaid2738092007-08-16 14:59:45 +020013031/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020013032static struct hda_verb alc268_toshiba_verbs[] = {
13033 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13034 { } /* end */
13035};
13036
13037/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020013038/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020013039static struct hda_bind_ctls alc268_acer_bind_master_vol = {
13040 .ops = &snd_hda_bind_vol,
13041 .values = {
13042 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13043 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
13044 0
13045 },
13046};
13047
Takashi Iwai889c4392007-08-23 18:56:52 +020013048/* mute/unmute internal speaker according to the hp jack and mute state */
13049static void alc268_acer_automute(struct hda_codec *codec, int force)
13050{
13051 struct alc_spec *spec = codec->spec;
13052 unsigned int mute;
13053
13054 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080013055 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020013056 spec->sense_updated = 1;
13057 }
13058 if (spec->jack_present)
13059 mute = HDA_AMP_MUTE; /* mute internal speaker */
13060 else /* unmute internal speaker if necessary */
13061 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13062 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13063 HDA_AMP_MUTE, mute);
13064}
13065
13066
13067/* bind hp and internal speaker mute (with plug check) */
13068static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
13069 struct snd_ctl_elem_value *ucontrol)
13070{
13071 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
13072 long *valp = ucontrol->value.integer.value;
13073 int change;
13074
Takashi Iwai8de56b72009-07-24 16:51:47 +020013075 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020013076 if (change)
13077 alc268_acer_automute(codec, 0);
13078 return change;
13079}
Takashi Iwaid2738092007-08-16 14:59:45 +020013080
Kailang Yang8ef355d2008-08-26 13:10:22 +020013081static struct snd_kcontrol_new alc268_acer_aspire_one_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,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013088 .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 Capture Volume", 0x18, 0, HDA_INPUT),
13094 { }
13095};
13096
Takashi Iwaid2738092007-08-16 14:59:45 +020013097static struct snd_kcontrol_new alc268_acer_mixer[] = {
13098 /* output mixer control */
13099 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13100 {
13101 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13102 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013103 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013104 .info = snd_hda_mixer_amp_switch_info,
13105 .get = snd_hda_mixer_amp_switch_get,
13106 .put = alc268_acer_master_sw_put,
13107 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13108 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020013109 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13110 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13111 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013112 { }
13113};
13114
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013115static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13116 /* output mixer control */
13117 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13118 {
13119 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13120 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013121 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013122 .info = snd_hda_mixer_amp_switch_info,
13123 .get = snd_hda_mixer_amp_switch_get,
13124 .put = alc268_acer_master_sw_put,
13125 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13126 },
13127 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13128 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
13129 { }
13130};
13131
Kailang Yang8ef355d2008-08-26 13:10:22 +020013132static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13133 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13134 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13135 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13136 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13137 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13138 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13139 { }
13140};
13141
Takashi Iwaid2738092007-08-16 14:59:45 +020013142static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013143 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13144 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013145 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13146 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013147 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13148 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013149 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13150 { }
13151};
13152
13153/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013154#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013155#define alc268_toshiba_setup alc262_hippo_setup
13156#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013157
13158static void alc268_acer_unsol_event(struct hda_codec *codec,
13159 unsigned int res)
13160{
Takashi Iwai889c4392007-08-23 18:56:52 +020013161 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013162 return;
13163 alc268_acer_automute(codec, 1);
13164}
13165
Takashi Iwai889c4392007-08-23 18:56:52 +020013166static void alc268_acer_init_hook(struct hda_codec *codec)
13167{
13168 alc268_acer_automute(codec, 1);
13169}
13170
Kailang Yang8ef355d2008-08-26 13:10:22 +020013171/* toggle speaker-output according to the hp-jack state */
13172static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13173{
13174 unsigned int present;
13175 unsigned char bits;
13176
Wu Fengguang864f92b2009-11-18 12:38:02 +080013177 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013178 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013179 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013180 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013181 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013182 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013183}
13184
Kailang Yang8ef355d2008-08-26 13:10:22 +020013185static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13186 unsigned int res)
13187{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013188 switch (res >> 26) {
13189 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013190 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013191 break;
13192 case ALC880_MIC_EVENT:
13193 alc_mic_automute(codec);
13194 break;
13195 }
13196}
13197
13198static void alc268_acer_lc_setup(struct hda_codec *codec)
13199{
13200 struct alc_spec *spec = codec->spec;
13201 spec->ext_mic.pin = 0x18;
13202 spec->ext_mic.mux_idx = 0;
13203 spec->int_mic.pin = 0x12;
13204 spec->int_mic.mux_idx = 6;
13205 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013206}
13207
13208static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13209{
13210 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013211 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013212}
13213
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013214static struct snd_kcontrol_new alc268_dell_mixer[] = {
13215 /* output mixer control */
13216 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13217 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13218 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13219 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13220 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13221 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13222 { }
13223};
13224
13225static struct hda_verb alc268_dell_verbs[] = {
13226 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13227 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13228 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013229 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013230 { }
13231};
13232
13233/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013234static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013235{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013236 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013237
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013238 spec->autocfg.hp_pins[0] = 0x15;
13239 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013240 spec->ext_mic.pin = 0x18;
13241 spec->ext_mic.mux_idx = 0;
13242 spec->int_mic.pin = 0x19;
13243 spec->int_mic.mux_idx = 1;
13244 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013245}
13246
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013247static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13248 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13249 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13250 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13251 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13252 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13253 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
13254 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13255 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13256 { }
13257};
13258
13259static struct hda_verb alc267_quanta_il1_verbs[] = {
13260 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13261 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13262 { }
13263};
13264
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013265static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013266{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013267 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013268 spec->autocfg.hp_pins[0] = 0x15;
13269 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013270 spec->ext_mic.pin = 0x18;
13271 spec->ext_mic.mux_idx = 0;
13272 spec->int_mic.pin = 0x19;
13273 spec->int_mic.mux_idx = 1;
13274 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013275}
13276
Kailang Yanga361d842007-06-05 12:30:55 +020013277/*
13278 * generic initialization of ADC, input mixers and output mixers
13279 */
13280static struct hda_verb alc268_base_init_verbs[] = {
13281 /* Unmute DAC0-1 and set vol = 0 */
13282 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013283 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013284
13285 /*
13286 * Set up output mixers (0x0c - 0x0e)
13287 */
13288 /* set vol=0 to output mixers */
13289 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013290 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13291
13292 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13293 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13294
13295 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13297 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13298 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13299 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13300 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13301 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13302 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13303
13304 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13305 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13306 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13307 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013308 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013309
13310 /* set PCBEEP vol = 0, mute connections */
13311 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13312 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13313 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013314
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013315 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013316
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013317 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13318 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13319 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13320 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013321
Kailang Yanga361d842007-06-05 12:30:55 +020013322 { }
13323};
13324
13325/*
13326 * generic initialization of ADC, input mixers and output mixers
13327 */
13328static struct hda_verb alc268_volume_init_verbs[] = {
13329 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013330 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13331 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013332
13333 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13334 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13335 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13336 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13337 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13338
Kailang Yanga361d842007-06-05 12:30:55 +020013339 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013340 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13341 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13342
13343 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013344 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013345
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013346 /* set PCBEEP vol = 0, mute connections */
13347 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13348 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13349 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013350
13351 { }
13352};
13353
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013354static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13355 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13356 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13357 { } /* end */
13358};
13359
Kailang Yanga361d842007-06-05 12:30:55 +020013360static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13361 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13362 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013363 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013364 { } /* end */
13365};
13366
13367static struct snd_kcontrol_new alc268_capture_mixer[] = {
13368 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13369 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13370 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13371 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013372 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013373 { } /* end */
13374};
13375
13376static struct hda_input_mux alc268_capture_source = {
13377 .num_items = 4,
13378 .items = {
13379 { "Mic", 0x0 },
13380 { "Front Mic", 0x1 },
13381 { "Line", 0x2 },
13382 { "CD", 0x3 },
13383 },
13384};
13385
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013386static struct hda_input_mux alc268_acer_capture_source = {
13387 .num_items = 3,
13388 .items = {
13389 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013390 { "Internal Mic", 0x1 },
13391 { "Line", 0x2 },
13392 },
13393};
13394
13395static struct hda_input_mux alc268_acer_dmic_capture_source = {
13396 .num_items = 3,
13397 .items = {
13398 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013399 { "Internal Mic", 0x6 },
13400 { "Line", 0x2 },
13401 },
13402};
13403
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013404#ifdef CONFIG_SND_DEBUG
13405static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013406 /* Volume widgets */
13407 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13408 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13409 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13410 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13411 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13412 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13413 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13414 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13415 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13416 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13417 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13418 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13419 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013420 /* The below appears problematic on some hardwares */
13421 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013422 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13423 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13424 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13425 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13426
13427 /* Modes for retasking pin widgets */
13428 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13429 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13430 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13431 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13432
13433 /* Controls for GPIO pins, assuming they are configured as outputs */
13434 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13435 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13436 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13437 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13438
13439 /* Switches to allow the digital SPDIF output pin to be enabled.
13440 * The ALC268 does not have an SPDIF input.
13441 */
13442 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13443
13444 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13445 * this output to turn on an external amplifier.
13446 */
13447 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13448 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13449
13450 { } /* end */
13451};
13452#endif
13453
Kailang Yanga361d842007-06-05 12:30:55 +020013454/* create input playback/capture controls for the given pin */
13455static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13456 const char *ctlname, int idx)
13457{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013458 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013459 int err;
13460
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013461 switch (nid) {
13462 case 0x14:
13463 case 0x16:
13464 dac = 0x02;
13465 break;
13466 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013467 case 0x1a: /* ALC259/269 only */
13468 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013469 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013470 dac = 0x03;
13471 break;
13472 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013473 snd_printd(KERN_WARNING "hda_codec: "
13474 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013475 return 0;
13476 }
13477 if (spec->multiout.dac_nids[0] != dac &&
13478 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013479 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013480 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013481 HDA_OUTPUT));
13482 if (err < 0)
13483 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013484 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13485 }
13486
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013487 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013488 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013489 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013490 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013491 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013492 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013493 if (err < 0)
13494 return err;
13495 return 0;
13496}
13497
13498/* add playback controls from the parsed DAC table */
13499static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13500 const struct auto_pin_cfg *cfg)
13501{
13502 hda_nid_t nid;
13503 int err;
13504
Kailang Yanga361d842007-06-05 12:30:55 +020013505 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013506
13507 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013508 if (nid) {
13509 const char *name;
13510 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13511 name = "Speaker";
13512 else
13513 name = "Front";
13514 err = alc268_new_analog_output(spec, nid, name, 0);
13515 if (err < 0)
13516 return err;
13517 }
Kailang Yanga361d842007-06-05 12:30:55 +020013518
13519 nid = cfg->speaker_pins[0];
13520 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013521 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013522 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13523 if (err < 0)
13524 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013525 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013526 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13527 if (err < 0)
13528 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013529 }
13530 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013531 if (nid) {
13532 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13533 if (err < 0)
13534 return err;
13535 }
Kailang Yanga361d842007-06-05 12:30:55 +020013536
13537 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13538 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013539 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013540 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013541 if (err < 0)
13542 return err;
13543 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013544 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013545}
13546
13547/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013548static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013549 const struct auto_pin_cfg *cfg)
13550{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013551 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013552}
13553
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013554static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13555 hda_nid_t nid, int pin_type)
13556{
13557 int idx;
13558
13559 alc_set_pin_output(codec, nid, pin_type);
13560 if (nid == 0x14 || nid == 0x16)
13561 idx = 0;
13562 else
13563 idx = 1;
13564 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13565}
13566
13567static void alc268_auto_init_multi_out(struct hda_codec *codec)
13568{
13569 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013570 int i;
13571
13572 for (i = 0; i < spec->autocfg.line_outs; i++) {
13573 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013574 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13575 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13576 }
13577}
13578
13579static void alc268_auto_init_hp_out(struct hda_codec *codec)
13580{
13581 struct alc_spec *spec = codec->spec;
13582 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013583 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013584
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013585 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13586 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013587 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013588 }
13589 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13590 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013591 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013592 }
13593 if (spec->autocfg.mono_out_pin)
13594 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13595 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013596}
13597
Kailang Yanga361d842007-06-05 12:30:55 +020013598static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13599{
13600 struct alc_spec *spec = codec->spec;
13601 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13602 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13603 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13604 unsigned int dac_vol1, dac_vol2;
13605
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013606 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013607 snd_hda_codec_write(codec, speaker_nid, 0,
13608 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013609 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013610 snd_hda_codec_write(codec, 0x0f, 0,
13611 AC_VERB_SET_AMP_GAIN_MUTE,
13612 AMP_IN_UNMUTE(1));
13613 snd_hda_codec_write(codec, 0x10, 0,
13614 AC_VERB_SET_AMP_GAIN_MUTE,
13615 AMP_IN_UNMUTE(1));
13616 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013617 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013618 snd_hda_codec_write(codec, 0x0f, 0,
13619 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13620 snd_hda_codec_write(codec, 0x10, 0,
13621 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13622 }
13623
13624 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013625 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013626 dac_vol2 = AMP_OUT_ZERO;
13627 else if (line_nid == 0x15)
13628 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013629 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013630 dac_vol2 = AMP_OUT_ZERO;
13631 else if (hp_nid == 0x15)
13632 dac_vol1 = AMP_OUT_ZERO;
13633 if (line_nid != 0x16 || hp_nid != 0x16 ||
13634 spec->autocfg.line_out_pins[1] != 0x16 ||
13635 spec->autocfg.line_out_pins[2] != 0x16)
13636 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13637
13638 snd_hda_codec_write(codec, 0x02, 0,
13639 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13640 snd_hda_codec_write(codec, 0x03, 0,
13641 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13642}
13643
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013644/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013645#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13646#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013647#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013648#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13649
13650/*
13651 * BIOS auto configuration
13652 */
13653static int alc268_parse_auto_config(struct hda_codec *codec)
13654{
13655 struct alc_spec *spec = codec->spec;
13656 int err;
13657 static hda_nid_t alc268_ignore[] = { 0 };
13658
13659 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13660 alc268_ignore);
13661 if (err < 0)
13662 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013663 if (!spec->autocfg.line_outs) {
13664 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13665 spec->multiout.max_channels = 2;
13666 spec->no_analog = 1;
13667 goto dig_only;
13668 }
Kailang Yanga361d842007-06-05 12:30:55 +020013669 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013670 }
Kailang Yanga361d842007-06-05 12:30:55 +020013671 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13672 if (err < 0)
13673 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013674 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013675 if (err < 0)
13676 return err;
13677
13678 spec->multiout.max_channels = 2;
13679
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013680 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013681 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013682 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013683 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013684 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013685
Takashi Iwai892981f2009-03-02 08:04:35 +010013686 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013687 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013688
Takashi Iwaid88897e2008-10-31 15:01:37 +010013689 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013690 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013691 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013692
Takashi Iwai776e1842007-08-29 15:07:11 +020013693 err = alc_auto_add_mic_boost(codec);
13694 if (err < 0)
13695 return err;
13696
Kailang Yang6227cdc2010-02-25 08:36:52 +010013697 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013698
Kailang Yanga361d842007-06-05 12:30:55 +020013699 return 1;
13700}
13701
Kailang Yanga361d842007-06-05 12:30:55 +020013702#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13703
13704/* init callback for auto-configuration model -- overriding the default init */
13705static void alc268_auto_init(struct hda_codec *codec)
13706{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013707 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013708 alc268_auto_init_multi_out(codec);
13709 alc268_auto_init_hp_out(codec);
13710 alc268_auto_init_mono_speaker_out(codec);
13711 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013712 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013713 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013714 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013715}
13716
13717/*
13718 * configuration and preset
13719 */
13720static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013721 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013722 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013723 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013724 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013725 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013726 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013727 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013728 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013729#ifdef CONFIG_SND_DEBUG
13730 [ALC268_TEST] = "test",
13731#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013732 [ALC268_AUTO] = "auto",
13733};
13734
13735static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013736 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013737 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013738 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013739 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013740 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013741 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13742 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013743 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013744 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13745 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013746 /* almost compatible with toshiba but with optional digital outs;
13747 * auto-probing seems working fine
13748 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013749 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013750 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013751 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013752 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013753 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013754 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013755 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013756 {}
13757};
13758
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013759/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13760static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13761 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13762 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13763 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13764 ALC268_TOSHIBA),
13765 {}
13766};
13767
Kailang Yanga361d842007-06-05 12:30:55 +020013768static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013769 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013770 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13771 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013772 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13773 alc267_quanta_il1_verbs },
13774 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13775 .dac_nids = alc268_dac_nids,
13776 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13777 .adc_nids = alc268_adc_nids_alt,
13778 .hp_nid = 0x03,
13779 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13780 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013781 .unsol_event = alc_sku_unsol_event,
13782 .setup = alc267_quanta_il1_setup,
13783 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013784 },
Kailang Yanga361d842007-06-05 12:30:55 +020013785 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013786 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13787 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013788 .init_verbs = { alc268_base_init_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,
Kailang Yanga361d842007-06-05 12:30:55 +020013794 .hp_nid = 0x03,
13795 .dig_out_nid = ALC268_DIGOUT_NID,
13796 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13797 .channel_mode = alc268_modes,
13798 .input_mux = &alc268_capture_source,
13799 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013800 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013801 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013802 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013803 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13804 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013805 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13806 .dac_nids = alc268_dac_nids,
13807 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13808 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013809 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013810 .hp_nid = 0x03,
13811 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13812 .channel_mode = alc268_modes,
13813 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013814 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013815 .setup = alc268_toshiba_setup,
13816 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013817 },
13818 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013819 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013820 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013821 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13822 alc268_acer_verbs },
13823 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13824 .dac_nids = alc268_dac_nids,
13825 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13826 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013827 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013828 .hp_nid = 0x02,
13829 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13830 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013831 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013832 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013833 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013834 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013835 [ALC268_ACER_DMIC] = {
13836 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13837 alc268_beep_mixer },
13838 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13839 alc268_acer_verbs },
13840 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13841 .dac_nids = alc268_dac_nids,
13842 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13843 .adc_nids = alc268_adc_nids_alt,
13844 .capsrc_nids = alc268_capsrc_nids,
13845 .hp_nid = 0x02,
13846 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13847 .channel_mode = alc268_modes,
13848 .input_mux = &alc268_acer_dmic_capture_source,
13849 .unsol_event = alc268_acer_unsol_event,
13850 .init_hook = alc268_acer_init_hook,
13851 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013852 [ALC268_ACER_ASPIRE_ONE] = {
13853 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013854 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013855 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013856 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13857 alc268_acer_aspire_one_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,
13862 .capsrc_nids = alc268_capsrc_nids,
13863 .hp_nid = 0x03,
13864 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13865 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013866 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013867 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013868 .init_hook = alc268_acer_lc_init_hook,
13869 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013870 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013871 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13872 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013873 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13874 alc268_dell_verbs },
13875 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13876 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013877 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13878 .adc_nids = alc268_adc_nids_alt,
13879 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013880 .hp_nid = 0x02,
13881 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13882 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013883 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013884 .setup = alc268_dell_setup,
13885 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013886 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013887 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013888 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13889 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013890 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13891 alc268_toshiba_verbs },
13892 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13893 .dac_nids = alc268_dac_nids,
13894 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13895 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013896 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013897 .hp_nid = 0x03,
13898 .dig_out_nid = ALC268_DIGOUT_NID,
13899 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13900 .channel_mode = alc268_modes,
13901 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013902 .setup = alc268_toshiba_setup,
13903 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013904 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013905#ifdef CONFIG_SND_DEBUG
13906 [ALC268_TEST] = {
13907 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13908 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13909 alc268_volume_init_verbs },
13910 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13911 .dac_nids = alc268_dac_nids,
13912 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13913 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013914 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013915 .hp_nid = 0x03,
13916 .dig_out_nid = ALC268_DIGOUT_NID,
13917 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13918 .channel_mode = alc268_modes,
13919 .input_mux = &alc268_capture_source,
13920 },
13921#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013922};
13923
13924static int patch_alc268(struct hda_codec *codec)
13925{
13926 struct alc_spec *spec;
13927 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013928 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013929
Julia Lawallef86f582009-12-19 08:18:03 +010013930 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013931 if (spec == NULL)
13932 return -ENOMEM;
13933
13934 codec->spec = spec;
13935
13936 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13937 alc268_models,
13938 alc268_cfg_tbl);
13939
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013940 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13941 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013942 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013943
Kailang Yanga361d842007-06-05 12:30:55 +020013944 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013945 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13946 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013947 board_config = ALC268_AUTO;
13948 }
13949
13950 if (board_config == ALC268_AUTO) {
13951 /* automatic parse from the BIOS config */
13952 err = alc268_parse_auto_config(codec);
13953 if (err < 0) {
13954 alc_free(codec);
13955 return err;
13956 } else if (!err) {
13957 printk(KERN_INFO
13958 "hda_codec: Cannot set up configuration "
13959 "from BIOS. Using base mode...\n");
13960 board_config = ALC268_3ST;
13961 }
13962 }
13963
13964 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013965 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013966
Kailang Yanga361d842007-06-05 12:30:55 +020013967 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13968 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013969 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013970
Kailang Yanga361d842007-06-05 12:30:55 +020013971 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13972
Takashi Iwai22971e32009-02-10 11:56:44 +010013973 has_beep = 0;
13974 for (i = 0; i < spec->num_mixers; i++) {
13975 if (spec->mixers[i] == alc268_beep_mixer) {
13976 has_beep = 1;
13977 break;
13978 }
13979 }
13980
13981 if (has_beep) {
13982 err = snd_hda_attach_beep_device(codec, 0x1);
13983 if (err < 0) {
13984 alc_free(codec);
13985 return err;
13986 }
13987 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13988 /* override the amp caps for beep generator */
13989 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013990 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13991 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13992 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13993 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013994 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013995
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013996 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013997 /* check whether NID 0x07 is valid */
13998 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013999 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020014000
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014001 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014002 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020014003 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014004 if (spec->auto_mic ||
14005 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014006 spec->adc_nids = alc268_adc_nids_alt;
14007 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014008 if (spec->auto_mic)
14009 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014010 if (spec->auto_mic || spec->input_mux->num_items == 1)
14011 add_mixer(spec, alc268_capture_nosrc_mixer);
14012 else
14013 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014014 } else {
14015 spec->adc_nids = alc268_adc_nids;
14016 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010014017 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020014018 }
Takashi Iwai85860c02008-02-19 15:00:15 +010014019 /* set default input source */
14020 for (i = 0; i < spec->num_adc_nids; i++)
14021 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
14022 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030014023 i < spec->num_mux_defs ?
14024 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010014025 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020014026 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010014027
14028 spec->vmaster_nid = 0x02;
14029
Kailang Yanga361d842007-06-05 12:30:55 +020014030 codec->patch_ops = alc_patch_ops;
14031 if (board_config == ALC268_AUTO)
14032 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020014033
Kailang Yangbf1b0222010-10-21 08:49:56 +020014034 alc_init_jacks(codec);
14035
Kailang Yanga361d842007-06-05 12:30:55 +020014036 return 0;
14037}
14038
14039/*
Kailang Yangf6a92242007-12-13 16:52:54 +010014040 * ALC269 channel source setting (2 channel)
14041 */
14042#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
14043
14044#define alc269_dac_nids alc260_dac_nids
14045
14046static hda_nid_t alc269_adc_nids[1] = {
14047 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020014048 0x08,
14049};
14050
Takashi Iwaie01bf502008-08-21 16:25:07 +020014051static hda_nid_t alc269_capsrc_nids[1] = {
14052 0x23,
14053};
14054
Kailang Yang84898e82010-02-04 14:16:14 +010014055static hda_nid_t alc269vb_adc_nids[1] = {
14056 /* ADC1 */
14057 0x09,
14058};
14059
14060static hda_nid_t alc269vb_capsrc_nids[1] = {
14061 0x22,
14062};
14063
Takashi Iwai66946352010-03-29 17:21:45 +020014064static hda_nid_t alc269_adc_candidates[] = {
14065 0x08, 0x09, 0x07,
14066};
Takashi Iwaie01bf502008-08-21 16:25:07 +020014067
Kailang Yangf6a92242007-12-13 16:52:54 +010014068#define alc269_modes alc260_modes
14069#define alc269_capture_source alc880_lg_lw_capture_source
14070
14071static struct snd_kcontrol_new alc269_base_mixer[] = {
14072 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14073 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14074 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14075 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14076 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14077 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14078 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14079 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14080 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14081 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14082 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14083 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14084 { } /* end */
14085};
14086
Kailang Yang60db6b52008-08-26 13:13:00 +020014087static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14088 /* output mixer control */
14089 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14090 {
14091 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14092 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014093 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014094 .info = snd_hda_mixer_amp_switch_info,
14095 .get = snd_hda_mixer_amp_switch_get,
14096 .put = alc268_acer_master_sw_put,
14097 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14098 },
14099 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14100 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14101 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14102 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14103 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14104 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014105 { }
14106};
14107
Tony Vroon64154832008-11-06 15:08:49 +000014108static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14109 /* output mixer control */
14110 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14111 {
14112 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14113 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014114 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014115 .info = snd_hda_mixer_amp_switch_info,
14116 .get = snd_hda_mixer_amp_switch_get,
14117 .put = alc268_acer_master_sw_put,
14118 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14119 },
14120 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14121 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14122 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14123 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14124 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14125 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
14126 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14127 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
14128 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014129 { }
14130};
14131
Kailang Yang84898e82010-02-04 14:16:14 +010014132static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014133 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014134 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014135 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014136 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014137 { } /* end */
14138};
14139
Kailang Yang84898e82010-02-04 14:16:14 +010014140static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14141 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14142 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14143 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14144 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14145 { } /* end */
14146};
14147
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014148static struct snd_kcontrol_new alc269_asus_mixer[] = {
14149 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14150 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14151 { } /* end */
14152};
14153
Kailang Yangf6a92242007-12-13 16:52:54 +010014154/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014155static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14156 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14157 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
14158 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14159 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14160 { } /* end */
14161};
14162
14163static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014164 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14165 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014166 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14167 { } /* end */
14168};
14169
Kailang Yang84898e82010-02-04 14:16:14 +010014170static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14171 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14172 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14173 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14174 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14175 { } /* end */
14176};
14177
14178static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14179 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14180 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14181 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14182 { } /* end */
14183};
14184
Takashi Iwai26f5df22008-11-03 17:39:46 +010014185/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014186#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014187
Kailang Yang60db6b52008-08-26 13:13:00 +020014188static struct hda_verb alc269_quanta_fl1_verbs[] = {
14189 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14190 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14191 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14192 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14193 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14194 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14195 { }
14196};
14197
Tony Vroon64154832008-11-06 15:08:49 +000014198static struct hda_verb alc269_lifebook_verbs[] = {
14199 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14200 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14201 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14202 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14203 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14204 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14205 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14206 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14207 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14208 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14209 { }
14210};
14211
Kailang Yang60db6b52008-08-26 13:13:00 +020014212/* toggle speaker-output according to the hp-jack state */
14213static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14214{
14215 unsigned int present;
14216 unsigned char bits;
14217
Wu Fengguang864f92b2009-11-18 12:38:02 +080014218 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014219 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014220 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014221 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014222 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014223 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014224
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, 0x680);
14229
14230 snd_hda_codec_write(codec, 0x20, 0,
14231 AC_VERB_SET_COEF_INDEX, 0x0c);
14232 snd_hda_codec_write(codec, 0x20, 0,
14233 AC_VERB_SET_PROC_COEF, 0x480);
14234}
14235
Tony Vroon64154832008-11-06 15:08:49 +000014236/* toggle speaker-output according to the hp-jacks state */
14237static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14238{
14239 unsigned int present;
14240 unsigned char bits;
14241
14242 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014243 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014244
14245 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014246 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014247
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014248 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014249 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014250 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014251 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014252 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014253
14254 snd_hda_codec_write(codec, 0x20, 0,
14255 AC_VERB_SET_COEF_INDEX, 0x0c);
14256 snd_hda_codec_write(codec, 0x20, 0,
14257 AC_VERB_SET_PROC_COEF, 0x680);
14258
14259 snd_hda_codec_write(codec, 0x20, 0,
14260 AC_VERB_SET_COEF_INDEX, 0x0c);
14261 snd_hda_codec_write(codec, 0x20, 0,
14262 AC_VERB_SET_PROC_COEF, 0x480);
14263}
14264
Tony Vroon64154832008-11-06 15:08:49 +000014265static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14266{
14267 unsigned int present_laptop;
14268 unsigned int present_dock;
14269
Wu Fengguang864f92b2009-11-18 12:38:02 +080014270 present_laptop = snd_hda_jack_detect(codec, 0x18);
14271 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014272
14273 /* Laptop mic port overrides dock mic port, design decision */
14274 if (present_dock)
14275 snd_hda_codec_write(codec, 0x23, 0,
14276 AC_VERB_SET_CONNECT_SEL, 0x3);
14277 if (present_laptop)
14278 snd_hda_codec_write(codec, 0x23, 0,
14279 AC_VERB_SET_CONNECT_SEL, 0x0);
14280 if (!present_dock && !present_laptop)
14281 snd_hda_codec_write(codec, 0x23, 0,
14282 AC_VERB_SET_CONNECT_SEL, 0x1);
14283}
14284
Kailang Yang60db6b52008-08-26 13:13:00 +020014285static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14286 unsigned int res)
14287{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014288 switch (res >> 26) {
14289 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014290 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014291 break;
14292 case ALC880_MIC_EVENT:
14293 alc_mic_automute(codec);
14294 break;
14295 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014296}
14297
Tony Vroon64154832008-11-06 15:08:49 +000014298static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14299 unsigned int res)
14300{
14301 if ((res >> 26) == ALC880_HP_EVENT)
14302 alc269_lifebook_speaker_automute(codec);
14303 if ((res >> 26) == ALC880_MIC_EVENT)
14304 alc269_lifebook_mic_autoswitch(codec);
14305}
14306
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014307static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14308{
14309 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014310 spec->autocfg.hp_pins[0] = 0x15;
14311 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014312 spec->ext_mic.pin = 0x18;
14313 spec->ext_mic.mux_idx = 0;
14314 spec->int_mic.pin = 0x19;
14315 spec->int_mic.mux_idx = 1;
14316 spec->auto_mic = 1;
14317}
14318
Kailang Yang60db6b52008-08-26 13:13:00 +020014319static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14320{
14321 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014322 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014323}
14324
Tony Vroon64154832008-11-06 15:08:49 +000014325static void alc269_lifebook_init_hook(struct hda_codec *codec)
14326{
14327 alc269_lifebook_speaker_automute(codec);
14328 alc269_lifebook_mic_autoswitch(codec);
14329}
14330
Kailang Yang84898e82010-02-04 14:16:14 +010014331static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014332 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14333 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14334 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14335 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14336 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14337 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14338 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14339 {}
14340};
14341
Kailang Yang84898e82010-02-04 14:16:14 +010014342static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014343 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14344 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14345 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14346 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14347 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14348 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14349 {}
14350};
14351
Kailang Yang84898e82010-02-04 14:16:14 +010014352static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14353 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14354 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14355 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14356 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14357 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14358 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14359 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14360 {}
14361};
14362
14363static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14364 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14365 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14366 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14367 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14368 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14369 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14370 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14371 {}
14372};
14373
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014374static struct hda_verb alc271_acer_dmic_verbs[] = {
14375 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14376 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14377 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14378 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14379 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14380 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14381 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14382 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14383 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14384 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14385 { }
14386};
14387
Kailang Yang60db6b52008-08-26 13:13:00 +020014388/* toggle speaker-output according to the hp-jack state */
14389static void alc269_speaker_automute(struct hda_codec *codec)
14390{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014391 struct alc_spec *spec = codec->spec;
14392 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014393 unsigned int present;
14394 unsigned char bits;
14395
Kailang Yangebb83ee2009-12-17 12:23:00 +010014396 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014397 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014398 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014399 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014400 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014401 HDA_AMP_MUTE, bits);
Kailang Yangbf1b0222010-10-21 08:49:56 +020014402 alc_report_jack(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020014403}
14404
Kailang Yang60db6b52008-08-26 13:13:00 +020014405/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014406static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014407 unsigned int res)
14408{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014409 switch (res >> 26) {
14410 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014411 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014412 break;
14413 case ALC880_MIC_EVENT:
14414 alc_mic_automute(codec);
14415 break;
14416 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014417}
14418
Kailang Yang226b1ec2010-04-09 11:01:20 +020014419static void alc269_laptop_amic_setup(struct hda_codec *codec)
14420{
14421 struct alc_spec *spec = codec->spec;
14422 spec->autocfg.hp_pins[0] = 0x15;
14423 spec->autocfg.speaker_pins[0] = 0x14;
14424 spec->ext_mic.pin = 0x18;
14425 spec->ext_mic.mux_idx = 0;
14426 spec->int_mic.pin = 0x19;
14427 spec->int_mic.mux_idx = 1;
14428 spec->auto_mic = 1;
14429}
14430
Kailang Yang84898e82010-02-04 14:16:14 +010014431static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014432{
14433 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014434 spec->autocfg.hp_pins[0] = 0x15;
14435 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014436 spec->ext_mic.pin = 0x18;
14437 spec->ext_mic.mux_idx = 0;
14438 spec->int_mic.pin = 0x12;
14439 spec->int_mic.mux_idx = 5;
14440 spec->auto_mic = 1;
14441}
14442
Kailang Yang226b1ec2010-04-09 11:01:20 +020014443static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014444{
14445 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014446 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014447 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014448 spec->ext_mic.pin = 0x18;
14449 spec->ext_mic.mux_idx = 0;
14450 spec->int_mic.pin = 0x19;
14451 spec->int_mic.mux_idx = 1;
14452 spec->auto_mic = 1;
14453}
14454
Kailang Yang226b1ec2010-04-09 11:01:20 +020014455static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14456{
14457 struct alc_spec *spec = codec->spec;
14458 spec->autocfg.hp_pins[0] = 0x21;
14459 spec->autocfg.speaker_pins[0] = 0x14;
14460 spec->ext_mic.pin = 0x18;
14461 spec->ext_mic.mux_idx = 0;
14462 spec->int_mic.pin = 0x12;
14463 spec->int_mic.mux_idx = 6;
14464 spec->auto_mic = 1;
14465}
14466
Kailang Yang84898e82010-02-04 14:16:14 +010014467static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014468{
14469 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014470 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014471}
14472
Kailang Yangf6a92242007-12-13 16:52:54 +010014473/*
14474 * generic initialization of ADC, input mixers and output mixers
14475 */
14476static struct hda_verb alc269_init_verbs[] = {
14477 /*
14478 * Unmute ADC0 and set the default input to mic-in
14479 */
Kailang Yang84898e82010-02-04 14:16:14 +010014480 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014481
14482 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014483 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014484 */
14485 /* set vol=0 to output mixers */
14486 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14487 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14488
14489 /* set up input amps for analog loopback */
14490 /* Amp Indices: DAC = 0, mixer = 1 */
14491 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14492 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14493 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14494 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14495 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14496 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14497
14498 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14499 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14500 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14501 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14502 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14503 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14504 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14505
14506 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14507 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014508
Kailang Yang84898e82010-02-04 14:16:14 +010014509 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014510 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14511 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014512 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014513
14514 /* set EAPD */
14515 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014516 { }
14517};
14518
14519static struct hda_verb alc269vb_init_verbs[] = {
14520 /*
14521 * Unmute ADC0 and set the default input to mic-in
14522 */
14523 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14524
14525 /*
14526 * Set up output mixers (0x02 - 0x03)
14527 */
14528 /* set vol=0 to output mixers */
14529 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14530 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14531
14532 /* set up input amps for analog loopback */
14533 /* Amp Indices: DAC = 0, mixer = 1 */
14534 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14535 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14536 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14537 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14538 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14539 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14540
14541 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14542 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14543 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14544 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14545 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14546 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14547 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14548
14549 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14550 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14551
14552 /* FIXME: use Mux-type input source selection */
14553 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14554 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14555 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14556
14557 /* set EAPD */
14558 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014559 { }
14560};
14561
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014562#define alc269_auto_create_multi_out_ctls \
14563 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014564#define alc269_auto_create_input_ctls \
14565 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014566
14567#ifdef CONFIG_SND_HDA_POWER_SAVE
14568#define alc269_loopbacks alc880_loopbacks
14569#endif
14570
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014571/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014572#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14573#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14574#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14575#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14576
Takashi Iwaif03d3112009-03-05 14:18:16 +010014577static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14578 .substreams = 1,
14579 .channels_min = 2,
14580 .channels_max = 8,
14581 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14582 /* NID is set in alc_build_pcms */
14583 .ops = {
14584 .open = alc880_playback_pcm_open,
14585 .prepare = alc880_playback_pcm_prepare,
14586 .cleanup = alc880_playback_pcm_cleanup
14587 },
14588};
14589
14590static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14591 .substreams = 1,
14592 .channels_min = 2,
14593 .channels_max = 2,
14594 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14595 /* NID is set in alc_build_pcms */
14596};
14597
Takashi Iwaiad358792010-03-30 18:00:59 +020014598#ifdef CONFIG_SND_HDA_POWER_SAVE
14599static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14600{
14601 switch (codec->subsystem_id) {
14602 case 0x103c1586:
14603 return 1;
14604 }
14605 return 0;
14606}
14607
14608static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14609{
14610 /* update mute-LED according to the speaker mute state */
14611 if (nid == 0x01 || nid == 0x14) {
14612 int pinval;
14613 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14614 HDA_AMP_MUTE)
14615 pinval = 0x24;
14616 else
14617 pinval = 0x20;
14618 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014619 snd_hda_codec_update_cache(codec, 0x19, 0,
14620 AC_VERB_SET_PIN_WIDGET_CONTROL,
14621 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014622 }
14623 return alc_check_power_status(codec, nid);
14624}
14625#endif /* CONFIG_SND_HDA_POWER_SAVE */
14626
Takashi Iwai840b64c2010-07-13 22:49:01 +020014627static int alc275_setup_dual_adc(struct hda_codec *codec)
14628{
14629 struct alc_spec *spec = codec->spec;
14630
14631 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14632 return 0;
14633 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14634 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14635 if (spec->ext_mic.pin <= 0x12) {
14636 spec->private_adc_nids[0] = 0x08;
14637 spec->private_adc_nids[1] = 0x11;
14638 spec->private_capsrc_nids[0] = 0x23;
14639 spec->private_capsrc_nids[1] = 0x22;
14640 } else {
14641 spec->private_adc_nids[0] = 0x11;
14642 spec->private_adc_nids[1] = 0x08;
14643 spec->private_capsrc_nids[0] = 0x22;
14644 spec->private_capsrc_nids[1] = 0x23;
14645 }
14646 spec->adc_nids = spec->private_adc_nids;
14647 spec->capsrc_nids = spec->private_capsrc_nids;
14648 spec->num_adc_nids = 2;
14649 spec->dual_adc_switch = 1;
14650 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14651 spec->adc_nids[0], spec->adc_nids[1]);
14652 return 1;
14653 }
14654 return 0;
14655}
14656
Takashi Iwaid433a672010-09-20 15:11:54 +020014657/* different alc269-variants */
14658enum {
14659 ALC269_TYPE_NORMAL,
Kailang Yang48c88e82010-11-23 08:56:16 +010014660 ALC269_TYPE_ALC258,
Takashi Iwaid433a672010-09-20 15:11:54 +020014661 ALC269_TYPE_ALC259,
Kailang Yang48c88e82010-11-23 08:56:16 +010014662 ALC269_TYPE_ALC269VB,
14663 ALC269_TYPE_ALC270,
Takashi Iwaid433a672010-09-20 15:11:54 +020014664 ALC269_TYPE_ALC271X,
14665};
14666
Kailang Yangf6a92242007-12-13 16:52:54 +010014667/*
14668 * BIOS auto configuration
14669 */
14670static int alc269_parse_auto_config(struct hda_codec *codec)
14671{
14672 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014673 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014674 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14675
14676 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14677 alc269_ignore);
14678 if (err < 0)
14679 return err;
14680
14681 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14682 if (err < 0)
14683 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014684 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14685 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14686 else
14687 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14688 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014689 if (err < 0)
14690 return err;
14691
14692 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14693
Takashi Iwai757899a2010-07-30 10:48:14 +020014694 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014695
Takashi Iwai603c4012008-07-30 15:01:44 +020014696 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014697 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014698
Takashi Iwaid433a672010-09-20 15:11:54 +020014699 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014700 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014701 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014702 } else {
14703 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014704 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014705 }
14706
Kailang Yangf6a92242007-12-13 16:52:54 +010014707 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014708 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014709
14710 if (!alc275_setup_dual_adc(codec))
14711 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14712 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014713
Takashi Iwaie01bf502008-08-21 16:25:07 +020014714 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014715 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014716 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14717 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014718
14719 err = alc_auto_add_mic_boost(codec);
14720 if (err < 0)
14721 return err;
14722
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014723 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014724 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014725
Kailang Yangf6a92242007-12-13 16:52:54 +010014726 return 1;
14727}
14728
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014729#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14730#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014731#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14732
14733
14734/* init callback for auto-configuration model -- overriding the default init */
14735static void alc269_auto_init(struct hda_codec *codec)
14736{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014737 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014738 alc269_auto_init_multi_out(codec);
14739 alc269_auto_init_hp_out(codec);
14740 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014741 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014742 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014743 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014744}
14745
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014746#ifdef SND_HDA_NEEDS_RESUME
14747static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14748{
14749 int val = alc_read_coef_idx(codec, 0x04);
14750 if (power_up)
14751 val |= 1 << 11;
14752 else
14753 val &= ~(1 << 11);
14754 alc_write_coef_idx(codec, 0x04, val);
14755}
14756
Kailang Yang977ddd62010-09-15 10:02:29 +020014757#ifdef CONFIG_SND_HDA_POWER_SAVE
14758static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14759{
14760 struct alc_spec *spec = codec->spec;
Kailang Yang977ddd62010-09-15 10:02:29 +020014761
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014762 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14763 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014764 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014765 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014766 msleep(150);
14767 }
14768
14769 alc_shutup(codec);
14770 if (spec && spec->power_hook)
14771 spec->power_hook(codec);
14772 return 0;
14773}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014774#endif /* CONFIG_SND_HDA_POWER_SAVE */
14775
Kailang Yang977ddd62010-09-15 10:02:29 +020014776static int alc269_resume(struct hda_codec *codec)
14777{
Kailang Yang977ddd62010-09-15 10:02:29 +020014778 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014779 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014780 msleep(150);
14781 }
14782
14783 codec->patch_ops.init(codec);
14784
14785 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014786 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014787 msleep(200);
14788 }
14789
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014790 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14791 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014792
14793 snd_hda_codec_resume_amp(codec);
14794 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014795 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014796 return 0;
14797}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014798#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014799
Takashi Iwaiff818c22010-04-12 08:59:25 +020014800enum {
14801 ALC269_FIXUP_SONY_VAIO,
David Henningsson145a9022010-09-16 10:07:53 +020014802 ALC269_FIXUP_DELL_M101Z,
David Henningssonfe67b242010-12-15 08:01:46 +010014803 ALC269_FIXUP_LENOVO_EDGE14,
David Henningssonac612402010-12-15 09:18:18 +010014804 ALC269_FIXUP_ASUS_G73JW,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014805};
14806
Takashi Iwaiff818c22010-04-12 08:59:25 +020014807static const struct alc_fixup alc269_fixups[] = {
14808 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020014809 .verbs = (const struct hda_verb[]) {
14810 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14811 {}
14812 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014813 },
David Henningsson145a9022010-09-16 10:07:53 +020014814 [ALC269_FIXUP_DELL_M101Z] = {
14815 .verbs = (const struct hda_verb[]) {
14816 /* Enables internal speaker */
14817 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14818 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14819 {}
14820 }
14821 },
David Henningssonfe67b242010-12-15 08:01:46 +010014822 [ALC269_FIXUP_LENOVO_EDGE14] = {
14823 .sku = ALC_FIXUP_SKU_IGNORE,
14824 },
David Henningssonac612402010-12-15 09:18:18 +010014825 [ALC269_FIXUP_ASUS_G73JW] = {
14826 .pins = (const struct alc_pincfg[]) {
14827 { 0x17, 0x99130111 }, /* subwoofer */
14828 { }
14829 }
14830 },
Takashi Iwaiff818c22010-04-12 08:59:25 +020014831};
14832
14833static struct snd_pci_quirk alc269_fixup_tbl[] = {
Takashi Iwaiabdd8f52010-09-21 17:38:14 +020014834 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014835 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
David Henningssonfe67b242010-12-15 08:01:46 +010014836 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_LENOVO_EDGE14),
David Henningssonac612402010-12-15 09:18:18 +010014837 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014838 {}
14839};
14840
14841
Kailang Yangf6a92242007-12-13 16:52:54 +010014842/*
14843 * configuration and preset
14844 */
14845static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014846 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014847 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014848 [ALC269_AMIC] = "laptop-amic",
14849 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014850 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014851 [ALC269_LIFEBOOK] = "lifebook",
14852 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014853};
14854
14855static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014856 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014857 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014858 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014859 ALC269_AMIC),
14860 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14861 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14862 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14863 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14864 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14865 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14866 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14867 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14868 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14869 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14870 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14871 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14872 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14873 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14874 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14875 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14876 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14877 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14878 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14879 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14880 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14881 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14882 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14883 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14884 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14885 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14886 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14887 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14888 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14889 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14890 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14891 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14892 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14893 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14894 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14895 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014896 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014897 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014898 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014899 ALC269_DMIC),
14900 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14901 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014902 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014903 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014904 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14905 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14906 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14907 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14908 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14909 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014910 {}
14911};
14912
14913static struct alc_config_preset alc269_presets[] = {
14914 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014915 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014916 .init_verbs = { alc269_init_verbs },
14917 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14918 .dac_nids = alc269_dac_nids,
14919 .hp_nid = 0x03,
14920 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14921 .channel_mode = alc269_modes,
14922 .input_mux = &alc269_capture_source,
14923 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014924 [ALC269_QUANTA_FL1] = {
14925 .mixers = { alc269_quanta_fl1_mixer },
14926 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14927 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14928 .dac_nids = alc269_dac_nids,
14929 .hp_nid = 0x03,
14930 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14931 .channel_mode = alc269_modes,
14932 .input_mux = &alc269_capture_source,
14933 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014934 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014935 .init_hook = alc269_quanta_fl1_init_hook,
14936 },
Kailang Yang84898e82010-02-04 14:16:14 +010014937 [ALC269_AMIC] = {
14938 .mixers = { alc269_laptop_mixer },
14939 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014940 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014941 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014942 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14943 .dac_nids = alc269_dac_nids,
14944 .hp_nid = 0x03,
14945 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14946 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014947 .unsol_event = alc269_laptop_unsol_event,
14948 .setup = alc269_laptop_amic_setup,
14949 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014950 },
Kailang Yang84898e82010-02-04 14:16:14 +010014951 [ALC269_DMIC] = {
14952 .mixers = { alc269_laptop_mixer },
14953 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014954 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014955 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014956 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14957 .dac_nids = alc269_dac_nids,
14958 .hp_nid = 0x03,
14959 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14960 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014961 .unsol_event = alc269_laptop_unsol_event,
14962 .setup = alc269_laptop_dmic_setup,
14963 .init_hook = alc269_laptop_inithook,
14964 },
14965 [ALC269VB_AMIC] = {
14966 .mixers = { alc269vb_laptop_mixer },
14967 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14968 .init_verbs = { alc269vb_init_verbs,
14969 alc269vb_laptop_amic_init_verbs },
14970 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14971 .dac_nids = alc269_dac_nids,
14972 .hp_nid = 0x03,
14973 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14974 .channel_mode = alc269_modes,
14975 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014976 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014977 .init_hook = alc269_laptop_inithook,
14978 },
14979 [ALC269VB_DMIC] = {
14980 .mixers = { alc269vb_laptop_mixer },
14981 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14982 .init_verbs = { alc269vb_init_verbs,
14983 alc269vb_laptop_dmic_init_verbs },
14984 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14985 .dac_nids = alc269_dac_nids,
14986 .hp_nid = 0x03,
14987 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14988 .channel_mode = alc269_modes,
14989 .unsol_event = alc269_laptop_unsol_event,
14990 .setup = alc269vb_laptop_dmic_setup,
14991 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014992 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014993 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014994 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014995 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014996 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014997 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014998 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14999 .dac_nids = alc269_dac_nids,
15000 .hp_nid = 0x03,
15001 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15002 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015003 .unsol_event = alc269_laptop_unsol_event,
15004 .setup = alc269_laptop_dmic_setup,
15005 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015006 },
Tony Vroon64154832008-11-06 15:08:49 +000015007 [ALC269_LIFEBOOK] = {
15008 .mixers = { alc269_lifebook_mixer },
15009 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
15010 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15011 .dac_nids = alc269_dac_nids,
15012 .hp_nid = 0x03,
15013 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15014 .channel_mode = alc269_modes,
15015 .input_mux = &alc269_capture_source,
15016 .unsol_event = alc269_lifebook_unsol_event,
15017 .init_hook = alc269_lifebook_init_hook,
15018 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020015019 [ALC271_ACER] = {
15020 .mixers = { alc269_asus_mixer },
15021 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15022 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
15023 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15024 .dac_nids = alc269_dac_nids,
15025 .adc_nids = alc262_dmic_adc_nids,
15026 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
15027 .capsrc_nids = alc262_dmic_capsrc_nids,
15028 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15029 .channel_mode = alc269_modes,
15030 .input_mux = &alc269_capture_source,
15031 .dig_out_nid = ALC880_DIGOUT_NID,
15032 .unsol_event = alc_sku_unsol_event,
15033 .setup = alc269vb_laptop_dmic_setup,
15034 .init_hook = alc_inithook,
15035 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015036};
15037
Kailang Yang977ddd62010-09-15 10:02:29 +020015038static int alc269_fill_coef(struct hda_codec *codec)
15039{
15040 int val;
15041
15042 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
15043 alc_write_coef_idx(codec, 0xf, 0x960b);
15044 alc_write_coef_idx(codec, 0xe, 0x8817);
15045 }
15046
15047 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
15048 alc_write_coef_idx(codec, 0xf, 0x960b);
15049 alc_write_coef_idx(codec, 0xe, 0x8814);
15050 }
15051
15052 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
15053 val = alc_read_coef_idx(codec, 0x04);
15054 /* Power up output pin */
15055 alc_write_coef_idx(codec, 0x04, val | (1<<11));
15056 }
15057
15058 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
15059 val = alc_read_coef_idx(codec, 0xd);
15060 if ((val & 0x0c00) >> 10 != 0x1) {
15061 /* Capless ramp up clock control */
15062 alc_write_coef_idx(codec, 0xd, val | 1<<10);
15063 }
15064 val = alc_read_coef_idx(codec, 0x17);
15065 if ((val & 0x01c0) >> 6 != 0x4) {
15066 /* Class D power on reset */
15067 alc_write_coef_idx(codec, 0x17, val | 1<<7);
15068 }
15069 }
15070 return 0;
15071}
15072
Kailang Yangf6a92242007-12-13 16:52:54 +010015073static int patch_alc269(struct hda_codec *codec)
15074{
15075 struct alc_spec *spec;
Kailang Yang48c88e82010-11-23 08:56:16 +010015076 int board_config, coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010015077 int err;
15078
15079 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15080 if (spec == NULL)
15081 return -ENOMEM;
15082
15083 codec->spec = spec;
15084
Kailang Yangda00c242010-03-19 11:23:45 +010015085 alc_auto_parse_customize_define(codec);
15086
Kailang Yang48c88e82010-11-23 08:56:16 +010015087 coef = alc_read_coef_idx(codec, 0);
15088 if ((coef & 0x00f0) == 0x0010) {
Kailang Yangc027ddc2010-03-19 11:33:06 +010015089 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
Takashi Iwaid433a672010-09-20 15:11:54 +020015090 spec->cdefine.platform_type == 1) {
Kailang Yangc027ddc2010-03-19 11:33:06 +010015091 alc_codec_rename(codec, "ALC271X");
Takashi Iwaid433a672010-09-20 15:11:54 +020015092 spec->codec_variant = ALC269_TYPE_ALC271X;
Kailang Yang48c88e82010-11-23 08:56:16 +010015093 } else if ((coef & 0xf000) == 0x1000) {
15094 spec->codec_variant = ALC269_TYPE_ALC270;
15095 } else if ((coef & 0xf000) == 0x2000) {
Kailang Yangc027ddc2010-03-19 11:33:06 +010015096 alc_codec_rename(codec, "ALC259");
Takashi Iwaid433a672010-09-20 15:11:54 +020015097 spec->codec_variant = ALC269_TYPE_ALC259;
Kailang Yang48c88e82010-11-23 08:56:16 +010015098 } else if ((coef & 0xf000) == 0x3000) {
15099 alc_codec_rename(codec, "ALC258");
15100 spec->codec_variant = ALC269_TYPE_ALC258;
15101 } else {
15102 alc_codec_rename(codec, "ALC269VB");
15103 spec->codec_variant = ALC269_TYPE_ALC269VB;
Takashi Iwaid433a672010-09-20 15:11:54 +020015104 }
Kailang Yangc027ddc2010-03-19 11:33:06 +010015105 } else
15106 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010015107
Kailang Yang977ddd62010-09-15 10:02:29 +020015108 alc269_fill_coef(codec);
15109
Kailang Yangf6a92242007-12-13 16:52:54 +010015110 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15111 alc269_models,
15112 alc269_cfg_tbl);
15113
15114 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015115 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15116 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015117 board_config = ALC269_AUTO;
15118 }
15119
Takashi Iwaiff818c22010-04-12 08:59:25 +020015120 if (board_config == ALC269_AUTO)
15121 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
15122
Kailang Yangf6a92242007-12-13 16:52:54 +010015123 if (board_config == ALC269_AUTO) {
15124 /* automatic parse from the BIOS config */
15125 err = alc269_parse_auto_config(codec);
15126 if (err < 0) {
15127 alc_free(codec);
15128 return err;
15129 } else if (!err) {
15130 printk(KERN_INFO
15131 "hda_codec: Cannot set up configuration "
15132 "from BIOS. Using base mode...\n");
15133 board_config = ALC269_BASIC;
15134 }
15135 }
15136
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015137 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015138 err = snd_hda_attach_beep_device(codec, 0x1);
15139 if (err < 0) {
15140 alc_free(codec);
15141 return err;
15142 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015143 }
15144
Kailang Yangf6a92242007-12-13 16:52:54 +010015145 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015146 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015147
Kailang Yang84898e82010-02-04 14:16:14 +010015148 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015149 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15150 * fix the sample rate of analog I/O to 44.1kHz
15151 */
15152 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15153 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015154 } else if (spec->dual_adc_switch) {
15155 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15156 /* switch ADC dynamically */
15157 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015158 } else {
15159 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15160 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15161 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015162 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15163 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15164
Takashi Iwai66946352010-03-29 17:21:45 +020015165 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Kailang Yang1657cbd2010-11-23 08:53:32 +010015166 if (spec->codec_variant == ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015167 spec->adc_nids = alc269_adc_nids;
15168 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15169 spec->capsrc_nids = alc269_capsrc_nids;
15170 } else {
15171 spec->adc_nids = alc269vb_adc_nids;
15172 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15173 spec->capsrc_nids = alc269vb_capsrc_nids;
15174 }
Kailang Yang84898e82010-02-04 14:16:14 +010015175 }
15176
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015177 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015178 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015179 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015180 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015181
Takashi Iwaiff818c22010-04-12 08:59:25 +020015182 if (board_config == ALC269_AUTO)
15183 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
15184
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015185 spec->vmaster_nid = 0x02;
15186
Kailang Yangf6a92242007-12-13 16:52:54 +010015187 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015188#ifdef CONFIG_SND_HDA_POWER_SAVE
15189 codec->patch_ops.suspend = alc269_suspend;
15190#endif
15191#ifdef SND_HDA_NEEDS_RESUME
15192 codec->patch_ops.resume = alc269_resume;
15193#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015194 if (board_config == ALC269_AUTO)
15195 spec->init_hook = alc269_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020015196
15197 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010015198#ifdef CONFIG_SND_HDA_POWER_SAVE
15199 if (!spec->loopback.amplist)
15200 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015201 if (alc269_mic2_for_mute_led(codec))
15202 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015203#endif
15204
15205 return 0;
15206}
15207
15208/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015209 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15210 */
15211
15212/*
15213 * set the path ways for 2 channel output
15214 * need to set the codec line out and mic 1 pin widgets to inputs
15215 */
15216static struct hda_verb alc861_threestack_ch2_init[] = {
15217 /* set pin widget 1Ah (line in) for input */
15218 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015219 /* set pin widget 18h (mic1/2) for input, for mic also enable
15220 * the vref
15221 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015222 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15223
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015224 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15225#if 0
15226 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15227 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15228#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015229 { } /* end */
15230};
15231/*
15232 * 6ch mode
15233 * need to set the codec line out and mic 1 pin widgets to outputs
15234 */
15235static struct hda_verb alc861_threestack_ch6_init[] = {
15236 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15237 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15238 /* set pin widget 18h (mic1) for output (CLFE)*/
15239 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15240
15241 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015242 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015243
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015244 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15245#if 0
15246 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15247 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15248#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015249 { } /* end */
15250};
15251
15252static struct hda_channel_mode alc861_threestack_modes[2] = {
15253 { 2, alc861_threestack_ch2_init },
15254 { 6, alc861_threestack_ch6_init },
15255};
Takashi Iwai22309c32006-08-09 16:57:28 +020015256/* Set mic1 as input and unmute the mixer */
15257static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15258 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15259 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15260 { } /* end */
15261};
15262/* Set mic1 as output and mute mixer */
15263static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15264 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15265 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15266 { } /* end */
15267};
15268
15269static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15270 { 2, alc861_uniwill_m31_ch2_init },
15271 { 4, alc861_uniwill_m31_ch4_init },
15272};
Kailang Yangdf694da2005-12-05 19:42:22 +010015273
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015274/* Set mic1 and line-in as input and unmute the mixer */
15275static struct hda_verb alc861_asus_ch2_init[] = {
15276 /* set pin widget 1Ah (line in) for input */
15277 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015278 /* set pin widget 18h (mic1/2) for input, for mic also enable
15279 * the vref
15280 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015281 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15282
15283 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15284#if 0
15285 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15286 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15287#endif
15288 { } /* end */
15289};
15290/* Set mic1 nad line-in as output and mute mixer */
15291static struct hda_verb alc861_asus_ch6_init[] = {
15292 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15293 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15294 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15295 /* set pin widget 18h (mic1) for output (CLFE)*/
15296 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15297 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15298 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15299 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15300
15301 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15302#if 0
15303 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15304 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15305#endif
15306 { } /* end */
15307};
15308
15309static struct hda_channel_mode alc861_asus_modes[2] = {
15310 { 2, alc861_asus_ch2_init },
15311 { 6, alc861_asus_ch6_init },
15312};
15313
Kailang Yangdf694da2005-12-05 19:42:22 +010015314/* patch-ALC861 */
15315
15316static struct snd_kcontrol_new alc861_base_mixer[] = {
15317 /* output mixer control */
15318 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15319 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15320 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15321 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15322 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15323
15324 /*Input mixer control */
15325 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15326 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15327 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15328 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15329 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15330 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15331 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15332 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15333 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15334 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015335
Kailang Yangdf694da2005-12-05 19:42:22 +010015336 { } /* end */
15337};
15338
15339static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15340 /* output mixer control */
15341 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15342 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15343 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15344 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15345 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15346
15347 /* Input mixer control */
15348 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15349 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15350 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15351 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15352 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15353 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15354 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15355 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15356 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15357 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015358
Kailang Yangdf694da2005-12-05 19:42:22 +010015359 {
15360 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15361 .name = "Channel Mode",
15362 .info = alc_ch_mode_info,
15363 .get = alc_ch_mode_get,
15364 .put = alc_ch_mode_put,
15365 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15366 },
15367 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015368};
15369
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015370static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015371 /* output mixer control */
15372 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15373 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15374 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015375
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015376 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015377};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015378
Takashi Iwai22309c32006-08-09 16:57:28 +020015379static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15380 /* output mixer control */
15381 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15382 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15383 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15384 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15385 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15386
15387 /* Input mixer control */
15388 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15389 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15390 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15391 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15392 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15393 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15394 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15395 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15396 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15397 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015398
Takashi Iwai22309c32006-08-09 16:57:28 +020015399 {
15400 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15401 .name = "Channel Mode",
15402 .info = alc_ch_mode_info,
15403 .get = alc_ch_mode_get,
15404 .put = alc_ch_mode_put,
15405 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15406 },
15407 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015408};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015409
15410static struct snd_kcontrol_new alc861_asus_mixer[] = {
15411 /* output mixer control */
15412 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15413 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15414 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15415 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15416 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15417
15418 /* Input mixer control */
15419 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15420 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15421 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15422 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15423 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15424 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15425 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15426 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15427 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015428 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15429
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015430 {
15431 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15432 .name = "Channel Mode",
15433 .info = alc_ch_mode_info,
15434 .get = alc_ch_mode_get,
15435 .put = alc_ch_mode_put,
15436 .private_value = ARRAY_SIZE(alc861_asus_modes),
15437 },
15438 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015439};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015440
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015441/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015442static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015443 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15444 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015445 { }
15446};
15447
Kailang Yangdf694da2005-12-05 19:42:22 +010015448/*
15449 * generic initialization of ADC, input mixers and output mixers
15450 */
15451static struct hda_verb alc861_base_init_verbs[] = {
15452 /*
15453 * Unmute ADC0 and set the default input to mic-in
15454 */
15455 /* port-A for surround (rear panel) */
15456 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15457 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15458 /* port-B for mic-in (rear panel) with vref */
15459 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15460 /* port-C for line-in (rear panel) */
15461 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15462 /* port-D for Front */
15463 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15464 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15465 /* port-E for HP out (front panel) */
15466 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15467 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015468 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015469 /* port-F for mic-in (front panel) with vref */
15470 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15471 /* port-G for CLFE (rear panel) */
15472 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15473 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15474 /* port-H for side (rear panel) */
15475 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15476 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15477 /* CD-in */
15478 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15479 /* route front mic to ADC1*/
15480 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15481 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015482
Kailang Yangdf694da2005-12-05 19:42:22 +010015483 /* Unmute DAC0~3 & spdif out*/
15484 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15485 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15486 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15487 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15488 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015489
Kailang Yangdf694da2005-12-05 19:42:22 +010015490 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15491 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15492 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15493 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15494 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015495
Kailang Yangdf694da2005-12-05 19:42:22 +010015496 /* Unmute Stereo Mixer 15 */
15497 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15498 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15499 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015500 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015501
15502 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15503 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15504 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15505 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15506 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15507 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15508 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15509 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015510 /* hp used DAC 3 (Front) */
15511 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015512 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15513
15514 { }
15515};
15516
15517static struct hda_verb alc861_threestack_init_verbs[] = {
15518 /*
15519 * Unmute ADC0 and set the default input to mic-in
15520 */
15521 /* port-A for surround (rear panel) */
15522 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15523 /* port-B for mic-in (rear panel) with vref */
15524 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15525 /* port-C for line-in (rear panel) */
15526 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15527 /* port-D for Front */
15528 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15529 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15530 /* port-E for HP out (front panel) */
15531 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15532 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015533 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015534 /* port-F for mic-in (front panel) with vref */
15535 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15536 /* port-G for CLFE (rear panel) */
15537 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15538 /* port-H for side (rear panel) */
15539 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15540 /* CD-in */
15541 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15542 /* route front mic to ADC1*/
15543 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15544 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15545 /* Unmute DAC0~3 & spdif out*/
15546 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15547 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15548 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15549 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015551
Kailang Yangdf694da2005-12-05 19:42:22 +010015552 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15553 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15554 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15555 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15556 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015557
Kailang Yangdf694da2005-12-05 19:42:22 +010015558 /* Unmute Stereo Mixer 15 */
15559 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15560 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15561 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015562 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015563
15564 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15565 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15566 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15567 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15568 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15569 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15570 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15571 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015572 /* hp used DAC 3 (Front) */
15573 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015574 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15575 { }
15576};
Takashi Iwai22309c32006-08-09 16:57:28 +020015577
15578static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15579 /*
15580 * Unmute ADC0 and set the default input to mic-in
15581 */
15582 /* port-A for surround (rear panel) */
15583 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15584 /* port-B for mic-in (rear panel) with vref */
15585 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15586 /* port-C for line-in (rear panel) */
15587 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15588 /* port-D for Front */
15589 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15590 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15591 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015592 /* this has to be set to VREF80 */
15593 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015594 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015595 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015596 /* port-F for mic-in (front panel) with vref */
15597 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15598 /* port-G for CLFE (rear panel) */
15599 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15600 /* port-H for side (rear panel) */
15601 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15602 /* CD-in */
15603 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15604 /* route front mic to ADC1*/
15605 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15606 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15607 /* Unmute DAC0~3 & spdif out*/
15608 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15609 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15610 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15611 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15612 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015613
Takashi Iwai22309c32006-08-09 16:57:28 +020015614 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15615 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15616 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15617 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15618 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015619
Takashi Iwai22309c32006-08-09 16:57:28 +020015620 /* Unmute Stereo Mixer 15 */
15621 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15622 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15623 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015624 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015625
15626 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15627 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15628 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15629 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15630 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15631 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15632 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15633 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015634 /* hp used DAC 3 (Front) */
15635 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015636 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15637 { }
15638};
15639
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015640static struct hda_verb alc861_asus_init_verbs[] = {
15641 /*
15642 * Unmute ADC0 and set the default input to mic-in
15643 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015644 /* port-A for surround (rear panel)
15645 * according to codec#0 this is the HP jack
15646 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015647 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15648 /* route front PCM to HP */
15649 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15650 /* port-B for mic-in (rear panel) with vref */
15651 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15652 /* port-C for line-in (rear panel) */
15653 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15654 /* port-D for Front */
15655 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15656 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15657 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015658 /* this has to be set to VREF80 */
15659 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015660 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015661 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015662 /* port-F for mic-in (front panel) with vref */
15663 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15664 /* port-G for CLFE (rear panel) */
15665 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15666 /* port-H for side (rear panel) */
15667 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15668 /* CD-in */
15669 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15670 /* route front mic to ADC1*/
15671 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15672 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15673 /* Unmute DAC0~3 & spdif out*/
15674 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15675 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15676 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15677 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15678 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15679 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15680 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15681 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15682 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15683 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015684
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015685 /* Unmute Stereo Mixer 15 */
15686 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15687 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15688 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015689 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015690
15691 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15692 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15693 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15694 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15695 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15696 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15697 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15698 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015699 /* hp used DAC 3 (Front) */
15700 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015701 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15702 { }
15703};
15704
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015705/* additional init verbs for ASUS laptops */
15706static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15707 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15708 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15709 { }
15710};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015711
Kailang Yangdf694da2005-12-05 19:42:22 +010015712/*
15713 * generic initialization of ADC, input mixers and output mixers
15714 */
15715static struct hda_verb alc861_auto_init_verbs[] = {
15716 /*
15717 * Unmute ADC0 and set the default input to mic-in
15718 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015719 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015720 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015721
Kailang Yangdf694da2005-12-05 19:42:22 +010015722 /* Unmute DAC0~3 & spdif out*/
15723 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15724 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15725 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15726 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15727 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015728
Kailang Yangdf694da2005-12-05 19:42:22 +010015729 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15730 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15731 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15732 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15733 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015734
Kailang Yangdf694da2005-12-05 19:42:22 +010015735 /* Unmute Stereo Mixer 15 */
15736 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15737 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15738 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15739 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15740
Takashi Iwai1c209302009-07-22 15:17:45 +020015741 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15742 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15743 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15744 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15745 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15746 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15747 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15748 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015749
15750 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15751 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015752 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15753 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015754 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15755 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015756 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15757 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015758
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015759 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015760
15761 { }
15762};
15763
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015764static struct hda_verb alc861_toshiba_init_verbs[] = {
15765 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015766
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015767 { }
15768};
15769
15770/* toggle speaker-output according to the hp-jack state */
15771static void alc861_toshiba_automute(struct hda_codec *codec)
15772{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015773 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015774
Takashi Iwai47fd8302007-08-10 17:11:07 +020015775 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15776 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15777 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15778 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015779}
15780
15781static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15782 unsigned int res)
15783{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015784 if ((res >> 26) == ALC880_HP_EVENT)
15785 alc861_toshiba_automute(codec);
15786}
15787
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015788/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015789#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15790#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15791#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15792#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15793
15794
15795#define ALC861_DIGOUT_NID 0x07
15796
15797static struct hda_channel_mode alc861_8ch_modes[1] = {
15798 { 8, NULL }
15799};
15800
15801static hda_nid_t alc861_dac_nids[4] = {
15802 /* front, surround, clfe, side */
15803 0x03, 0x06, 0x05, 0x04
15804};
15805
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015806static hda_nid_t alc660_dac_nids[3] = {
15807 /* front, clfe, surround */
15808 0x03, 0x05, 0x06
15809};
15810
Kailang Yangdf694da2005-12-05 19:42:22 +010015811static hda_nid_t alc861_adc_nids[1] = {
15812 /* ADC0-2 */
15813 0x08,
15814};
15815
15816static struct hda_input_mux alc861_capture_source = {
15817 .num_items = 5,
15818 .items = {
15819 { "Mic", 0x0 },
15820 { "Front Mic", 0x3 },
15821 { "Line", 0x1 },
15822 { "CD", 0x4 },
15823 { "Mixer", 0x5 },
15824 },
15825};
15826
Takashi Iwai1c209302009-07-22 15:17:45 +020015827static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15828{
15829 struct alc_spec *spec = codec->spec;
15830 hda_nid_t mix, srcs[5];
15831 int i, j, num;
15832
15833 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15834 return 0;
15835 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15836 if (num < 0)
15837 return 0;
15838 for (i = 0; i < num; i++) {
15839 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015840 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015841 if (type != AC_WID_AUD_OUT)
15842 continue;
15843 for (j = 0; j < spec->multiout.num_dacs; j++)
15844 if (spec->multiout.dac_nids[j] == srcs[i])
15845 break;
15846 if (j >= spec->multiout.num_dacs)
15847 return srcs[i];
15848 }
15849 return 0;
15850}
15851
Kailang Yangdf694da2005-12-05 19:42:22 +010015852/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015853static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015854 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015855{
Takashi Iwai1c209302009-07-22 15:17:45 +020015856 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015857 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015858 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015859
15860 spec->multiout.dac_nids = spec->private_dac_nids;
15861 for (i = 0; i < cfg->line_outs; i++) {
15862 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015863 dac = alc861_look_for_dac(codec, nid);
15864 if (!dac)
15865 continue;
15866 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015867 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015868 return 0;
15869}
15870
Takashi Iwai1c209302009-07-22 15:17:45 +020015871static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15872 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015873{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015874 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015875 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15876}
15877
15878/* add playback controls from the parsed DAC table */
15879static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15880 const struct auto_pin_cfg *cfg)
15881{
15882 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015883 static const char *chname[4] = {
15884 "Front", "Surround", NULL /*CLFE*/, "Side"
15885 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015886 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015887 int i, err;
15888
15889 if (cfg->line_outs == 1) {
15890 const char *pfx = NULL;
15891 if (!cfg->hp_outs)
15892 pfx = "Master";
15893 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15894 pfx = "Speaker";
15895 if (pfx) {
15896 nid = spec->multiout.dac_nids[0];
15897 return alc861_create_out_sw(codec, pfx, nid, 3);
15898 }
15899 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015900
15901 for (i = 0; i < cfg->line_outs; i++) {
15902 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015903 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015904 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015905 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015906 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015907 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015908 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015909 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015910 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015911 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015912 return err;
15913 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015914 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015915 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015916 return err;
15917 }
15918 }
15919 return 0;
15920}
15921
Takashi Iwai1c209302009-07-22 15:17:45 +020015922static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015923{
Takashi Iwai1c209302009-07-22 15:17:45 +020015924 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015925 int err;
15926 hda_nid_t nid;
15927
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015928 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015929 return 0;
15930
15931 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015932 nid = alc861_look_for_dac(codec, pin);
15933 if (nid) {
15934 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15935 if (err < 0)
15936 return err;
15937 spec->multiout.hp_nid = nid;
15938 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015939 }
15940 return 0;
15941}
15942
15943/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015944static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015945 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015946{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015947 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015948}
15949
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015950static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15951 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015952 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015953{
Takashi Iwai1c209302009-07-22 15:17:45 +020015954 hda_nid_t mix, srcs[5];
15955 int i, num;
15956
Jacek Luczak564c5be2008-05-03 18:41:23 +020015957 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15958 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015959 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015960 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015961 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15962 return;
15963 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15964 if (num < 0)
15965 return;
15966 for (i = 0; i < num; i++) {
15967 unsigned int mute;
15968 if (srcs[i] == dac || srcs[i] == 0x15)
15969 mute = AMP_IN_UNMUTE(i);
15970 else
15971 mute = AMP_IN_MUTE(i);
15972 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15973 mute);
15974 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015975}
15976
15977static void alc861_auto_init_multi_out(struct hda_codec *codec)
15978{
15979 struct alc_spec *spec = codec->spec;
15980 int i;
15981
15982 for (i = 0; i < spec->autocfg.line_outs; i++) {
15983 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015984 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015985 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015986 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015987 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015988 }
15989}
15990
15991static void alc861_auto_init_hp_out(struct hda_codec *codec)
15992{
15993 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015994
Takashi Iwai15870f02009-10-05 08:25:13 +020015995 if (spec->autocfg.hp_outs)
15996 alc861_auto_set_output_and_unmute(codec,
15997 spec->autocfg.hp_pins[0],
15998 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015999 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020016000 if (spec->autocfg.speaker_outs)
16001 alc861_auto_set_output_and_unmute(codec,
16002 spec->autocfg.speaker_pins[0],
16003 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020016004 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016005}
16006
16007static void alc861_auto_init_analog_input(struct hda_codec *codec)
16008{
16009 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016010 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010016011 int i;
16012
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016013 for (i = 0; i < cfg->num_inputs; i++) {
16014 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010016015 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020016016 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016017 }
16018}
16019
16020/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016021/* return 1 if successful, 0 if the proper config is not found,
16022 * or a negative error code
16023 */
Kailang Yangdf694da2005-12-05 19:42:22 +010016024static int alc861_parse_auto_config(struct hda_codec *codec)
16025{
16026 struct alc_spec *spec = codec->spec;
16027 int err;
16028 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
16029
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016030 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16031 alc861_ignore);
16032 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016033 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016034 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010016035 return 0; /* can't find valid BIOS pin config */
16036
Takashi Iwai1c209302009-07-22 15:17:45 +020016037 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016038 if (err < 0)
16039 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016040 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016041 if (err < 0)
16042 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016043 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016044 if (err < 0)
16045 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016046 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016047 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016048 return err;
16049
16050 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16051
Takashi Iwai757899a2010-07-30 10:48:14 +020016052 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016053
Takashi Iwai603c4012008-07-30 15:01:44 +020016054 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016055 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010016056
Takashi Iwaid88897e2008-10-31 15:01:37 +010016057 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010016058
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020016059 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016060 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010016061
16062 spec->adc_nids = alc861_adc_nids;
16063 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016064 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016065
Kailang Yang6227cdc2010-02-25 08:36:52 +010016066 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016067
Kailang Yangdf694da2005-12-05 19:42:22 +010016068 return 1;
16069}
16070
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016071/* additional initialization for auto-configuration model */
16072static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010016073{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016074 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016075 alc861_auto_init_multi_out(codec);
16076 alc861_auto_init_hp_out(codec);
16077 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016078 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016079 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016080 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016081}
16082
Takashi Iwaicb53c622007-08-10 17:21:45 +020016083#ifdef CONFIG_SND_HDA_POWER_SAVE
16084static struct hda_amp_list alc861_loopbacks[] = {
16085 { 0x15, HDA_INPUT, 0 },
16086 { 0x15, HDA_INPUT, 1 },
16087 { 0x15, HDA_INPUT, 2 },
16088 { 0x15, HDA_INPUT, 3 },
16089 { } /* end */
16090};
16091#endif
16092
Kailang Yangdf694da2005-12-05 19:42:22 +010016093
16094/*
16095 * configuration and preset
16096 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016097static const char *alc861_models[ALC861_MODEL_LAST] = {
16098 [ALC861_3ST] = "3stack",
16099 [ALC660_3ST] = "3stack-660",
16100 [ALC861_3ST_DIG] = "3stack-dig",
16101 [ALC861_6ST_DIG] = "6stack-dig",
16102 [ALC861_UNIWILL_M31] = "uniwill-m31",
16103 [ALC861_TOSHIBA] = "toshiba",
16104 [ALC861_ASUS] = "asus",
16105 [ALC861_ASUS_LAPTOP] = "asus-laptop",
16106 [ALC861_AUTO] = "auto",
16107};
16108
16109static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010016110 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016111 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16112 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16113 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016114 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016115 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016116 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016117 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16118 * Any other models that need this preset?
16119 */
16120 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016121 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16122 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016123 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16124 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16125 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16126 /* FIXME: the below seems conflict */
16127 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16128 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16129 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016130 {}
16131};
16132
16133static struct alc_config_preset alc861_presets[] = {
16134 [ALC861_3ST] = {
16135 .mixers = { alc861_3ST_mixer },
16136 .init_verbs = { alc861_threestack_init_verbs },
16137 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16138 .dac_nids = alc861_dac_nids,
16139 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16140 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016141 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016142 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16143 .adc_nids = alc861_adc_nids,
16144 .input_mux = &alc861_capture_source,
16145 },
16146 [ALC861_3ST_DIG] = {
16147 .mixers = { alc861_base_mixer },
16148 .init_verbs = { alc861_threestack_init_verbs },
16149 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16150 .dac_nids = alc861_dac_nids,
16151 .dig_out_nid = ALC861_DIGOUT_NID,
16152 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16153 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016154 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016155 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16156 .adc_nids = alc861_adc_nids,
16157 .input_mux = &alc861_capture_source,
16158 },
16159 [ALC861_6ST_DIG] = {
16160 .mixers = { alc861_base_mixer },
16161 .init_verbs = { alc861_base_init_verbs },
16162 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16163 .dac_nids = alc861_dac_nids,
16164 .dig_out_nid = ALC861_DIGOUT_NID,
16165 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16166 .channel_mode = alc861_8ch_modes,
16167 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16168 .adc_nids = alc861_adc_nids,
16169 .input_mux = &alc861_capture_source,
16170 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016171 [ALC660_3ST] = {
16172 .mixers = { alc861_3ST_mixer },
16173 .init_verbs = { alc861_threestack_init_verbs },
16174 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16175 .dac_nids = alc660_dac_nids,
16176 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16177 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016178 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016179 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16180 .adc_nids = alc861_adc_nids,
16181 .input_mux = &alc861_capture_source,
16182 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016183 [ALC861_UNIWILL_M31] = {
16184 .mixers = { alc861_uniwill_m31_mixer },
16185 .init_verbs = { alc861_uniwill_m31_init_verbs },
16186 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16187 .dac_nids = alc861_dac_nids,
16188 .dig_out_nid = ALC861_DIGOUT_NID,
16189 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16190 .channel_mode = alc861_uniwill_m31_modes,
16191 .need_dac_fix = 1,
16192 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16193 .adc_nids = alc861_adc_nids,
16194 .input_mux = &alc861_capture_source,
16195 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016196 [ALC861_TOSHIBA] = {
16197 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016198 .init_verbs = { alc861_base_init_verbs,
16199 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016200 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16201 .dac_nids = alc861_dac_nids,
16202 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16203 .channel_mode = alc883_3ST_2ch_modes,
16204 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16205 .adc_nids = alc861_adc_nids,
16206 .input_mux = &alc861_capture_source,
16207 .unsol_event = alc861_toshiba_unsol_event,
16208 .init_hook = alc861_toshiba_automute,
16209 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016210 [ALC861_ASUS] = {
16211 .mixers = { alc861_asus_mixer },
16212 .init_verbs = { alc861_asus_init_verbs },
16213 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16214 .dac_nids = alc861_dac_nids,
16215 .dig_out_nid = ALC861_DIGOUT_NID,
16216 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16217 .channel_mode = alc861_asus_modes,
16218 .need_dac_fix = 1,
16219 .hp_nid = 0x06,
16220 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16221 .adc_nids = alc861_adc_nids,
16222 .input_mux = &alc861_capture_source,
16223 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016224 [ALC861_ASUS_LAPTOP] = {
16225 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16226 .init_verbs = { alc861_asus_init_verbs,
16227 alc861_asus_laptop_init_verbs },
16228 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16229 .dac_nids = alc861_dac_nids,
16230 .dig_out_nid = ALC861_DIGOUT_NID,
16231 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16232 .channel_mode = alc883_3ST_2ch_modes,
16233 .need_dac_fix = 1,
16234 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16235 .adc_nids = alc861_adc_nids,
16236 .input_mux = &alc861_capture_source,
16237 },
16238};
Kailang Yangdf694da2005-12-05 19:42:22 +010016239
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016240/* Pin config fixes */
16241enum {
16242 PINFIX_FSC_AMILO_PI1505,
16243};
16244
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016245static const struct alc_fixup alc861_fixups[] = {
16246 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020016247 .pins = (const struct alc_pincfg[]) {
16248 { 0x0b, 0x0221101f }, /* HP */
16249 { 0x0f, 0x90170310 }, /* speaker */
16250 { }
16251 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016252 },
16253};
16254
16255static struct snd_pci_quirk alc861_fixup_tbl[] = {
16256 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16257 {}
16258};
Kailang Yangdf694da2005-12-05 19:42:22 +010016259
16260static int patch_alc861(struct hda_codec *codec)
16261{
16262 struct alc_spec *spec;
16263 int board_config;
16264 int err;
16265
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016266 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016267 if (spec == NULL)
16268 return -ENOMEM;
16269
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016270 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016271
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016272 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16273 alc861_models,
16274 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016275
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016276 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016277 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16278 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016279 board_config = ALC861_AUTO;
16280 }
16281
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016282 if (board_config == ALC861_AUTO)
16283 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016284
Kailang Yangdf694da2005-12-05 19:42:22 +010016285 if (board_config == ALC861_AUTO) {
16286 /* automatic parse from the BIOS config */
16287 err = alc861_parse_auto_config(codec);
16288 if (err < 0) {
16289 alc_free(codec);
16290 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016291 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016292 printk(KERN_INFO
16293 "hda_codec: Cannot set up configuration "
16294 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016295 board_config = ALC861_3ST_DIG;
16296 }
16297 }
16298
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016299 err = snd_hda_attach_beep_device(codec, 0x23);
16300 if (err < 0) {
16301 alc_free(codec);
16302 return err;
16303 }
16304
Kailang Yangdf694da2005-12-05 19:42:22 +010016305 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016306 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016307
Kailang Yangdf694da2005-12-05 19:42:22 +010016308 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16309 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16310
Kailang Yangdf694da2005-12-05 19:42:22 +010016311 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16312 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16313
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016314 if (!spec->cap_mixer)
16315 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016316 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16317
Takashi Iwai2134ea42008-01-10 16:53:55 +010016318 spec->vmaster_nid = 0x03;
16319
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016320 if (board_config == ALC861_AUTO)
16321 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
16322
Kailang Yangdf694da2005-12-05 19:42:22 +010016323 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016324 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016325 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016326#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016327 spec->power_hook = alc_power_eapd;
16328#endif
16329 }
16330#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016331 if (!spec->loopback.amplist)
16332 spec->loopback.amplist = alc861_loopbacks;
16333#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016334
Kailang Yangdf694da2005-12-05 19:42:22 +010016335 return 0;
16336}
16337
16338/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016339 * ALC861-VD support
16340 *
16341 * Based on ALC882
16342 *
16343 * In addition, an independent DAC
16344 */
16345#define ALC861VD_DIGOUT_NID 0x06
16346
16347static hda_nid_t alc861vd_dac_nids[4] = {
16348 /* front, surr, clfe, side surr */
16349 0x02, 0x03, 0x04, 0x05
16350};
16351
16352/* dac_nids for ALC660vd are in a different order - according to
16353 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016354 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016355 * of ALC660vd codecs, but for now there is only 3stack mixer
16356 * - and it is the same as in 861vd.
16357 * adc_nids in ALC660vd are (is) the same as in 861vd
16358 */
16359static hda_nid_t alc660vd_dac_nids[3] = {
16360 /* front, rear, clfe, rear_surr */
16361 0x02, 0x04, 0x03
16362};
16363
16364static hda_nid_t alc861vd_adc_nids[1] = {
16365 /* ADC0 */
16366 0x09,
16367};
16368
Takashi Iwaie1406342008-02-11 18:32:32 +010016369static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16370
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016371/* input MUX */
16372/* FIXME: should be a matrix-type input source selection */
16373static struct hda_input_mux alc861vd_capture_source = {
16374 .num_items = 4,
16375 .items = {
16376 { "Mic", 0x0 },
16377 { "Front Mic", 0x1 },
16378 { "Line", 0x2 },
16379 { "CD", 0x4 },
16380 },
16381};
16382
Kailang Yang272a5272007-05-14 11:00:38 +020016383static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016384 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016385 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010016386 { "Ext Mic", 0x0 },
16387 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016388 },
16389};
16390
Kailang Yangd1a991a2007-08-15 16:21:59 +020016391static struct hda_input_mux alc861vd_hp_capture_source = {
16392 .num_items = 2,
16393 .items = {
16394 { "Front Mic", 0x0 },
16395 { "ATAPI Mic", 0x1 },
16396 },
16397};
16398
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016399/*
16400 * 2ch mode
16401 */
16402static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16403 { 2, NULL }
16404};
16405
16406/*
16407 * 6ch mode
16408 */
16409static struct hda_verb alc861vd_6stack_ch6_init[] = {
16410 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16411 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16412 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16413 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16414 { } /* end */
16415};
16416
16417/*
16418 * 8ch mode
16419 */
16420static struct hda_verb alc861vd_6stack_ch8_init[] = {
16421 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16422 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16423 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16424 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16425 { } /* end */
16426};
16427
16428static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16429 { 6, alc861vd_6stack_ch6_init },
16430 { 8, alc861vd_6stack_ch8_init },
16431};
16432
16433static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16434 {
16435 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16436 .name = "Channel Mode",
16437 .info = alc_ch_mode_info,
16438 .get = alc_ch_mode_get,
16439 .put = alc_ch_mode_put,
16440 },
16441 { } /* end */
16442};
16443
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016444/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16445 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16446 */
16447static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16448 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16449 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16450
16451 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16452 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16453
16454 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16455 HDA_OUTPUT),
16456 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16457 HDA_OUTPUT),
16458 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16459 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16460
16461 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16462 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
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("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16475 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16476
16477 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16478 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16479
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016480 { } /* end */
16481};
16482
16483static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16484 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16485 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16486
16487 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16488
16489 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16490 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16491 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16492
16493 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16494 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16495 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16496
16497 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16498 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16499
16500 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16501 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16502
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016503 { } /* end */
16504};
16505
Kailang Yangbdd148a2007-05-08 15:19:08 +020016506static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16507 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16508 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16509 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16510
16511 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16512
16513 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16514 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16515 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16516
16517 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16518 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16519 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16520
16521 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16522 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16523
16524 { } /* end */
16525};
16526
Tobin Davisb419f342008-03-07 11:57:51 +010016527/* Pin assignment: Speaker=0x14, HP = 0x15,
16528 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016529 */
16530static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016531 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16532 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016533 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16534 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010016535 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16536 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16537 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16538 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16539 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16540 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016541 { } /* end */
16542};
16543
Kailang Yangd1a991a2007-08-15 16:21:59 +020016544/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16545 * Front Mic=0x18, ATAPI Mic = 0x19,
16546 */
16547static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16548 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16549 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16550 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16551 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16552 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16553 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16554 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16555 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016556
Kailang Yangd1a991a2007-08-15 16:21:59 +020016557 { } /* end */
16558};
16559
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016560/*
16561 * generic initialization of ADC, input mixers and output mixers
16562 */
16563static struct hda_verb alc861vd_volume_init_verbs[] = {
16564 /*
16565 * Unmute ADC0 and set the default input to mic-in
16566 */
16567 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16568 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16569
16570 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16571 * the analog-loopback mixer widget
16572 */
16573 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016574 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16575 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16576 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16577 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16578 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016579
16580 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016581 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16582 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16583 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016584 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016585
16586 /*
16587 * Set up output mixers (0x02 - 0x05)
16588 */
16589 /* set vol=0 to output mixers */
16590 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16591 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16592 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16593 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16594
16595 /* set up input amps for analog loopback */
16596 /* Amp Indices: DAC = 0, mixer = 1 */
16597 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16598 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16599 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16600 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16601 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16602 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16603 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16604 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16605
16606 { }
16607};
16608
16609/*
16610 * 3-stack pin configuration:
16611 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16612 */
16613static struct hda_verb alc861vd_3stack_init_verbs[] = {
16614 /*
16615 * Set pin mode and muting
16616 */
16617 /* set front pin widgets 0x14 for output */
16618 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16619 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16620 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16621
16622 /* Mic (rear) pin: input vref at 80% */
16623 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16624 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16625 /* Front Mic pin: input vref at 80% */
16626 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16627 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16628 /* Line In pin: input */
16629 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16630 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16631 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16632 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16633 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16634 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16635 /* CD pin widget for input */
16636 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16637
16638 { }
16639};
16640
16641/*
16642 * 6-stack pin configuration:
16643 */
16644static struct hda_verb alc861vd_6stack_init_verbs[] = {
16645 /*
16646 * Set pin mode and muting
16647 */
16648 /* set front pin widgets 0x14 for output */
16649 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16650 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16651 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16652
16653 /* Rear Pin: output 1 (0x0d) */
16654 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16655 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16656 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16657 /* CLFE Pin: output 2 (0x0e) */
16658 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16659 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16660 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16661 /* Side Pin: output 3 (0x0f) */
16662 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16663 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16664 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16665
16666 /* Mic (rear) pin: input vref at 80% */
16667 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16668 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16669 /* Front Mic pin: input vref at 80% */
16670 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16671 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16672 /* Line In pin: input */
16673 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16674 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16675 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16676 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16677 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16678 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16679 /* CD pin widget for input */
16680 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16681
16682 { }
16683};
16684
Kailang Yangbdd148a2007-05-08 15:19:08 +020016685static struct hda_verb alc861vd_eapd_verbs[] = {
16686 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16687 { }
16688};
16689
Kailang Yangf9423e72008-05-27 12:32:25 +020016690static struct hda_verb alc660vd_eapd_verbs[] = {
16691 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16692 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16693 { }
16694};
16695
Kailang Yangbdd148a2007-05-08 15:19:08 +020016696static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16697 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16698 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16699 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16700 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016701 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016702 {}
16703};
16704
Kailang Yangbdd148a2007-05-08 15:19:08 +020016705static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
16706{
16707 unsigned int present;
16708 unsigned char bits;
16709
Wu Fengguang864f92b2009-11-18 12:38:02 +080016710 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016711 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016712
Takashi Iwai47fd8302007-08-10 17:11:07 +020016713 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
16714 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016715}
16716
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016717static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016718{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016719 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016720 spec->autocfg.hp_pins[0] = 0x1b;
16721 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016722}
16723
16724static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16725{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016726 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016727 alc861vd_lenovo_mic_automute(codec);
16728}
16729
16730static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16731 unsigned int res)
16732{
16733 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016734 case ALC880_MIC_EVENT:
16735 alc861vd_lenovo_mic_automute(codec);
16736 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016737 default:
16738 alc_automute_amp_unsol_event(codec, res);
16739 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016740 }
16741}
16742
Kailang Yang272a5272007-05-14 11:00:38 +020016743static struct hda_verb alc861vd_dallas_verbs[] = {
16744 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16745 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16746 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16747 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16748
16749 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16750 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16751 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16752 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16753 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16754 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16755 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16756 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016757
Kailang Yang272a5272007-05-14 11:00:38 +020016758 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16759 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16760 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16761 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16762 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16763 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16764 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16765 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16766
16767 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16768 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16769 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16770 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16771 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16772 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16773 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16774 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16775
16776 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16778 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16779 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16780
16781 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016782 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016783 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16784
16785 { } /* end */
16786};
16787
16788/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016789static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016790{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016791 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016792
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016793 spec->autocfg.hp_pins[0] = 0x15;
16794 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016795}
16796
Takashi Iwaicb53c622007-08-10 17:21:45 +020016797#ifdef CONFIG_SND_HDA_POWER_SAVE
16798#define alc861vd_loopbacks alc880_loopbacks
16799#endif
16800
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016801/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016802#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16803#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16804#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16805#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16806
16807/*
16808 * configuration and preset
16809 */
16810static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16811 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016812 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016813 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016814 [ALC861VD_3ST] = "3stack",
16815 [ALC861VD_3ST_DIG] = "3stack-digout",
16816 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016817 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016818 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016819 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016820 [ALC861VD_AUTO] = "auto",
16821};
16822
16823static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016824 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16825 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016826 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016827 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016828 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016829 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016830 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016831 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016832 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016833 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016834 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016835 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016836 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016837 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016838 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016839 {}
16840};
16841
16842static struct alc_config_preset alc861vd_presets[] = {
16843 [ALC660VD_3ST] = {
16844 .mixers = { alc861vd_3st_mixer },
16845 .init_verbs = { alc861vd_volume_init_verbs,
16846 alc861vd_3stack_init_verbs },
16847 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16848 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016849 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16850 .channel_mode = alc861vd_3stack_2ch_modes,
16851 .input_mux = &alc861vd_capture_source,
16852 },
Mike Crash6963f842007-06-25 12:12:51 +020016853 [ALC660VD_3ST_DIG] = {
16854 .mixers = { alc861vd_3st_mixer },
16855 .init_verbs = { alc861vd_volume_init_verbs,
16856 alc861vd_3stack_init_verbs },
16857 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16858 .dac_nids = alc660vd_dac_nids,
16859 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016860 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16861 .channel_mode = alc861vd_3stack_2ch_modes,
16862 .input_mux = &alc861vd_capture_source,
16863 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016864 [ALC861VD_3ST] = {
16865 .mixers = { alc861vd_3st_mixer },
16866 .init_verbs = { alc861vd_volume_init_verbs,
16867 alc861vd_3stack_init_verbs },
16868 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16869 .dac_nids = alc861vd_dac_nids,
16870 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16871 .channel_mode = alc861vd_3stack_2ch_modes,
16872 .input_mux = &alc861vd_capture_source,
16873 },
16874 [ALC861VD_3ST_DIG] = {
16875 .mixers = { alc861vd_3st_mixer },
16876 .init_verbs = { alc861vd_volume_init_verbs,
16877 alc861vd_3stack_init_verbs },
16878 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16879 .dac_nids = alc861vd_dac_nids,
16880 .dig_out_nid = ALC861VD_DIGOUT_NID,
16881 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16882 .channel_mode = alc861vd_3stack_2ch_modes,
16883 .input_mux = &alc861vd_capture_source,
16884 },
16885 [ALC861VD_6ST_DIG] = {
16886 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16887 .init_verbs = { alc861vd_volume_init_verbs,
16888 alc861vd_6stack_init_verbs },
16889 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16890 .dac_nids = alc861vd_dac_nids,
16891 .dig_out_nid = ALC861VD_DIGOUT_NID,
16892 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16893 .channel_mode = alc861vd_6stack_modes,
16894 .input_mux = &alc861vd_capture_source,
16895 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016896 [ALC861VD_LENOVO] = {
16897 .mixers = { alc861vd_lenovo_mixer },
16898 .init_verbs = { alc861vd_volume_init_verbs,
16899 alc861vd_3stack_init_verbs,
16900 alc861vd_eapd_verbs,
16901 alc861vd_lenovo_unsol_verbs },
16902 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16903 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016904 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16905 .channel_mode = alc861vd_3stack_2ch_modes,
16906 .input_mux = &alc861vd_capture_source,
16907 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016908 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016909 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016910 },
Kailang Yang272a5272007-05-14 11:00:38 +020016911 [ALC861VD_DALLAS] = {
16912 .mixers = { alc861vd_dallas_mixer },
16913 .init_verbs = { alc861vd_dallas_verbs },
16914 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16915 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016916 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16917 .channel_mode = alc861vd_3stack_2ch_modes,
16918 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016919 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016920 .setup = alc861vd_dallas_setup,
16921 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016922 },
16923 [ALC861VD_HP] = {
16924 .mixers = { alc861vd_hp_mixer },
16925 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16926 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16927 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016928 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016929 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16930 .channel_mode = alc861vd_3stack_2ch_modes,
16931 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016932 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016933 .setup = alc861vd_dallas_setup,
16934 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016935 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016936 [ALC660VD_ASUS_V1S] = {
16937 .mixers = { alc861vd_lenovo_mixer },
16938 .init_verbs = { alc861vd_volume_init_verbs,
16939 alc861vd_3stack_init_verbs,
16940 alc861vd_eapd_verbs,
16941 alc861vd_lenovo_unsol_verbs },
16942 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16943 .dac_nids = alc660vd_dac_nids,
16944 .dig_out_nid = ALC861VD_DIGOUT_NID,
16945 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16946 .channel_mode = alc861vd_3stack_2ch_modes,
16947 .input_mux = &alc861vd_capture_source,
16948 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016949 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016950 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016951 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016952};
16953
16954/*
16955 * BIOS auto configuration
16956 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016957static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16958 const struct auto_pin_cfg *cfg)
16959{
Herton Ronaldo Krzesinski71675942010-11-25 00:08:01 -020016960 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016961}
16962
16963
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016964static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16965 hda_nid_t nid, int pin_type, int dac_idx)
16966{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016967 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016968}
16969
16970static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16971{
16972 struct alc_spec *spec = codec->spec;
16973 int i;
16974
16975 for (i = 0; i <= HDA_SIDE; i++) {
16976 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016977 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016978 if (nid)
16979 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016980 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016981 }
16982}
16983
16984
16985static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16986{
16987 struct alc_spec *spec = codec->spec;
16988 hda_nid_t pin;
16989
16990 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016991 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016992 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016993 pin = spec->autocfg.speaker_pins[0];
16994 if (pin)
16995 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016996}
16997
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016998#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16999
17000static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
17001{
17002 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017003 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017004 int i;
17005
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017006 for (i = 0; i < cfg->num_inputs; i++) {
17007 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017008 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020017009 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010017010 if (nid != ALC861VD_PIN_CD_NID &&
17011 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017012 snd_hda_codec_write(codec, nid, 0,
17013 AC_VERB_SET_AMP_GAIN_MUTE,
17014 AMP_OUT_MUTE);
17015 }
17016 }
17017}
17018
Takashi Iwaif511b012008-08-15 16:46:42 +020017019#define alc861vd_auto_init_input_src alc882_auto_init_input_src
17020
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017021#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
17022#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
17023
17024/* add playback controls from the parsed DAC table */
17025/* Based on ALC880 version. But ALC861VD has separate,
17026 * different NIDs for mute/unmute switch and volume control */
17027static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
17028 const struct auto_pin_cfg *cfg)
17029{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017030 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
17031 hda_nid_t nid_v, nid_s;
17032 int i, err;
17033
17034 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017035 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017036 continue;
17037 nid_v = alc861vd_idx_to_mixer_vol(
17038 alc880_dac_to_idx(
17039 spec->multiout.dac_nids[i]));
17040 nid_s = alc861vd_idx_to_mixer_switch(
17041 alc880_dac_to_idx(
17042 spec->multiout.dac_nids[i]));
17043
17044 if (i == 2) {
17045 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017046 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17047 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017048 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
17049 HDA_OUTPUT));
17050 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017051 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017052 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17053 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017054 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
17055 HDA_OUTPUT));
17056 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017057 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017058 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17059 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017060 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
17061 HDA_INPUT));
17062 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017063 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017064 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17065 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017066 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
17067 HDA_INPUT));
17068 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017069 return err;
17070 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020017071 const char *pfx;
17072 if (cfg->line_outs == 1 &&
17073 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
17074 if (!cfg->hp_pins)
17075 pfx = "Speaker";
17076 else
17077 pfx = "PCM";
17078 } else
17079 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017080 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017081 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17082 HDA_OUTPUT));
17083 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017084 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020017085 if (cfg->line_outs == 1 &&
17086 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17087 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017088 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017089 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017090 HDA_INPUT));
17091 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017092 return err;
17093 }
17094 }
17095 return 0;
17096}
17097
17098/* add playback controls for speaker and HP outputs */
17099/* Based on ALC880 version. But ALC861VD has separate,
17100 * different NIDs for mute/unmute switch and volume control */
17101static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
17102 hda_nid_t pin, const char *pfx)
17103{
17104 hda_nid_t nid_v, nid_s;
17105 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017106
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017107 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017108 return 0;
17109
17110 if (alc880_is_fixed_pin(pin)) {
17111 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17112 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017113 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017114 spec->multiout.hp_nid = nid_v;
17115 else
17116 spec->multiout.extra_out_nid[0] = nid_v;
17117 /* control HP volume/switch on the output mixer amp */
17118 nid_v = alc861vd_idx_to_mixer_vol(
17119 alc880_fixed_pin_idx(pin));
17120 nid_s = alc861vd_idx_to_mixer_switch(
17121 alc880_fixed_pin_idx(pin));
17122
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017123 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017124 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17125 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017126 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017127 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017128 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17129 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017130 return err;
17131 } else if (alc880_is_multi_pin(pin)) {
17132 /* set manual connection */
17133 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017134 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017135 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17136 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017137 return err;
17138 }
17139 return 0;
17140}
17141
17142/* parse the BIOS configuration and set up the alc_spec
17143 * return 1 if successful, 0 if the proper config is not found,
17144 * or a negative error code
17145 * Based on ALC880 version - had to change it to override
17146 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17147static int alc861vd_parse_auto_config(struct hda_codec *codec)
17148{
17149 struct alc_spec *spec = codec->spec;
17150 int err;
17151 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17152
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017153 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17154 alc861vd_ignore);
17155 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017156 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017157 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017158 return 0; /* can't find valid BIOS pin config */
17159
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017160 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17161 if (err < 0)
17162 return err;
17163 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17164 if (err < 0)
17165 return err;
17166 err = alc861vd_auto_create_extra_out(spec,
17167 spec->autocfg.speaker_pins[0],
17168 "Speaker");
17169 if (err < 0)
17170 return err;
17171 err = alc861vd_auto_create_extra_out(spec,
17172 spec->autocfg.hp_pins[0],
17173 "Headphone");
17174 if (err < 0)
17175 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017176 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017177 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017178 return err;
17179
17180 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17181
Takashi Iwai757899a2010-07-30 10:48:14 +020017182 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017183
Takashi Iwai603c4012008-07-30 15:01:44 +020017184 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017185 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017186
Takashi Iwaid88897e2008-10-31 15:01:37 +010017187 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017188
17189 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017190 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017191
Takashi Iwai776e1842007-08-29 15:07:11 +020017192 err = alc_auto_add_mic_boost(codec);
17193 if (err < 0)
17194 return err;
17195
Kailang Yang6227cdc2010-02-25 08:36:52 +010017196 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017197
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017198 return 1;
17199}
17200
17201/* additional initialization for auto-configuration model */
17202static void alc861vd_auto_init(struct hda_codec *codec)
17203{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017204 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017205 alc861vd_auto_init_multi_out(codec);
17206 alc861vd_auto_init_hp_out(codec);
17207 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017208 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017209 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017210 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017211 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017212}
17213
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017214enum {
17215 ALC660VD_FIX_ASUS_GPIO1
17216};
17217
17218/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017219static const struct alc_fixup alc861vd_fixups[] = {
17220 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020017221 .verbs = (const struct hda_verb[]) {
17222 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17223 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17224 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17225 { }
17226 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017227 },
17228};
17229
17230static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17231 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17232 {}
17233};
17234
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017235static int patch_alc861vd(struct hda_codec *codec)
17236{
17237 struct alc_spec *spec;
17238 int err, board_config;
17239
17240 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17241 if (spec == NULL)
17242 return -ENOMEM;
17243
17244 codec->spec = spec;
17245
17246 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17247 alc861vd_models,
17248 alc861vd_cfg_tbl);
17249
17250 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017251 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17252 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017253 board_config = ALC861VD_AUTO;
17254 }
17255
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017256 if (board_config == ALC861VD_AUTO)
17257 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017258
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017259 if (board_config == ALC861VD_AUTO) {
17260 /* automatic parse from the BIOS config */
17261 err = alc861vd_parse_auto_config(codec);
17262 if (err < 0) {
17263 alc_free(codec);
17264 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017265 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017266 printk(KERN_INFO
17267 "hda_codec: Cannot set up configuration "
17268 "from BIOS. Using base mode...\n");
17269 board_config = ALC861VD_3ST;
17270 }
17271 }
17272
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017273 err = snd_hda_attach_beep_device(codec, 0x23);
17274 if (err < 0) {
17275 alc_free(codec);
17276 return err;
17277 }
17278
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017279 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017280 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017281
Kailang Yang2f893282008-05-27 12:14:47 +020017282 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017283 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017284 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017285 }
17286
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017287 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17288 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17289
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017290 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17291 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17292
Takashi Iwaidd704692009-08-11 08:45:11 +020017293 if (!spec->adc_nids) {
17294 spec->adc_nids = alc861vd_adc_nids;
17295 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17296 }
17297 if (!spec->capsrc_nids)
17298 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017299
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017300 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017301 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017302
Takashi Iwai2134ea42008-01-10 16:53:55 +010017303 spec->vmaster_nid = 0x02;
17304
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017305 if (board_config == ALC861VD_AUTO)
17306 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
17307
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017308 codec->patch_ops = alc_patch_ops;
17309
17310 if (board_config == ALC861VD_AUTO)
17311 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017312#ifdef CONFIG_SND_HDA_POWER_SAVE
17313 if (!spec->loopback.amplist)
17314 spec->loopback.amplist = alc861vd_loopbacks;
17315#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017316
17317 return 0;
17318}
17319
17320/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017321 * ALC662 support
17322 *
17323 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17324 * configuration. Each pin widget can choose any input DACs and a mixer.
17325 * Each ADC is connected from a mixer of all inputs. This makes possible
17326 * 6-channel independent captures.
17327 *
17328 * In addition, an independent DAC for the multi-playback (not used in this
17329 * driver yet).
17330 */
17331#define ALC662_DIGOUT_NID 0x06
17332#define ALC662_DIGIN_NID 0x0a
17333
17334static hda_nid_t alc662_dac_nids[4] = {
17335 /* front, rear, clfe, rear_surr */
17336 0x02, 0x03, 0x04
17337};
17338
Kailang Yang622e84c2009-04-21 07:39:04 +020017339static hda_nid_t alc272_dac_nids[2] = {
17340 0x02, 0x03
17341};
17342
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017343static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017344 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017345 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017346};
Takashi Iwaie1406342008-02-11 18:32:32 +010017347
Kailang Yang622e84c2009-04-21 07:39:04 +020017348static hda_nid_t alc272_adc_nids[1] = {
17349 /* ADC1-2 */
17350 0x08,
17351};
17352
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017353static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017354static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17355
Takashi Iwaie1406342008-02-11 18:32:32 +010017356
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017357/* input MUX */
17358/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017359static struct hda_input_mux alc662_capture_source = {
17360 .num_items = 4,
17361 .items = {
17362 { "Mic", 0x0 },
17363 { "Front Mic", 0x1 },
17364 { "Line", 0x2 },
17365 { "CD", 0x4 },
17366 },
17367};
17368
17369static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17370 .num_items = 2,
17371 .items = {
17372 { "Mic", 0x1 },
17373 { "Line", 0x2 },
17374 },
17375};
Kailang Yang291702f2007-10-16 14:28:03 +020017376
Kailang Yang6dda9f42008-05-27 12:05:31 +020017377static struct hda_input_mux alc663_capture_source = {
17378 .num_items = 3,
17379 .items = {
17380 { "Mic", 0x0 },
17381 { "Front Mic", 0x1 },
17382 { "Line", 0x2 },
17383 },
17384};
17385
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017386#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017387static struct hda_input_mux alc272_nc10_capture_source = {
17388 .num_items = 16,
17389 .items = {
17390 { "Autoselect Mic", 0x0 },
17391 { "Internal Mic", 0x1 },
17392 { "In-0x02", 0x2 },
17393 { "In-0x03", 0x3 },
17394 { "In-0x04", 0x4 },
17395 { "In-0x05", 0x5 },
17396 { "In-0x06", 0x6 },
17397 { "In-0x07", 0x7 },
17398 { "In-0x08", 0x8 },
17399 { "In-0x09", 0x9 },
17400 { "In-0x0a", 0x0a },
17401 { "In-0x0b", 0x0b },
17402 { "In-0x0c", 0x0c },
17403 { "In-0x0d", 0x0d },
17404 { "In-0x0e", 0x0e },
17405 { "In-0x0f", 0x0f },
17406 },
17407};
17408#endif
17409
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017410/*
17411 * 2ch mode
17412 */
17413static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17414 { 2, NULL }
17415};
17416
17417/*
17418 * 2ch mode
17419 */
17420static struct hda_verb alc662_3ST_ch2_init[] = {
17421 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17422 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17423 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17424 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17425 { } /* end */
17426};
17427
17428/*
17429 * 6ch mode
17430 */
17431static struct hda_verb alc662_3ST_ch6_init[] = {
17432 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17433 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17434 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17435 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17436 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17437 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17438 { } /* end */
17439};
17440
17441static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17442 { 2, alc662_3ST_ch2_init },
17443 { 6, alc662_3ST_ch6_init },
17444};
17445
17446/*
17447 * 2ch mode
17448 */
17449static struct hda_verb alc662_sixstack_ch6_init[] = {
17450 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17451 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17452 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17453 { } /* end */
17454};
17455
17456/*
17457 * 6ch mode
17458 */
17459static struct hda_verb alc662_sixstack_ch8_init[] = {
17460 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17461 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17462 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17463 { } /* end */
17464};
17465
17466static struct hda_channel_mode alc662_5stack_modes[2] = {
17467 { 2, alc662_sixstack_ch6_init },
17468 { 6, alc662_sixstack_ch8_init },
17469};
17470
17471/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17472 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17473 */
17474
17475static struct snd_kcontrol_new alc662_base_mixer[] = {
17476 /* output mixer control */
17477 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017478 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017479 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017480 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017481 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17482 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017483 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17484 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017485 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17486
17487 /*Input mixer control */
17488 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17489 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17490 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17491 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17492 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17493 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17494 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17495 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017496 { } /* end */
17497};
17498
17499static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17500 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017501 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017502 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17503 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17504 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17505 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17506 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17507 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17508 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17509 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17510 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017511 { } /* end */
17512};
17513
17514static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17515 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017516 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017517 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017518 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017519 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),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017521 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17522 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017523 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17524 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17525 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17526 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17527 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17528 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17529 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17530 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17531 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017532 { } /* end */
17533};
17534
17535static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17536 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17537 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017538 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17539 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017540 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17541 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17542 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17543 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17544 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017545 { } /* end */
17546};
17547
Kailang Yang291702f2007-10-16 14:28:03 +020017548static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017549 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17550 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017551
17552 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
17553 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17554 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17555
17556 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17557 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17558 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17559 { } /* end */
17560};
17561
Kailang Yang8c427222008-01-10 13:03:59 +010017562static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017563 ALC262_HIPPO_MASTER_SWITCH,
17564 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017565 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017566 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17567 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017568 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17569 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17570 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17571 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17572 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17573 { } /* end */
17574};
17575
Kailang Yangf1d4e282008-08-26 14:03:29 +020017576static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17577 .ops = &snd_hda_bind_vol,
17578 .values = {
17579 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17580 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17581 0
17582 },
17583};
17584
17585static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17586 .ops = &snd_hda_bind_sw,
17587 .values = {
17588 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17589 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17590 0
17591 },
17592};
17593
Kailang Yang6dda9f42008-05-27 12:05:31 +020017594static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017595 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17596 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17597 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17598 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17599 { } /* end */
17600};
17601
17602static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17603 .ops = &snd_hda_bind_sw,
17604 .values = {
17605 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17606 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17607 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17608 0
17609 },
17610};
17611
17612static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17613 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17614 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17615 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17616 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17617 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17618 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17619
17620 { } /* end */
17621};
17622
17623static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17624 .ops = &snd_hda_bind_sw,
17625 .values = {
17626 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17627 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17628 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17629 0
17630 },
17631};
17632
17633static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17634 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17635 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17637 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17638 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17639 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17640 { } /* end */
17641};
17642
17643static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017644 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17645 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017646 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17647 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17648 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17649 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17650 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17651 { } /* end */
17652};
17653
17654static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17655 .ops = &snd_hda_bind_vol,
17656 .values = {
17657 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17658 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17659 0
17660 },
17661};
17662
17663static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17664 .ops = &snd_hda_bind_sw,
17665 .values = {
17666 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17667 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17668 0
17669 },
17670};
17671
17672static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17673 HDA_BIND_VOL("Master Playback Volume",
17674 &alc663_asus_two_bind_master_vol),
17675 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17676 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017677 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17678 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17679 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017680 { } /* end */
17681};
17682
17683static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17684 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17685 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17686 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17687 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17688 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17689 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017690 { } /* end */
17691};
17692
17693static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17694 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17695 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17696 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17697 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17698 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17699
17700 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17701 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17702 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17703 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17704 { } /* end */
17705};
17706
17707static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17708 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17709 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17710 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17711
17712 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17713 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17714 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17715 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17716 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17717 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17718 { } /* end */
17719};
17720
Kailang Yangebb83ee2009-12-17 12:23:00 +010017721static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17722 .ops = &snd_hda_bind_sw,
17723 .values = {
17724 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17725 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17726 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17727 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17728 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17729 0
17730 },
17731};
17732
17733static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17734 .ops = &snd_hda_bind_sw,
17735 .values = {
17736 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17737 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17738 0
17739 },
17740};
17741
17742static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17743 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17744 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17745 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17746 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17747 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17748 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17749 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17750 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17751 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17752 { } /* end */
17753};
17754
17755static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17756 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17757 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17758 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17759 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17760 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17761 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17762 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17763 { } /* end */
17764};
17765
17766
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017767static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17768 {
17769 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17770 .name = "Channel Mode",
17771 .info = alc_ch_mode_info,
17772 .get = alc_ch_mode_get,
17773 .put = alc_ch_mode_put,
17774 },
17775 { } /* end */
17776};
17777
17778static struct hda_verb alc662_init_verbs[] = {
17779 /* ADC: mute amp left and right */
17780 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17781 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017782
Kailang Yangb60dd392007-09-20 12:50:29 +020017783 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17784 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17785 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17786 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17787 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17788 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017789
17790 /* Front Pin: output 0 (0x0c) */
17791 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17792 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17793
17794 /* Rear Pin: output 1 (0x0d) */
17795 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17796 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17797
17798 /* CLFE Pin: output 2 (0x0e) */
17799 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17800 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17801
17802 /* Mic (rear) pin: input vref at 80% */
17803 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17804 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17805 /* Front Mic pin: input vref at 80% */
17806 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17807 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17808 /* Line In pin: input */
17809 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17810 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17811 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17812 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17813 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17814 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17815 /* CD pin widget for input */
17816 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17817
17818 /* FIXME: use matrix-type input source selection */
17819 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17820 /* Input mixer */
17821 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017822 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017823
17824 /* always trun on EAPD */
17825 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17826 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17827
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017828 { }
17829};
17830
Kailang Yangcec27c82010-02-04 14:18:18 +010017831static struct hda_verb alc663_init_verbs[] = {
17832 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17833 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17834 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17835 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17836 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17837 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17838 { }
17839};
17840
17841static struct hda_verb alc272_init_verbs[] = {
17842 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17843 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17844 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17845 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17846 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17847 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17848 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17849 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17850 { }
17851};
17852
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017853static struct hda_verb alc662_sue_init_verbs[] = {
17854 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17855 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017856 {}
17857};
17858
17859static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17860 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17861 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17862 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017863};
17864
Kailang Yang8c427222008-01-10 13:03:59 +010017865/* Set Unsolicited Event*/
17866static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17867 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17868 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17869 {}
17870};
17871
Kailang Yang6dda9f42008-05-27 12:05:31 +020017872static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017873 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17874 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017875 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17876 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017877 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17878 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17879 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017880 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17881 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17882 {}
17883};
17884
Kailang Yangf1d4e282008-08-26 14:03:29 +020017885static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17886 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17887 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17888 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17889 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17890 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17891 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17892 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17893 {}
17894};
17895
17896static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17897 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17898 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17899 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17900 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17901 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17903 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17904 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17905 {}
17906};
17907
17908static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17909 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17910 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17911 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17912 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17913 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17914 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17915 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17916 {}
17917};
17918
17919static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17920 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17921 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17922 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17923 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17924 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17925 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17926 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17927 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17928 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17929 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17930 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17931 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17932 {}
17933};
17934
17935static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17936 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17937 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17938 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17939 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17940 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17941 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17942 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17943 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17944 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17945 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17946 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17947 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17948 {}
17949};
17950
Kailang Yang6dda9f42008-05-27 12:05:31 +020017951static struct hda_verb alc663_g71v_init_verbs[] = {
17952 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17953 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17954 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17955
17956 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17957 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17958 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17959
17960 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17961 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17962 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17963 {}
17964};
17965
17966static struct hda_verb alc663_g50v_init_verbs[] = {
17967 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17968 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17969 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17970
17971 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17972 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17973 {}
17974};
17975
Kailang Yangf1d4e282008-08-26 14:03:29 +020017976static struct hda_verb alc662_ecs_init_verbs[] = {
17977 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17978 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17979 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17980 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17981 {}
17982};
17983
Kailang Yang622e84c2009-04-21 07:39:04 +020017984static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17985 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17986 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17987 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17988 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17989 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17990 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17991 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17992 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17993 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17994 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17995 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17996 {}
17997};
17998
17999static struct hda_verb alc272_dell_init_verbs[] = {
18000 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18001 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18002 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18003 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18004 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18005 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18006 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18007 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18008 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18009 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18010 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18011 {}
18012};
18013
Kailang Yangebb83ee2009-12-17 12:23:00 +010018014static struct hda_verb alc663_mode7_init_verbs[] = {
18015 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18016 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18017 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18018 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18019 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18020 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18021 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
18022 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18023 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18024 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18025 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18026 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18027 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18028 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18029 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18030 {}
18031};
18032
18033static struct hda_verb alc663_mode8_init_verbs[] = {
18034 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18035 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18036 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18037 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
18038 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18039 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18040 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18041 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18042 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18043 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18044 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18045 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18046 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18047 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18048 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18049 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18050 {}
18051};
18052
Kailang Yangf1d4e282008-08-26 14:03:29 +020018053static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
18054 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
18055 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
18056 { } /* end */
18057};
18058
Kailang Yang622e84c2009-04-21 07:39:04 +020018059static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
18060 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18061 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18062 { } /* end */
18063};
18064
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018065static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
18066{
18067 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018068 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018069
Wu Fengguang864f92b2009-11-18 12:38:02 +080018070 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018071 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018072
Takashi Iwai47fd8302007-08-10 17:11:07 +020018073 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18074 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018075}
18076
18077static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
18078{
18079 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018080 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018081
Wu Fengguang864f92b2009-11-18 12:38:02 +080018082 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018083 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018084
Takashi Iwai47fd8302007-08-10 17:11:07 +020018085 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18086 HDA_AMP_MUTE, bits);
18087 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18088 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018089}
18090
18091static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
18092 unsigned int res)
18093{
18094 if ((res >> 26) == ALC880_HP_EVENT)
18095 alc662_lenovo_101e_all_automute(codec);
18096 if ((res >> 26) == ALC880_FRONT_EVENT)
18097 alc662_lenovo_101e_ispeaker_automute(codec);
18098}
18099
Kailang Yang291702f2007-10-16 14:28:03 +020018100/* unsolicited event for HP jack sensing */
18101static void alc662_eeepc_unsol_event(struct hda_codec *codec,
18102 unsigned int res)
18103{
Kailang Yang291702f2007-10-16 14:28:03 +020018104 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018105 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020018106 else
18107 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020018108}
18109
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018110static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020018111{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018112 struct alc_spec *spec = codec->spec;
18113
18114 alc262_hippo1_setup(codec);
18115 spec->ext_mic.pin = 0x18;
18116 spec->ext_mic.mux_idx = 0;
18117 spec->int_mic.pin = 0x19;
18118 spec->int_mic.mux_idx = 1;
18119 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018120}
18121
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018122static void alc662_eeepc_inithook(struct hda_codec *codec)
18123{
18124 alc262_hippo_automute(codec);
18125 alc_mic_automute(codec);
18126}
18127
18128static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018129{
Takashi Iwai42171c12009-05-08 14:11:43 +020018130 struct alc_spec *spec = codec->spec;
18131
18132 spec->autocfg.hp_pins[0] = 0x14;
18133 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010018134}
18135
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018136#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
18137
Kailang Yang6dda9f42008-05-27 12:05:31 +020018138static void alc663_m51va_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, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018144 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018145 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018146 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018147 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018148 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018149}
18150
18151static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
18152{
18153 unsigned int present;
18154 unsigned char bits;
18155
Wu Fengguang864f92b2009-11-18 12:38:02 +080018156 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018157 bits = present ? HDA_AMP_MUTE : 0;
18158 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018159 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018160 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018161 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018162 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018163 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018164 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018165 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018166}
18167
18168static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18169{
18170 unsigned int present;
18171 unsigned char bits;
18172
Wu Fengguang864f92b2009-11-18 12:38:02 +080018173 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018174 bits = present ? HDA_AMP_MUTE : 0;
18175 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018176 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018177 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018178 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018179 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018180 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018181 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018182 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018183}
18184
18185static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18186{
18187 unsigned int present;
18188 unsigned char bits;
18189
Wu Fengguang864f92b2009-11-18 12:38:02 +080018190 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018191 bits = present ? 0 : PIN_OUT;
18192 snd_hda_codec_write(codec, 0x14, 0,
18193 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18194}
18195
18196static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18197{
18198 unsigned int present1, present2;
18199
Wu Fengguang864f92b2009-11-18 12:38:02 +080018200 present1 = snd_hda_jack_detect(codec, 0x21);
18201 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018202
18203 if (present1 || present2) {
18204 snd_hda_codec_write_cache(codec, 0x14, 0,
18205 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18206 } else {
18207 snd_hda_codec_write_cache(codec, 0x14, 0,
18208 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18209 }
18210}
18211
18212static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18213{
18214 unsigned int present1, present2;
18215
Wu Fengguang864f92b2009-11-18 12:38:02 +080018216 present1 = snd_hda_jack_detect(codec, 0x1b);
18217 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018218
18219 if (present1 || present2) {
18220 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018221 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018222 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018223 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018224 } else {
18225 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018226 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018227 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018228 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018229 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018230}
18231
Kailang Yangebb83ee2009-12-17 12:23:00 +010018232static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18233{
18234 unsigned int present1, present2;
18235
18236 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18237 AC_VERB_GET_PIN_SENSE, 0)
18238 & AC_PINSENSE_PRESENCE;
18239 present2 = snd_hda_codec_read(codec, 0x21, 0,
18240 AC_VERB_GET_PIN_SENSE, 0)
18241 & AC_PINSENSE_PRESENCE;
18242
18243 if (present1 || present2) {
18244 snd_hda_codec_write_cache(codec, 0x14, 0,
18245 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18246 snd_hda_codec_write_cache(codec, 0x17, 0,
18247 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18248 } else {
18249 snd_hda_codec_write_cache(codec, 0x14, 0,
18250 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18251 snd_hda_codec_write_cache(codec, 0x17, 0,
18252 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18253 }
18254}
18255
18256static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18257{
18258 unsigned int present1, present2;
18259
18260 present1 = snd_hda_codec_read(codec, 0x21, 0,
18261 AC_VERB_GET_PIN_SENSE, 0)
18262 & AC_PINSENSE_PRESENCE;
18263 present2 = snd_hda_codec_read(codec, 0x15, 0,
18264 AC_VERB_GET_PIN_SENSE, 0)
18265 & AC_PINSENSE_PRESENCE;
18266
18267 if (present1 || present2) {
18268 snd_hda_codec_write_cache(codec, 0x14, 0,
18269 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18270 snd_hda_codec_write_cache(codec, 0x17, 0,
18271 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18272 } else {
18273 snd_hda_codec_write_cache(codec, 0x14, 0,
18274 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18275 snd_hda_codec_write_cache(codec, 0x17, 0,
18276 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18277 }
18278}
18279
Kailang Yang6dda9f42008-05-27 12:05:31 +020018280static void alc663_m51va_unsol_event(struct hda_codec *codec,
18281 unsigned int res)
18282{
18283 switch (res >> 26) {
18284 case ALC880_HP_EVENT:
18285 alc663_m51va_speaker_automute(codec);
18286 break;
18287 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018288 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018289 break;
18290 }
18291}
18292
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018293static void alc663_m51va_setup(struct hda_codec *codec)
18294{
18295 struct alc_spec *spec = codec->spec;
18296 spec->ext_mic.pin = 0x18;
18297 spec->ext_mic.mux_idx = 0;
18298 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018299 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018300 spec->auto_mic = 1;
18301}
18302
Kailang Yang6dda9f42008-05-27 12:05:31 +020018303static void alc663_m51va_inithook(struct hda_codec *codec)
18304{
18305 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018306 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018307}
18308
Kailang Yangf1d4e282008-08-26 14:03:29 +020018309/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018310#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018311
18312static void alc663_mode1_setup(struct hda_codec *codec)
18313{
18314 struct alc_spec *spec = codec->spec;
18315 spec->ext_mic.pin = 0x18;
18316 spec->ext_mic.mux_idx = 0;
18317 spec->int_mic.pin = 0x19;
18318 spec->int_mic.mux_idx = 1;
18319 spec->auto_mic = 1;
18320}
18321
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018322#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018323
Kailang Yangf1d4e282008-08-26 14:03:29 +020018324/* ***************** Mode2 ******************************/
18325static void alc662_mode2_unsol_event(struct hda_codec *codec,
18326 unsigned int res)
18327{
18328 switch (res >> 26) {
18329 case ALC880_HP_EVENT:
18330 alc662_f5z_speaker_automute(codec);
18331 break;
18332 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018333 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018334 break;
18335 }
18336}
18337
Kailang Yangebb83ee2009-12-17 12:23:00 +010018338#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018339
Kailang Yangf1d4e282008-08-26 14:03:29 +020018340static void alc662_mode2_inithook(struct hda_codec *codec)
18341{
18342 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018343 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018344}
18345/* ***************** Mode3 ******************************/
18346static void alc663_mode3_unsol_event(struct hda_codec *codec,
18347 unsigned int res)
18348{
18349 switch (res >> 26) {
18350 case ALC880_HP_EVENT:
18351 alc663_two_hp_m1_speaker_automute(codec);
18352 break;
18353 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018354 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018355 break;
18356 }
18357}
18358
Kailang Yangebb83ee2009-12-17 12:23:00 +010018359#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018360
Kailang Yangf1d4e282008-08-26 14:03:29 +020018361static void alc663_mode3_inithook(struct hda_codec *codec)
18362{
18363 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018364 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018365}
18366/* ***************** Mode4 ******************************/
18367static void alc663_mode4_unsol_event(struct hda_codec *codec,
18368 unsigned int res)
18369{
18370 switch (res >> 26) {
18371 case ALC880_HP_EVENT:
18372 alc663_21jd_two_speaker_automute(codec);
18373 break;
18374 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018375 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018376 break;
18377 }
18378}
18379
Kailang Yangebb83ee2009-12-17 12:23:00 +010018380#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018381
Kailang Yangf1d4e282008-08-26 14:03:29 +020018382static void alc663_mode4_inithook(struct hda_codec *codec)
18383{
18384 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018385 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018386}
18387/* ***************** Mode5 ******************************/
18388static void alc663_mode5_unsol_event(struct hda_codec *codec,
18389 unsigned int res)
18390{
18391 switch (res >> 26) {
18392 case ALC880_HP_EVENT:
18393 alc663_15jd_two_speaker_automute(codec);
18394 break;
18395 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018396 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018397 break;
18398 }
18399}
18400
Kailang Yangebb83ee2009-12-17 12:23:00 +010018401#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018402
Kailang Yangf1d4e282008-08-26 14:03:29 +020018403static void alc663_mode5_inithook(struct hda_codec *codec)
18404{
18405 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018406 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018407}
18408/* ***************** Mode6 ******************************/
18409static void alc663_mode6_unsol_event(struct hda_codec *codec,
18410 unsigned int res)
18411{
18412 switch (res >> 26) {
18413 case ALC880_HP_EVENT:
18414 alc663_two_hp_m2_speaker_automute(codec);
18415 break;
18416 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018417 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018418 break;
18419 }
18420}
18421
Kailang Yangebb83ee2009-12-17 12:23:00 +010018422#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018423
Kailang Yangf1d4e282008-08-26 14:03:29 +020018424static void alc663_mode6_inithook(struct hda_codec *codec)
18425{
18426 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018427 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018428}
18429
Kailang Yangebb83ee2009-12-17 12:23:00 +010018430/* ***************** Mode7 ******************************/
18431static void alc663_mode7_unsol_event(struct hda_codec *codec,
18432 unsigned int res)
18433{
18434 switch (res >> 26) {
18435 case ALC880_HP_EVENT:
18436 alc663_two_hp_m7_speaker_automute(codec);
18437 break;
18438 case ALC880_MIC_EVENT:
18439 alc_mic_automute(codec);
18440 break;
18441 }
18442}
18443
18444#define alc663_mode7_setup alc663_mode1_setup
18445
18446static void alc663_mode7_inithook(struct hda_codec *codec)
18447{
18448 alc663_two_hp_m7_speaker_automute(codec);
18449 alc_mic_automute(codec);
18450}
18451
18452/* ***************** Mode8 ******************************/
18453static void alc663_mode8_unsol_event(struct hda_codec *codec,
18454 unsigned int res)
18455{
18456 switch (res >> 26) {
18457 case ALC880_HP_EVENT:
18458 alc663_two_hp_m8_speaker_automute(codec);
18459 break;
18460 case ALC880_MIC_EVENT:
18461 alc_mic_automute(codec);
18462 break;
18463 }
18464}
18465
18466#define alc663_mode8_setup alc663_m51va_setup
18467
18468static void alc663_mode8_inithook(struct hda_codec *codec)
18469{
18470 alc663_two_hp_m8_speaker_automute(codec);
18471 alc_mic_automute(codec);
18472}
18473
Kailang Yang6dda9f42008-05-27 12:05:31 +020018474static void alc663_g71v_hp_automute(struct hda_codec *codec)
18475{
18476 unsigned int present;
18477 unsigned char bits;
18478
Wu Fengguang864f92b2009-11-18 12:38:02 +080018479 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018480 bits = present ? HDA_AMP_MUTE : 0;
18481 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18482 HDA_AMP_MUTE, bits);
18483 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18484 HDA_AMP_MUTE, bits);
18485}
18486
18487static void alc663_g71v_front_automute(struct hda_codec *codec)
18488{
18489 unsigned int present;
18490 unsigned char bits;
18491
Wu Fengguang864f92b2009-11-18 12:38:02 +080018492 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018493 bits = present ? HDA_AMP_MUTE : 0;
18494 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18495 HDA_AMP_MUTE, bits);
18496}
18497
18498static void alc663_g71v_unsol_event(struct hda_codec *codec,
18499 unsigned int res)
18500{
18501 switch (res >> 26) {
18502 case ALC880_HP_EVENT:
18503 alc663_g71v_hp_automute(codec);
18504 break;
18505 case ALC880_FRONT_EVENT:
18506 alc663_g71v_front_automute(codec);
18507 break;
18508 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018509 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018510 break;
18511 }
18512}
18513
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018514#define alc663_g71v_setup alc663_m51va_setup
18515
Kailang Yang6dda9f42008-05-27 12:05:31 +020018516static void alc663_g71v_inithook(struct hda_codec *codec)
18517{
18518 alc663_g71v_front_automute(codec);
18519 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018520 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018521}
18522
18523static void alc663_g50v_unsol_event(struct hda_codec *codec,
18524 unsigned int res)
18525{
18526 switch (res >> 26) {
18527 case ALC880_HP_EVENT:
18528 alc663_m51va_speaker_automute(codec);
18529 break;
18530 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018531 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018532 break;
18533 }
18534}
18535
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018536#define alc663_g50v_setup alc663_m51va_setup
18537
Kailang Yang6dda9f42008-05-27 12:05:31 +020018538static void alc663_g50v_inithook(struct hda_codec *codec)
18539{
18540 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018541 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018542}
18543
Kailang Yangf1d4e282008-08-26 14:03:29 +020018544static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18545 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018546 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018547
18548 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
18549 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18550 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
18551
18552 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
18553 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18554 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18555 { } /* end */
18556};
18557
Chris Pockelé9541ba12009-05-12 08:08:53 +020018558static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18559 /* Master Playback automatically created from Speaker and Headphone */
18560 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18561 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18562 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18563 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18564
18565 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18566 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
18567 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
18568
18569 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18570 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18571 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
18572 { } /* end */
18573};
18574
Takashi Iwaicb53c622007-08-10 17:21:45 +020018575#ifdef CONFIG_SND_HDA_POWER_SAVE
18576#define alc662_loopbacks alc880_loopbacks
18577#endif
18578
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018579
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018580/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018581#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18582#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18583#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18584#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18585
18586/*
18587 * configuration and preset
18588 */
18589static const char *alc662_models[ALC662_MODEL_LAST] = {
18590 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18591 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18592 [ALC662_3ST_6ch] = "3stack-6ch",
18593 [ALC662_5ST_DIG] = "6stack-dig",
18594 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018595 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018596 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018597 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018598 [ALC663_ASUS_M51VA] = "m51va",
18599 [ALC663_ASUS_G71V] = "g71v",
18600 [ALC663_ASUS_H13] = "h13",
18601 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018602 [ALC663_ASUS_MODE1] = "asus-mode1",
18603 [ALC662_ASUS_MODE2] = "asus-mode2",
18604 [ALC663_ASUS_MODE3] = "asus-mode3",
18605 [ALC663_ASUS_MODE4] = "asus-mode4",
18606 [ALC663_ASUS_MODE5] = "asus-mode5",
18607 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018608 [ALC663_ASUS_MODE7] = "asus-mode7",
18609 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018610 [ALC272_DELL] = "dell",
18611 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018612 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018613 [ALC662_AUTO] = "auto",
18614};
18615
18616static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018617 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018618 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18619 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018620 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18621 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018622 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018623 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18624 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18625 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18626 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018627 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18628 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018629 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018630 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18631 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18632 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18633 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18634 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018635 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018636 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18637 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018638 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18639 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18640 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18641 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018642 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018643 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18644 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18645 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018646 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18647 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18648 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18649 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018650 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018651 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18652 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018653 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018654 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18655 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18656 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018657 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018658 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018659 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18660 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018661 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18662 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18663 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018664 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018665 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18666 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018667 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018668 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018669 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018670 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18671 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18672 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018673 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018674 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18675 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018676 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018677 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018678 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018679 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018680 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18681 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018682 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018683 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018684 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18685 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018686 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018687 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018688 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018689 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018690 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018691 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018692 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18693 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018694 {}
18695};
18696
18697static struct alc_config_preset alc662_presets[] = {
18698 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018699 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018700 .init_verbs = { alc662_init_verbs },
18701 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18702 .dac_nids = alc662_dac_nids,
18703 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018704 .dig_in_nid = ALC662_DIGIN_NID,
18705 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18706 .channel_mode = alc662_3ST_2ch_modes,
18707 .input_mux = &alc662_capture_source,
18708 },
18709 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018710 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018711 .init_verbs = { alc662_init_verbs },
18712 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18713 .dac_nids = alc662_dac_nids,
18714 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018715 .dig_in_nid = ALC662_DIGIN_NID,
18716 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18717 .channel_mode = alc662_3ST_6ch_modes,
18718 .need_dac_fix = 1,
18719 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018720 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018721 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018722 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018723 .init_verbs = { alc662_init_verbs },
18724 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18725 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018726 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18727 .channel_mode = alc662_3ST_6ch_modes,
18728 .need_dac_fix = 1,
18729 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018730 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018731 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018732 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018733 .init_verbs = { alc662_init_verbs },
18734 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18735 .dac_nids = alc662_dac_nids,
18736 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018737 .dig_in_nid = ALC662_DIGIN_NID,
18738 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18739 .channel_mode = alc662_5stack_modes,
18740 .input_mux = &alc662_capture_source,
18741 },
18742 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018743 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018744 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18745 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18746 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018747 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18748 .channel_mode = alc662_3ST_2ch_modes,
18749 .input_mux = &alc662_lenovo_101e_capture_source,
18750 .unsol_event = alc662_lenovo_101e_unsol_event,
18751 .init_hook = alc662_lenovo_101e_all_automute,
18752 },
Kailang Yang291702f2007-10-16 14:28:03 +020018753 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018754 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018755 .init_verbs = { alc662_init_verbs,
18756 alc662_eeepc_sue_init_verbs },
18757 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18758 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018759 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18760 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018761 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018762 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018763 .init_hook = alc662_eeepc_inithook,
18764 },
Kailang Yang8c427222008-01-10 13:03:59 +010018765 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018766 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018767 alc662_chmode_mixer },
18768 .init_verbs = { alc662_init_verbs,
18769 alc662_eeepc_ep20_sue_init_verbs },
18770 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18771 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018772 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18773 .channel_mode = alc662_3ST_6ch_modes,
18774 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018775 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018776 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018777 .init_hook = alc662_eeepc_ep20_inithook,
18778 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018779 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018780 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018781 .init_verbs = { alc662_init_verbs,
18782 alc662_ecs_init_verbs },
18783 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18784 .dac_nids = alc662_dac_nids,
18785 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18786 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018787 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018788 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018789 .init_hook = alc662_eeepc_inithook,
18790 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018791 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018792 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018793 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18794 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18795 .dac_nids = alc662_dac_nids,
18796 .dig_out_nid = ALC662_DIGOUT_NID,
18797 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18798 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018799 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018800 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018801 .init_hook = alc663_m51va_inithook,
18802 },
18803 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018804 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018805 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18806 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18807 .dac_nids = alc662_dac_nids,
18808 .dig_out_nid = ALC662_DIGOUT_NID,
18809 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18810 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018811 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018812 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018813 .init_hook = alc663_g71v_inithook,
18814 },
18815 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018816 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018817 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18818 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18819 .dac_nids = alc662_dac_nids,
18820 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18821 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018822 .unsol_event = alc663_m51va_unsol_event,
18823 .init_hook = alc663_m51va_inithook,
18824 },
18825 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018826 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018827 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18828 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18829 .dac_nids = alc662_dac_nids,
18830 .dig_out_nid = ALC662_DIGOUT_NID,
18831 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18832 .channel_mode = alc662_3ST_6ch_modes,
18833 .input_mux = &alc663_capture_source,
18834 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018835 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018836 .init_hook = alc663_g50v_inithook,
18837 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018838 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018839 .mixers = { alc663_m51va_mixer },
18840 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018841 .init_verbs = { alc662_init_verbs,
18842 alc663_21jd_amic_init_verbs },
18843 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18844 .hp_nid = 0x03,
18845 .dac_nids = alc662_dac_nids,
18846 .dig_out_nid = ALC662_DIGOUT_NID,
18847 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18848 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018849 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018850 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018851 .init_hook = alc663_mode1_inithook,
18852 },
18853 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018854 .mixers = { alc662_1bjd_mixer },
18855 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018856 .init_verbs = { alc662_init_verbs,
18857 alc662_1bjd_amic_init_verbs },
18858 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18859 .dac_nids = alc662_dac_nids,
18860 .dig_out_nid = ALC662_DIGOUT_NID,
18861 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18862 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018863 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018864 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018865 .init_hook = alc662_mode2_inithook,
18866 },
18867 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018868 .mixers = { alc663_two_hp_m1_mixer },
18869 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018870 .init_verbs = { alc662_init_verbs,
18871 alc663_two_hp_amic_m1_init_verbs },
18872 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18873 .hp_nid = 0x03,
18874 .dac_nids = alc662_dac_nids,
18875 .dig_out_nid = ALC662_DIGOUT_NID,
18876 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18877 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018878 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018879 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018880 .init_hook = alc663_mode3_inithook,
18881 },
18882 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018883 .mixers = { alc663_asus_21jd_clfe_mixer },
18884 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018885 .init_verbs = { alc662_init_verbs,
18886 alc663_21jd_amic_init_verbs},
18887 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18888 .hp_nid = 0x03,
18889 .dac_nids = alc662_dac_nids,
18890 .dig_out_nid = ALC662_DIGOUT_NID,
18891 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18892 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018893 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018894 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018895 .init_hook = alc663_mode4_inithook,
18896 },
18897 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018898 .mixers = { alc663_asus_15jd_clfe_mixer },
18899 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018900 .init_verbs = { alc662_init_verbs,
18901 alc663_15jd_amic_init_verbs },
18902 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18903 .hp_nid = 0x03,
18904 .dac_nids = alc662_dac_nids,
18905 .dig_out_nid = ALC662_DIGOUT_NID,
18906 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18907 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018908 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018909 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018910 .init_hook = alc663_mode5_inithook,
18911 },
18912 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018913 .mixers = { alc663_two_hp_m2_mixer },
18914 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018915 .init_verbs = { alc662_init_verbs,
18916 alc663_two_hp_amic_m2_init_verbs },
18917 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18918 .hp_nid = 0x03,
18919 .dac_nids = alc662_dac_nids,
18920 .dig_out_nid = ALC662_DIGOUT_NID,
18921 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18922 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018923 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018924 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018925 .init_hook = alc663_mode6_inithook,
18926 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018927 [ALC663_ASUS_MODE7] = {
18928 .mixers = { alc663_mode7_mixer },
18929 .cap_mixer = alc662_auto_capture_mixer,
18930 .init_verbs = { alc662_init_verbs,
18931 alc663_mode7_init_verbs },
18932 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18933 .hp_nid = 0x03,
18934 .dac_nids = alc662_dac_nids,
18935 .dig_out_nid = ALC662_DIGOUT_NID,
18936 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18937 .channel_mode = alc662_3ST_2ch_modes,
18938 .unsol_event = alc663_mode7_unsol_event,
18939 .setup = alc663_mode7_setup,
18940 .init_hook = alc663_mode7_inithook,
18941 },
18942 [ALC663_ASUS_MODE8] = {
18943 .mixers = { alc663_mode8_mixer },
18944 .cap_mixer = alc662_auto_capture_mixer,
18945 .init_verbs = { alc662_init_verbs,
18946 alc663_mode8_init_verbs },
18947 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18948 .hp_nid = 0x03,
18949 .dac_nids = alc662_dac_nids,
18950 .dig_out_nid = ALC662_DIGOUT_NID,
18951 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18952 .channel_mode = alc662_3ST_2ch_modes,
18953 .unsol_event = alc663_mode8_unsol_event,
18954 .setup = alc663_mode8_setup,
18955 .init_hook = alc663_mode8_inithook,
18956 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018957 [ALC272_DELL] = {
18958 .mixers = { alc663_m51va_mixer },
18959 .cap_mixer = alc272_auto_capture_mixer,
18960 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18961 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18962 .dac_nids = alc662_dac_nids,
18963 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18964 .adc_nids = alc272_adc_nids,
18965 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18966 .capsrc_nids = alc272_capsrc_nids,
18967 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018968 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018969 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018970 .init_hook = alc663_m51va_inithook,
18971 },
18972 [ALC272_DELL_ZM1] = {
18973 .mixers = { alc663_m51va_mixer },
18974 .cap_mixer = alc662_auto_capture_mixer,
18975 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18976 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18977 .dac_nids = alc662_dac_nids,
18978 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18979 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018980 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018981 .capsrc_nids = alc662_capsrc_nids,
18982 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018983 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018984 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018985 .init_hook = alc663_m51va_inithook,
18986 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018987 [ALC272_SAMSUNG_NC10] = {
18988 .mixers = { alc272_nc10_mixer },
18989 .init_verbs = { alc662_init_verbs,
18990 alc663_21jd_amic_init_verbs },
18991 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18992 .dac_nids = alc272_dac_nids,
18993 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18994 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018995 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018996 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018997 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018998 .init_hook = alc663_mode4_inithook,
18999 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019000};
19001
19002
19003/*
19004 * BIOS auto configuration
19005 */
19006
Takashi Iwai7085ec12009-10-02 09:03:58 +020019007/* convert from MIX nid to DAC */
19008static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
19009{
19010 if (nid == 0x0f)
19011 return 0x02;
19012 else if (nid >= 0x0c && nid <= 0x0e)
19013 return nid - 0x0c + 0x02;
David Henningssoncc1c4522010-11-24 14:17:47 +010019014 else if (nid == 0x26) /* ALC887-VD has this DAC too */
19015 return 0x25;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019016 else
19017 return 0;
19018}
19019
19020/* get MIX nid connected to the given pin targeted to DAC */
19021static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
19022 hda_nid_t dac)
19023{
David Henningssoncc1c4522010-11-24 14:17:47 +010019024 hda_nid_t mix[5];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019025 int i, num;
19026
19027 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
19028 for (i = 0; i < num; i++) {
19029 if (alc662_mix_to_dac(mix[i]) == dac)
19030 return mix[i];
19031 }
19032 return 0;
19033}
19034
19035/* look for an empty DAC slot */
19036static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
19037{
19038 struct alc_spec *spec = codec->spec;
19039 hda_nid_t srcs[5];
19040 int i, j, num;
19041
19042 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
19043 if (num < 0)
19044 return 0;
19045 for (i = 0; i < num; i++) {
19046 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
19047 if (!nid)
19048 continue;
19049 for (j = 0; j < spec->multiout.num_dacs; j++)
19050 if (spec->multiout.dac_nids[j] == nid)
19051 break;
19052 if (j >= spec->multiout.num_dacs)
19053 return nid;
19054 }
19055 return 0;
19056}
19057
19058/* fill in the dac_nids table from the parsed pin configuration */
19059static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
19060 const struct auto_pin_cfg *cfg)
19061{
19062 struct alc_spec *spec = codec->spec;
19063 int i;
19064 hda_nid_t dac;
19065
19066 spec->multiout.dac_nids = spec->private_dac_nids;
19067 for (i = 0; i < cfg->line_outs; i++) {
19068 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
19069 if (!dac)
19070 continue;
19071 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19072 }
19073 return 0;
19074}
19075
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019076static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019077 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019078{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019079 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019080 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
19081}
19082
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019083static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019084 hda_nid_t nid, unsigned int chs)
19085{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019086 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019087 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
19088}
19089
19090#define alc662_add_stereo_vol(spec, pfx, nid) \
19091 alc662_add_vol_ctl(spec, pfx, nid, 3)
19092#define alc662_add_stereo_sw(spec, pfx, nid) \
19093 alc662_add_sw_ctl(spec, pfx, nid, 3)
19094
19095/* add playback controls from the parsed DAC table */
19096static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
19097 const struct auto_pin_cfg *cfg)
19098{
19099 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019100 static const char *chname[4] = {
19101 "Front", "Surround", NULL /*CLFE*/, "Side"
19102 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020019103 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019104 int i, err;
19105
19106 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019107 nid = spec->multiout.dac_nids[i];
19108 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019109 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019110 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
19111 if (!mix)
19112 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019113 if (i == 2) {
19114 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019115 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019116 if (err < 0)
19117 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019118 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019119 if (err < 0)
19120 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019121 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019122 if (err < 0)
19123 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019124 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019125 if (err < 0)
19126 return err;
19127 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019128 const char *pfx;
19129 if (cfg->line_outs == 1 &&
19130 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019131 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019132 pfx = "Speaker";
19133 else
19134 pfx = "PCM";
19135 } else
19136 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019137 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019138 if (err < 0)
19139 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019140 if (cfg->line_outs == 1 &&
19141 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19142 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020019143 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019144 if (err < 0)
19145 return err;
19146 }
19147 }
19148 return 0;
19149}
19150
19151/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019152/* return DAC nid if any new DAC is assigned */
19153static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019154 const char *pfx)
19155{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019156 struct alc_spec *spec = codec->spec;
19157 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019158 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019159
19160 if (!pin)
19161 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019162 nid = alc662_look_for_dac(codec, pin);
19163 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019164 /* the corresponding DAC is already occupied */
19165 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19166 return 0; /* no way */
19167 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019168 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019169 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19170 }
19171
19172 mix = alc662_dac_to_mix(codec, pin, nid);
19173 if (!mix)
19174 return 0;
19175 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19176 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019177 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019178 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19179 if (err < 0)
19180 return err;
19181 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019182}
19183
19184/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019185#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019186 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019187
19188static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19189 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019190 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019191{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019192 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019193 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019194
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019195 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019196 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019197 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19198 if (num <= 1)
19199 return;
19200 for (i = 0; i < num; i++) {
19201 if (alc662_mix_to_dac(srcs[i]) != dac)
19202 continue;
19203 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19204 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019205 }
19206}
19207
19208static void alc662_auto_init_multi_out(struct hda_codec *codec)
19209{
19210 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019211 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019212 int i;
19213
19214 for (i = 0; i <= HDA_SIDE; i++) {
19215 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19216 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019217 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019218 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019219 }
19220}
19221
19222static void alc662_auto_init_hp_out(struct hda_codec *codec)
19223{
19224 struct alc_spec *spec = codec->spec;
19225 hda_nid_t pin;
19226
19227 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019228 if (pin)
19229 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19230 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019231 pin = spec->autocfg.speaker_pins[0];
19232 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019233 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19234 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019235}
19236
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019237#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19238
19239static void alc662_auto_init_analog_input(struct hda_codec *codec)
19240{
19241 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019242 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019243 int i;
19244
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019245 for (i = 0; i < cfg->num_inputs; i++) {
19246 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019247 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019248 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019249 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019250 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019251 snd_hda_codec_write(codec, nid, 0,
19252 AC_VERB_SET_AMP_GAIN_MUTE,
19253 AMP_OUT_MUTE);
19254 }
19255 }
19256}
19257
Takashi Iwaif511b012008-08-15 16:46:42 +020019258#define alc662_auto_init_input_src alc882_auto_init_input_src
19259
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019260static int alc662_parse_auto_config(struct hda_codec *codec)
19261{
19262 struct alc_spec *spec = codec->spec;
19263 int err;
19264 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19265
19266 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19267 alc662_ignore);
19268 if (err < 0)
19269 return err;
19270 if (!spec->autocfg.line_outs)
19271 return 0; /* can't find valid BIOS pin config */
19272
Takashi Iwai7085ec12009-10-02 09:03:58 +020019273 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019274 if (err < 0)
19275 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019276 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019277 if (err < 0)
19278 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019279 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019280 spec->autocfg.speaker_pins[0],
19281 "Speaker");
19282 if (err < 0)
19283 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019284 if (err)
19285 spec->multiout.extra_out_nid[0] = err;
19286 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019287 "Headphone");
19288 if (err < 0)
19289 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019290 if (err)
19291 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019292 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019293 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019294 return err;
19295
19296 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19297
Takashi Iwai757899a2010-07-30 10:48:14 +020019298 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019299
Takashi Iwai603c4012008-07-30 15:01:44 +020019300 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019301 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019302
19303 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019304 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019305
Kailang Yangcec27c82010-02-04 14:18:18 +010019306 add_verb(spec, alc662_init_verbs);
19307 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019308 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019309 add_verb(spec, alc663_init_verbs);
19310
19311 if (codec->vendor_id == 0x10ec0272)
19312 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019313
19314 err = alc_auto_add_mic_boost(codec);
19315 if (err < 0)
19316 return err;
19317
Kailang Yang6227cdc2010-02-25 08:36:52 +010019318 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19319 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19320 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19321 else
19322 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019323
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019324 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019325}
19326
19327/* additional initialization for auto-configuration model */
19328static void alc662_auto_init(struct hda_codec *codec)
19329{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019330 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019331 alc662_auto_init_multi_out(codec);
19332 alc662_auto_init_hp_out(codec);
19333 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019334 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019335 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019336 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019337 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019338}
19339
David Henningsson6cb3b702010-09-09 08:51:44 +020019340enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040019341 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019342 ALC662_FIXUP_IDEAPAD,
19343};
19344
19345static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019346 [ALC662_FIXUP_ASPIRE] = {
19347 .pins = (const struct alc_pincfg[]) {
19348 { 0x15, 0x99130112 }, /* subwoofer */
19349 { }
19350 }
19351 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019352 [ALC662_FIXUP_IDEAPAD] = {
19353 .pins = (const struct alc_pincfg[]) {
19354 { 0x17, 0x99130112 }, /* subwoofer */
19355 { }
19356 }
19357 },
19358};
19359
19360static struct snd_pci_quirk alc662_fixup_tbl[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019361 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050019362 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060019363 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020019364 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
19365 {}
19366};
19367
19368
19369
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019370static int patch_alc662(struct hda_codec *codec)
19371{
19372 struct alc_spec *spec;
19373 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020019374 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019375
19376 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19377 if (!spec)
19378 return -ENOMEM;
19379
19380 codec->spec = spec;
19381
Kailang Yangda00c242010-03-19 11:23:45 +010019382 alc_auto_parse_customize_define(codec);
19383
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019384 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19385
Kailang Yang693194f2010-10-21 08:51:48 +020019386 coef = alc_read_coef_idx(codec, 0);
19387 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019388 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020019389 else if (coef & (1 << 14) &&
19390 codec->bus->pci->subsystem_vendor == 0x1025 &&
19391 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019392 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019393 else if (coef == 0x4011)
19394 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019395
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019396 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19397 alc662_models,
19398 alc662_cfg_tbl);
19399 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019400 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19401 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019402 board_config = ALC662_AUTO;
19403 }
19404
19405 if (board_config == ALC662_AUTO) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019406 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019407 /* automatic parse from the BIOS config */
19408 err = alc662_parse_auto_config(codec);
19409 if (err < 0) {
19410 alc_free(codec);
19411 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019412 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019413 printk(KERN_INFO
19414 "hda_codec: Cannot set up configuration "
19415 "from BIOS. Using base mode...\n");
19416 board_config = ALC662_3ST_2ch_DIG;
19417 }
19418 }
19419
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019420 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019421 err = snd_hda_attach_beep_device(codec, 0x1);
19422 if (err < 0) {
19423 alc_free(codec);
19424 return err;
19425 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019426 }
19427
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019428 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019429 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019430
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019431 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19432 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19433
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019434 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19435 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19436
Takashi Iwaidd704692009-08-11 08:45:11 +020019437 if (!spec->adc_nids) {
19438 spec->adc_nids = alc662_adc_nids;
19439 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19440 }
19441 if (!spec->capsrc_nids)
19442 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019443
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019444 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019445 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019446
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019447 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019448 switch (codec->vendor_id) {
19449 case 0x10ec0662:
19450 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19451 break;
19452 case 0x10ec0272:
19453 case 0x10ec0663:
19454 case 0x10ec0665:
19455 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19456 break;
19457 case 0x10ec0273:
19458 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19459 break;
19460 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019461 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019462 spec->vmaster_nid = 0x02;
19463
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019464 codec->patch_ops = alc_patch_ops;
David Henningsson6cb3b702010-09-09 08:51:44 +020019465 if (board_config == ALC662_AUTO) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019466 spec->init_hook = alc662_auto_init;
David Henningsson6cb3b702010-09-09 08:51:44 +020019467 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 0);
19468 }
19469
Kailang Yangbf1b0222010-10-21 08:49:56 +020019470 alc_init_jacks(codec);
19471
Takashi Iwaicb53c622007-08-10 17:21:45 +020019472#ifdef CONFIG_SND_HDA_POWER_SAVE
19473 if (!spec->loopback.amplist)
19474 spec->loopback.amplist = alc662_loopbacks;
19475#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019476
19477 return 0;
19478}
19479
Kailang Yang274693f2009-12-03 10:07:50 +010019480static int patch_alc888(struct hda_codec *codec)
19481{
19482 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19483 kfree(codec->chip_name);
Kailang Yang01e0f132010-11-22 10:59:36 +010019484 if (codec->vendor_id == 0x10ec0887)
19485 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19486 else
19487 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019488 if (!codec->chip_name) {
19489 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019490 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019491 }
19492 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019493 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019494 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019495}
19496
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019497/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019498 * ALC680 support
19499 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019500#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019501#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19502#define alc680_modes alc260_modes
19503
19504static hda_nid_t alc680_dac_nids[3] = {
19505 /* Lout1, Lout2, hp */
19506 0x02, 0x03, 0x04
19507};
19508
19509static hda_nid_t alc680_adc_nids[3] = {
19510 /* ADC0-2 */
19511 /* DMIC, MIC, Line-in*/
19512 0x07, 0x08, 0x09
19513};
19514
Kailang Yangc69aefa2010-08-17 10:39:22 +020019515/*
19516 * Analog capture ADC cgange
19517 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019518static void alc680_rec_autoswitch(struct hda_codec *codec)
19519{
19520 struct alc_spec *spec = codec->spec;
19521 struct auto_pin_cfg *cfg = &spec->autocfg;
19522 int pin_found = 0;
19523 int type_found = AUTO_PIN_LAST;
19524 hda_nid_t nid;
19525 int i;
19526
19527 for (i = 0; i < cfg->num_inputs; i++) {
19528 nid = cfg->inputs[i].pin;
19529 if (!(snd_hda_query_pin_caps(codec, nid) &
19530 AC_PINCAP_PRES_DETECT))
19531 continue;
19532 if (snd_hda_jack_detect(codec, nid)) {
19533 if (cfg->inputs[i].type < type_found) {
19534 type_found = cfg->inputs[i].type;
19535 pin_found = nid;
19536 }
19537 }
19538 }
19539
19540 nid = 0x07;
19541 if (pin_found)
19542 snd_hda_get_connections(codec, pin_found, &nid, 1);
19543
19544 if (nid != spec->cur_adc)
19545 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19546 spec->cur_adc = nid;
19547 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19548 spec->cur_adc_format);
19549}
19550
Kailang Yangc69aefa2010-08-17 10:39:22 +020019551static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19552 struct hda_codec *codec,
19553 unsigned int stream_tag,
19554 unsigned int format,
19555 struct snd_pcm_substream *substream)
19556{
19557 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019558
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019559 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019560 spec->cur_adc_stream_tag = stream_tag;
19561 spec->cur_adc_format = format;
19562
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019563 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019564 return 0;
19565}
19566
19567static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19568 struct hda_codec *codec,
19569 struct snd_pcm_substream *substream)
19570{
19571 snd_hda_codec_cleanup_stream(codec, 0x07);
19572 snd_hda_codec_cleanup_stream(codec, 0x08);
19573 snd_hda_codec_cleanup_stream(codec, 0x09);
19574 return 0;
19575}
19576
19577static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19578 .substreams = 1, /* can be overridden */
19579 .channels_min = 2,
19580 .channels_max = 2,
19581 /* NID is set in alc_build_pcms */
19582 .ops = {
19583 .prepare = alc680_capture_pcm_prepare,
19584 .cleanup = alc680_capture_pcm_cleanup
19585 },
19586};
19587
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019588static struct snd_kcontrol_new alc680_base_mixer[] = {
19589 /* output mixer control */
19590 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19591 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19592 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19593 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019594 HDA_CODEC_VOLUME("Int Mic Boost", 0x12, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019595 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019596 HDA_CODEC_VOLUME("Line In Boost", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019597 { }
19598};
19599
Kailang Yangc69aefa2010-08-17 10:39:22 +020019600static struct hda_bind_ctls alc680_bind_cap_vol = {
19601 .ops = &snd_hda_bind_vol,
19602 .values = {
19603 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19604 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19605 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19606 0
19607 },
19608};
19609
19610static struct hda_bind_ctls alc680_bind_cap_switch = {
19611 .ops = &snd_hda_bind_sw,
19612 .values = {
19613 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19614 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19615 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19616 0
19617 },
19618};
19619
19620static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19621 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19622 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019623 { } /* end */
19624};
19625
19626/*
19627 * generic initialization of ADC, input mixers and output mixers
19628 */
19629static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019630 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19631 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19632 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019633
Kailang Yangc69aefa2010-08-17 10:39:22 +020019634 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19635 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19636 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19637 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19638 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19639 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019640
19641 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19642 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19643 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19644 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19645 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019646
19647 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19648 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019649 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019650
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019651 { }
19652};
19653
Kailang Yangc69aefa2010-08-17 10:39:22 +020019654/* toggle speaker-output according to the hp-jack state */
19655static void alc680_base_setup(struct hda_codec *codec)
19656{
19657 struct alc_spec *spec = codec->spec;
19658
19659 spec->autocfg.hp_pins[0] = 0x16;
19660 spec->autocfg.speaker_pins[0] = 0x14;
19661 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019662 spec->autocfg.num_inputs = 2;
19663 spec->autocfg.inputs[0].pin = 0x18;
19664 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19665 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019666 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019667}
19668
19669static void alc680_unsol_event(struct hda_codec *codec,
19670 unsigned int res)
19671{
19672 if ((res >> 26) == ALC880_HP_EVENT)
19673 alc_automute_amp(codec);
19674 if ((res >> 26) == ALC880_MIC_EVENT)
19675 alc680_rec_autoswitch(codec);
19676}
19677
19678static void alc680_inithook(struct hda_codec *codec)
19679{
19680 alc_automute_amp(codec);
19681 alc680_rec_autoswitch(codec);
19682}
19683
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019684/* create input playback/capture controls for the given pin */
19685static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19686 const char *ctlname, int idx)
19687{
19688 hda_nid_t dac;
19689 int err;
19690
19691 switch (nid) {
19692 case 0x14:
19693 dac = 0x02;
19694 break;
19695 case 0x15:
19696 dac = 0x03;
19697 break;
19698 case 0x16:
19699 dac = 0x04;
19700 break;
19701 default:
19702 return 0;
19703 }
19704 if (spec->multiout.dac_nids[0] != dac &&
19705 spec->multiout.dac_nids[1] != dac) {
19706 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19707 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19708 HDA_OUTPUT));
19709 if (err < 0)
19710 return err;
19711
19712 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19713 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19714
19715 if (err < 0)
19716 return err;
19717 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19718 }
19719
19720 return 0;
19721}
19722
19723/* add playback controls from the parsed DAC table */
19724static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19725 const struct auto_pin_cfg *cfg)
19726{
19727 hda_nid_t nid;
19728 int err;
19729
19730 spec->multiout.dac_nids = spec->private_dac_nids;
19731
19732 nid = cfg->line_out_pins[0];
19733 if (nid) {
19734 const char *name;
19735 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19736 name = "Speaker";
19737 else
19738 name = "Front";
19739 err = alc680_new_analog_output(spec, nid, name, 0);
19740 if (err < 0)
19741 return err;
19742 }
19743
19744 nid = cfg->speaker_pins[0];
19745 if (nid) {
19746 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19747 if (err < 0)
19748 return err;
19749 }
19750 nid = cfg->hp_pins[0];
19751 if (nid) {
19752 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19753 if (err < 0)
19754 return err;
19755 }
19756
19757 return 0;
19758}
19759
19760static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19761 hda_nid_t nid, int pin_type)
19762{
19763 alc_set_pin_output(codec, nid, pin_type);
19764}
19765
19766static void alc680_auto_init_multi_out(struct hda_codec *codec)
19767{
19768 struct alc_spec *spec = codec->spec;
19769 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19770 if (nid) {
19771 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19772 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19773 }
19774}
19775
19776static void alc680_auto_init_hp_out(struct hda_codec *codec)
19777{
19778 struct alc_spec *spec = codec->spec;
19779 hda_nid_t pin;
19780
19781 pin = spec->autocfg.hp_pins[0];
19782 if (pin)
19783 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19784 pin = spec->autocfg.speaker_pins[0];
19785 if (pin)
19786 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19787}
19788
19789/* pcm configuration: identical with ALC880 */
19790#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19791#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19792#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19793#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019794#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019795
19796/*
19797 * BIOS auto configuration
19798 */
19799static int alc680_parse_auto_config(struct hda_codec *codec)
19800{
19801 struct alc_spec *spec = codec->spec;
19802 int err;
19803 static hda_nid_t alc680_ignore[] = { 0 };
19804
19805 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19806 alc680_ignore);
19807 if (err < 0)
19808 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019809
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019810 if (!spec->autocfg.line_outs) {
19811 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19812 spec->multiout.max_channels = 2;
19813 spec->no_analog = 1;
19814 goto dig_only;
19815 }
19816 return 0; /* can't find valid BIOS pin config */
19817 }
19818 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19819 if (err < 0)
19820 return err;
19821
19822 spec->multiout.max_channels = 2;
19823
19824 dig_only:
19825 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019826 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019827 if (spec->kctls.list)
19828 add_mixer(spec, spec->kctls.list);
19829
19830 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019831
19832 err = alc_auto_add_mic_boost(codec);
19833 if (err < 0)
19834 return err;
19835
19836 return 1;
19837}
19838
19839#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19840
19841/* init callback for auto-configuration model -- overriding the default init */
19842static void alc680_auto_init(struct hda_codec *codec)
19843{
19844 struct alc_spec *spec = codec->spec;
19845 alc680_auto_init_multi_out(codec);
19846 alc680_auto_init_hp_out(codec);
19847 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019848 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019849 if (spec->unsol_event)
19850 alc_inithook(codec);
19851}
19852
19853/*
19854 * configuration and preset
19855 */
19856static const char *alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019857 [ALC680_BASE] = "base",
19858 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019859};
19860
19861static struct snd_pci_quirk alc680_cfg_tbl[] = {
19862 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19863 {}
19864};
19865
19866static struct alc_config_preset alc680_presets[] = {
19867 [ALC680_BASE] = {
19868 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019869 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019870 .init_verbs = { alc680_init_verbs },
19871 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19872 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019873 .dig_out_nid = ALC680_DIGOUT_NID,
19874 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19875 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019876 .unsol_event = alc680_unsol_event,
19877 .setup = alc680_base_setup,
19878 .init_hook = alc680_inithook,
19879
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019880 },
19881};
19882
19883static int patch_alc680(struct hda_codec *codec)
19884{
19885 struct alc_spec *spec;
19886 int board_config;
19887 int err;
19888
19889 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19890 if (spec == NULL)
19891 return -ENOMEM;
19892
19893 codec->spec = spec;
19894
19895 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19896 alc680_models,
19897 alc680_cfg_tbl);
19898
19899 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19900 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19901 codec->chip_name);
19902 board_config = ALC680_AUTO;
19903 }
19904
19905 if (board_config == ALC680_AUTO) {
19906 /* automatic parse from the BIOS config */
19907 err = alc680_parse_auto_config(codec);
19908 if (err < 0) {
19909 alc_free(codec);
19910 return err;
19911 } else if (!err) {
19912 printk(KERN_INFO
19913 "hda_codec: Cannot set up configuration "
19914 "from BIOS. Using base mode...\n");
19915 board_config = ALC680_BASE;
19916 }
19917 }
19918
19919 if (board_config != ALC680_AUTO)
19920 setup_preset(codec, &alc680_presets[board_config]);
19921
19922 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019923 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019924 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019925 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019926
19927 if (!spec->adc_nids) {
19928 spec->adc_nids = alc680_adc_nids;
19929 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
19930 }
19931
19932 if (!spec->cap_mixer)
19933 set_capture_mixer(codec);
19934
19935 spec->vmaster_nid = 0x02;
19936
19937 codec->patch_ops = alc_patch_ops;
19938 if (board_config == ALC680_AUTO)
19939 spec->init_hook = alc680_auto_init;
19940
19941 return 0;
19942}
19943
19944/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019945 * patch entries
19946 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019947static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070019948 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019949 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019950 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020019951 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019952 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019953 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020019954 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019955 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019956 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019957 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019958 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
19959 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
19960 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019961 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019962 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019963 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
19964 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020019965 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010019966 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010019967 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019968 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019969 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019970 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019971 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020019972 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019973 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020019974 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019975 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019976 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yang01e0f132010-11-22 10:59:36 +010019977 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
Kailang Yang44426082008-10-15 11:18:05 +020019978 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019979 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019980 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019981 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019982 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019983 {} /* terminator */
19984};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019985
19986MODULE_ALIAS("snd-hda-codec-id:10ec*");
19987
19988MODULE_LICENSE("GPL");
19989MODULE_DESCRIPTION("Realtek HD-audio codec");
19990
19991static struct hda_codec_preset_list realtek_list = {
19992 .preset = snd_hda_preset_realtek,
19993 .owner = THIS_MODULE,
19994};
19995
19996static int __init patch_realtek_init(void)
19997{
19998 return snd_hda_add_codec_preset(&realtek_list);
19999}
20000
20001static void __exit patch_realtek_exit(void)
20002{
20003 snd_hda_delete_codec_preset(&realtek_list);
20004}
20005
20006module_init(patch_realtek_init)
20007module_exit(patch_realtek_exit)